Loading

摘要: 题目 代码class Solution {public: string longestPalindrome(string s) { if(s.size()==1) return s; string max=s.substr(... 阅读全文
posted @ 2018-09-17 21:14 李正浩 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: int lengthOfLongestSubstring(string s) { //用dic存储每个字符最后一次出现的位置 vector dic(255,-1); in... 阅读全文
posted @ 2018-09-17 21:13 李正浩 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: vector> groupAnagrams(vector& strs) { vector> res; unordered_map> table; for(auto i:s... 阅读全文
posted @ 2018-09-17 21:11 李正浩 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: void setZeroes(vector>& matrix) { if(matrix.size()==0) return; int lastRow=-1,H=ma... 阅读全文
posted @ 2018-09-17 18:59 李正浩 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: vector> threeSum(vector& nums) { //先固定住第一个数字,然后后面两个数字为 i+1和 nums.size()-1开始往中间缩小,并且要考虑数字重复的问题,时间复杂度... 阅读全文
posted @ 2018-09-17 18:55 李正浩 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: int missingNumber(vector& nums) { int result = nums.size(); for(int i=0;i<nums.size... 阅读全文
posted @ 2018-09-17 18:51 李正浩 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: bool isValid(string s) { stack sta; for(auto i:s) { switch(i) { ... 阅读全文
posted @ 2018-09-17 18:47 李正浩 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: vector> generate(int numRows) { vector> res; if(numRows==0) return res; fo... 阅读全文
posted @ 2018-09-17 18:46 李正浩 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: uint32_t reverseBits(uint32_t n) { n=(n>>16)|(n>8)|((n&0x00ff00ff)>4)|((n&0x0f0f0f0f)>2)|((n&0x3333... 阅读全文
posted @ 2018-09-17 18:43 李正浩 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 题目 代码class Solution {public: int hammingDistance(int x, int y) { int res=x^y; int num=1; int result=0; whil... 阅读全文
posted @ 2018-09-17 18:40 李正浩 阅读(124) 评论(0) 推荐(0) 编辑