摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* d... 阅读全文
posted @ 2018-07-12 22:56 Little_Shel 阅读(181) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int searchInsert(vector& nums, int target) { int i; for(i=0;i=target) return i; } return i; } }; 阅读全文
posted @ 2018-07-12 21:24 Little_Shel 阅读(96) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: void moveZeroes(vector& nums) { if(nums.empty()) return; int l=0; int r=0; int len=nums.size(); while(l<len&&r<len){ i... 阅读全文
posted @ 2018-07-12 21:10 Little_Shel 阅读(65) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int removeElement(vector& nums, int val) { if(nums.empty()) return 0; int l=0; int r=nums.size()-1; while(l<r){ if(nums[l]==va... 阅读全文
posted @ 2018-07-12 17:48 Little_Shel 阅读(92) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* m... 阅读全文
posted @ 2018-07-12 15:49 Little_Shel 阅读(395) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string countAndSay(int n) { string str,ans; str="1"; if(n--==1) return str; while(n--){ ans.clear(); int left=0,ri... 阅读全文
posted @ 2018-05-09 23:12 Little_Shel 阅读(124) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int romanToInt(string s) { int ans=0; unordered_map mp; mp['I']=1; mp['V']=5; mp['X']=10; mp['L']=50; mp['C']=100;... 阅读全文
posted @ 2018-05-09 22:37 Little_Shel 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 还没有解决的问题:你能不将整数转为字符串来解决这个问题吗?(思考ing) 阅读全文
posted @ 2018-05-09 21:41 Little_Shel 阅读(98) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector twoSum(vector& nums, int target) { vector v(2,0); unordered_map hashtable; for(int i=nums.size();i--;hashtable[nums[i]]=i){ if(... 阅读全文
posted @ 2018-05-09 21:19 Little_Shel 阅读(69) 评论(0) 推荐(0) 编辑