LeetCode
文章平均质量分 58
wacdzz22
这个作者很懒,什么都没留下…
展开
-
7-Reverse Integer-C++
代码如下: int reverse(int x) { int result = 0; int err = 0; int temp; bool sign = true; if(x sign = false; x=-x;原创 2017-05-11 21:27:40 · 271 阅读 · 0 评论 -
9-Palindrome Number -C++
代码如下:bool isPalindrome(int x) { int high = x; int min = 0; int temp; while(high>0) { temp = high%10; min = 10*min+temp原创 2017-05-11 22:02:53 · 273 阅读 · 0 评论 -
今日LeetCode--13 14
13.Roman to integerint romanToInt(string s) { int result = ToNum(s[0]); for(int i = 1; i { if(ToNum(s[i-1]) result +=ToNum(s[i])-2*ToNum(s原创 2017-05-12 10:09:52 · 230 阅读 · 0 评论 -
今日LeetCode--21
21 merged two sorted lists开始时用错了方式//ListNode* merge;//merge->next = new ListNode(l1->val);提示错误:Line 39: member access within null pointer of type 'struct ListNode'错误原因:对空链表进行操作;修改方案:加头原创 2017-05-13 12:48:10 · 4488 阅读 · 0 评论 -
今日LeetCode--28,38
28. Implement strStr()代码如下:class Solution { public: int strStr(string haystack, string needle) { int offset; int h = haystack.length(); int n = needle.lengt原创 2017-05-15 15:03:39 · 168 阅读 · 0 评论