Loading

摘要: 题目 代码/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2018-09-14 08:23 李正浩 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: string longestCommonPrefix(vector& strs) { //题目要求的是必须从每个字符串的0索引开始计算公共前缀 if(strs.size()==0) ... 阅读全文
posted @ 2018-09-14 08:21 李正浩 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: int strStr(string haystack, string needle) { if(haystack.size()==0&&needle.size()==0) re... 阅读全文
posted @ 2018-09-14 08:18 李正浩 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: int myAtoi(string str) { int res=0,sign=1; int i=str.find_first_not_of(' '); if(st... 阅读全文
posted @ 2018-09-14 08:16 李正浩 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: bool isPalindrome(string s) { string res; for(int i=0;i='a'&&s[i]='A'&&s[i]='0'&&s[i]<='9'))... 阅读全文
posted @ 2018-09-14 08:14 李正浩 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: bool isAnagram(string s, string t) { //字符交换了位置,但是每个字符的个数是一样的 map res1,res2; if(s.size... 阅读全文
posted @ 2018-09-14 08:13 李正浩 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: int firstUniqChar(string s) { std::map table; //先用map存储,value是出现的次数 for(int i=0;i<s.s... 阅读全文
posted @ 2018-09-14 08:11 李正浩 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: int reverse(int x) { int rev = 0; while (x != 0) { int pop = x % 10; x ... 阅读全文
posted @ 2018-09-14 08:09 李正浩 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: string reverseString(string s) { for (int i=0,j=s.size()-1; i<=j; i++, j--) { std::swap(s[i],s[j]); }... 阅读全文
posted @ 2018-09-14 08:06 李正浩 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 题目代码class Solution {public: void rotate(vector>& matrix) { int n=matrix.size(); for(int i=0;i (0,3)(0,1) -> (1,3)(0,2) ->... 阅读全文
posted @ 2018-09-14 08:03 李正浩 阅读(114) 评论(0) 推荐(0) 编辑