- 博客(14)
- 收藏
- 关注
原创 c++实现斐波那契数列
递归实现long long Fibonacci(unsigned int n){ if(n<=0) return 0; if(n==1) return 1; return Fibonacci(n-1)+Fibonacci(n-2);}
2017-09-29 10:32:29
6407
原创 找工作小结
找工作已有半个月左右,虽然并不顺利,但也算收获良多,故总结一发笔试:1.数据结构是重中之重,如hash表,二叉排序树,快速排序等频繁出现,大数乘法和斐波那契数也是常见题型;2.数据库知识的匮乏让我在笔试时吃了很多亏,十一期间要好好补习一下;3.在线编程注意边界和特殊情况的考量,刷题是很有必要的,注意C++编程尽量多使用STL库函数,加快编码速度;面试:面试目前也只参加了华为
2017-09-26 17:20:32
236
原创 【LEET-CODE】53. Maximum Subarray
Question:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarra
2017-06-20 17:22:58
238
原创 【LEET-CODE】11. Container With Most Water
Question:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) an
2017-05-02 14:57:28
217
原创 【LEET-CODE】34. Search for a Range【Medium】
Question:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log
2017-04-28 10:58:38
221
原创 【LEET-CODE】33. Search in Rotated Sorted Array【Medium】
Question:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to
2017-04-28 10:14:43
229
原创 【LEET-CODE】12. Integer to Roman【Medium】
Qusetion:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路:把整数转成罗马数字,要仔细理解罗马数字的规则,如39应该对应XLI而不是IXL。思路的话从到大到小不断整除取余,注意如果是900
2017-04-27 15:43:43
152
原创 【LEET-CODE】9. Palindrome Number
Question:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer
2017-04-26 09:11:33
214
原创 【LEET-CODE】38. Count and Say
Question:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21
2017-04-24 17:40:35
281
原创 【LEET-CODE】35. Search Insert Position
Question: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
2017-04-24 17:30:49
213
原创 【LEET-CODE】28. Implement strStr()
Question:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.思路:返回needle(关键字)在haystack(字符串)中第一次出现的位置,如果needle不在hay
2017-04-24 16:34:25
170
原创 【LEET-CODE】14. Longest Common Prefix
Qusetion:Write a function to find the longest common prefix string amongst an array of strings.思路:找若干数组的最长公共字符串,先找出最短的数组作为初始最长数组mylongest,从头开始依次比较,不一致时更新mylongest;注意substr(0,j)的用法,string的成员函
2017-04-24 15:57:02
190
原创 【LEET-CODE】27. Remove Element
Qusetion:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with const
2017-04-24 15:27:48
255
原创 【LEET-CODE】26. Remove Duplicates from Sorted Array
``` pythonclass Solution {public: int removeDuplicates(vector& nums) { if(nums.size()==0) return 0; if(nums.size()==1) return 1; for(int i = 0 ;i
2017-04-24 11:41:25
182
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人