上一页 1 ··· 5 6 7 8 9 10 11 下一页

2013年5月19日

摘要: Problem:Implement pow(x,n).Analysis:Notice n may be negative numbers.Simply use for loop to implement is okay when n is small. When n is large enough, it may cause Time Limit Exceeded error. In this way, the time complexity is O(n).There's a recursive implementation method can reduce the complex 阅读全文
posted @ 2013-05-19 11:18 freeneng 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Problem:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character'.'.A partially filled sudoku which is valid.Analysis:Simulation problem, the nice part here is use a same function for t 阅读全文
posted @ 2013-05-19 09:32 freeneng 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Problem:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 2 → 1[1,3,5,6], 7 → 4[1,3,5,6], 0 → 0Analysis:A 阅读全文
posted @ 2013-05-19 09:01 freeneng 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Problem:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant space. You maynotmodify the values in the list, only nodes itself can be changed.Analysis:One 阅读全文
posted @ 2013-05-19 08:46 freeneng 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Problem:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Analysis:like merge sort.Time complexity is O(m+n), Space complexity is O(m+n)Code: 1 /** 2 * Definition for singly-linked list. 3 * public class Lis.. 阅读全文
posted @ 2013-05-19 06:38 freeneng 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Problem:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct order,"()"and"()[]{}"are all valid but"(]"and"([)]"are 阅读全文
posted @ 2013-05-19 04:16 freeneng 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Problem:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5.Note:Givennwill always be valid.Try to do this in one 阅读全文
posted @ 2013-05-19 03:37 freeneng 阅读(172) 评论(0) 推荐(0) 编辑
摘要: Problem:Write a function to find the longest common prefix string amongst an array of strings.Analysis:Each time take a character from the first string and compare it with other strings' same position character.If reaching some end of some string or find a mismatch, then the longest common prefi 阅读全文
posted @ 2013-05-19 03:20 freeneng 阅读(279) 评论(0) 推荐(0) 编辑
摘要: Problem:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Analysis:Some Roman Number examples can be seen here:http://literacy.kent.edu/Minigrants/Cinci/romanchart.htm.Use a one pass scan to decide whether add or subtract a number from current 阅读全文
posted @ 2013-05-19 02:11 freeneng 阅读(572) 评论(0) 推荐(0) 编辑

2013年4月26日

摘要: 1. Sleep before 12:00 pm, get up before 8:am every day [0/10]2. GPA reaches 3.88 after 6 courses [Achieved]3. Finish the thesis during the summer [In Porgress...] 4. Find a great advisor towards Phd [In Progress...][new 07/15/2013]5. Prepare for the basic coding problems(LeetCode 63/132, Project... 阅读全文
posted @ 2013-04-26 23:13 freeneng 阅读(100) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 下一页

导航