随笔分类 -  leedcode

上一页 1 ··· 7 8 9 10 11 12 下一页
摘要:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文
posted @ 2015-07-06 20:41 ~每天进步一点点~ 阅读(136) 评论(0) 推荐(0)
摘要:public class Solution { public boolean isPalindrome(int x) { //负数不是回文 //主要的突破点是如何获得整数的第n位和后n位(/和%运算结合) if(x=10){//这里面需要考虑整数越界的... 阅读全文
posted @ 2015-07-06 18:55 ~每天进步一点点~ 阅读(114) 评论(0) 推荐(0)
摘要:public class Solution { public int myAtoi(String str) { //此题需要注意的细节很多 //1.对于“ -123”,“ +3231”,需要考虑去除最前的空格,主要利用循环 //2.对于越界情况需要判... 阅读全文
posted @ 2015-07-05 22:56 ~每天进步一点点~ 阅读(158) 评论(0) 推荐(0)
摘要:public class Solution { public int reverse(int x) { //此题需要注意整数越界问题,因此先将res声明为long,注意32位的范围是0x80000000到0x7fffffff long res=0; i... 阅读全文
posted @ 2015-07-04 22:51 ~每天进步一点点~ 阅读(134) 评论(0) 推荐(0)
摘要:public class Solution { public String convert(String s, int numRows) { //本题通过画图numRows=4和numRows=5可以得到规则,主线路距离是2*numRows-2;辅助行是(numRows-i-1)... 阅读全文
posted @ 2015-07-04 22:26 ~每天进步一点点~ 阅读(139) 评论(0) 推荐(0)
摘要:public class Solution { public String longestPalindrome(String s) { //本题是动态规划思想,构造一个数组pal[i][j],表示从i到j是否为一个回文, //pal[i][j]=true;if i=... 阅读全文
posted @ 2015-07-04 21:40 ~每天进步一点点~ 阅读(143) 评论(0) 推荐(0)
摘要:There are two sorted arraysnums1andnums2of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should... 阅读全文
posted @ 2015-07-04 16:09 ~每天进步一点点~ 阅读(165) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
posted @ 2015-07-04 14:03 ~每天进步一点点~ 阅读(129) 评论(0) 推荐(0)
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文
posted @ 2015-07-03 23:46 ~每天进步一点点~ 阅读(159) 评论(0) 推荐(0)
摘要:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2015-07-03 23:16 ~每天进步一点点~ 阅读(133) 评论(0) 推荐(0)
摘要:After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This t... 阅读全文
posted @ 2015-07-03 21:46 ~每天进步一点点~ 阅读(241) 评论(0) 推荐(0)
摘要:双指针思路,循环时,声明一个变量保存范围起始的下标注意:如何在数组只有一个元素,还有遍历到最后一个元素的时候,去更新结果集。public class Solution { public List summaryRanges(int[] nums) { List res=new A... 阅读全文
posted @ 2015-06-28 22:46 ~每天进步一点点~ 阅读(155) 评论(0) 推荐(0)
摘要:public class Solution { public int findKthLargest(int[] nums, int k) { return find(nums,nums.length-k,0,nums.length-1); } public int f... 阅读全文
posted @ 2015-05-31 17:04 ~每天进步一点点~ 阅读(147) 评论(0) 推荐(0)
摘要:Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文
posted @ 2015-05-31 15:02 ~每天进步一点点~ 阅读(183) 评论(0) 推荐(0)
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?/**... 阅读全文
posted @ 2015-05-05 14:33 ~每天进步一点点~ 阅读(152) 评论(0) 推荐(0)
摘要:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. *... 阅读全文
posted @ 2015-05-05 14:30 ~每天进步一点点~ 阅读(118) 评论(0) 推荐(0)
摘要:class Solution {public: void rotate(int nums[], int n, int k) { k%=n; reverse(nums,0,n-k-1); reverse(nums,n-k,n-1); rev... 阅读全文
posted @ 2015-04-30 21:49 ~每天进步一点点~ 阅读(98) 评论(0) 推荐(0)
摘要:class Solution {public: int hammingWeight(uint32_t n) { int result=0; while(n){ n=n&(n-1); result++; ... 阅读全文
posted @ 2015-04-30 21:48 ~每天进步一点点~ 阅读(105) 评论(0) 推荐(0)
摘要:public class Solution { public int rob(int[] nums) { int result=0; int rob=0; int unrob=0; for(int i=0;ib?a:b; }} 阅读全文
posted @ 2015-04-30 21:47 ~每天进步一点点~ 阅读(148) 评论(0) 推荐(0)
摘要:public class Solution { public boolean isHappy(int n) { int sum=0; if(n==1||n==7) return true; else if(n>1&&n0){ ... 阅读全文
posted @ 2015-04-30 21:46 ~每天进步一点点~ 阅读(105) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 下一页