上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 36 下一页
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2015-03-23 10:08 keepshuatishuati 阅读(105) 评论(0) 推荐(0) 编辑
摘要: Same thing need to as :Whether m > n, m > list size, or n > list size 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * in... 阅读全文
posted @ 2015-03-23 09:50 keepshuatishuati 阅读(94) 评论(0) 推荐(0) 编辑
摘要: Remember to check overflows. 1 class Solution { 2 public: 3 int reverse(int x) { 4 int sign = x 0) { 7 if (result > (INT_MAX ... 阅读全文
posted @ 2015-03-23 05:55 keepshuatishuati 阅读(92) 评论(0) 推荐(0) 编辑
摘要: Two method of making that:1. As we know this is 32 bit integer. We just get the bit and shift to 31 - i. 1 class Solution { 2 public: 3 uint32_t r... 阅读全文
posted @ 2015-03-23 05:50 keepshuatishuati 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 bool isIp(string s) { 4 int len = s.size(), ip = 0; 5 if (len == 0 || len > 4 || len > 1 && s[0] =... 阅读全文
posted @ 2015-03-23 05:41 keepshuatishuati 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1. Find mid point and break it into two lists2. reverse the second list (mid to end)3. reinsert into first one. 1 /** 2 * Definition for singly-linke... 阅读全文
posted @ 2015-03-23 05:31 keepshuatishuati 阅读(137) 评论(0) 推荐(0) 编辑
摘要: If interview did not mention n's situation, please ask.It will affect the code. EX: n = 10, List : 1 2 3. 1 /** 2 * Definition for singly-linked list... 阅读全文
posted @ 2015-03-23 05:24 keepshuatishuati 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int removeElement(int A[], int n, int elem) { 4 int index = 0; 5 for (int i = 0; i < n; i++) { 6 ... 阅读全文
posted @ 2015-03-22 17:00 keepshuatishuati 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Notes:1. Check when the loop finished. The last element still need to be remove.2. when remove the current one, do not forget to move the pointer back... 阅读全文
posted @ 2015-03-22 16:58 keepshuatishuati 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2015-03-22 16:13 keepshuatishuati 阅读(117) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 36 下一页