随笔分类 -  LeetCode

1 2 3 4 5 ··· 8 下一页
摘要:https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/description/ 阅读全文
posted @ 2017-08-06 22:38 阿怪123 阅读(137) 评论(0) 推荐(0)
摘要:public class Solution { public String countAndSay(int n) { if(n==1) return "1"; String res="1"; for(int i=1;i<n;i++) { res=Say(res)... 阅读全文
posted @ 2016-08-14 15:08 阿怪123 阅读(118) 评论(0) 推荐(0)
摘要:import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class Solution { public boolean isValidSudoku(char[][] board) { if(board==null) ... 阅读全文
posted @ 2016-08-13 21:33 阿怪123 阅读(113) 评论(0) 推荐(0)
摘要:public class Solution { public void nextPermutation(int[] nums) { /* 假设数组大小为 n 1.从后往前,找到第一个 A[i-1] =0&&nums[i]>=nums[i+1]) i--; if(i!=-1) ... 阅读全文
posted @ 2016-08-12 11:21 阿怪123 阅读(148) 评论(0) 推荐(0)
摘要:public class Solution { public int strStr(String haystack, String needle) { if(haystack.equals("")&&needle.equals("")) return 0; int size1=haystack.length(); i... 阅读全文
posted @ 2016-08-10 21:01 阿怪123 阅读(113) 评论(0) 推荐(0)
摘要:public class Solution { public int removeDuplicates(int[] nums) { int size=nums.length; int last=0; boolean isHead=true; int lastIndex=0; for(int i=0;i<siz... 阅读全文
posted @ 2016-08-10 20:47 阿怪123 阅读(127) 评论(0) 推荐(0)
摘要:import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Solution { public List> threeSum(int[] nums) { int size=nums.length; List> res=new ArrayL... 阅读全文
posted @ 2016-08-10 20:34 阿怪123 阅读(124) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNode rem... 阅读全文
posted @ 2016-08-09 23:36 阿怪123 阅读(143) 评论(0) 推荐(0)
摘要:public class Solution { public int lengthOfLongestSubstring(String s) { int size=s.length(); int[] map=new int[206]; int maxLen=0; for(int i=0;imaxLen) ... 阅读全文
posted @ 2016-08-09 22:32 阿怪123 阅读(100) 评论(0) 推荐(0)
摘要:public class Solution { public String longestCommonPrefix(String[] strs) { int size=strs.length; if(size==0) return ""; int index=0; boolean flag=true;... 阅读全文
posted @ 2016-08-09 19:10 阿怪123 阅读(130) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNode add... 阅读全文
posted @ 2016-08-09 18:55 阿怪123 阅读(239) 评论(0) 推荐(0)
摘要:这道题的关键点在于,对于字符串的赋值操作要谨慎,尽量采用记录下标的方式,而不是整个字符串的赋值,这样可以节省时间。 阅读全文
posted @ 2016-08-09 18:19 阿怪123 阅读(127) 评论(0) 推荐(0)
摘要:public class Solution { public int myAtoi(String str) { str=str.trim(); int size=str.length(); if(str==null||size==0) return 0; double res=0; b... 阅读全文
posted @ 2016-08-03 21:30 阿怪123 阅读(135) 评论(0) 推荐(0)
摘要:public class Solution { public String convert(String s, int numRows) { if(s.equals("")) return ""; if(numRows==1) return s; String res=""; ... 阅读全文
posted @ 2016-08-03 16:05 阿怪123 阅读(112) 评论(0) 推荐(0)
摘要:public class Solution { public int[] twoSum(int[] nums, int target) { int [] res=new int[2]; int size=nums.length; boolean isGot=false; int i=0; int j=0; ... 阅读全文
posted @ 2016-08-03 15:40 阿怪123 阅读(127) 评论(0) 推荐(0)
摘要:public class Solution { public int[] searchRange(int[] nums, int target) { int []res=new int[2]; int size=nums.length; int left=0; int right=size-1; ... 阅读全文
posted @ 2016-08-02 23:15 阿怪123 阅读(185) 评论(0) 推荐(0)
摘要:import java.util.Arrays; public class Solution { public int threeSumClosest(int[] nums, int target) { int size=nums.length; int res=0; if(size<3) return 0; ... 阅读全文
posted @ 2016-08-02 18:59 阿怪123 阅读(115) 评论(0) 推荐(0)
摘要:import java.util.ArrayList; import java.util.List; public class Solution { public List letterCombinations(String digits) { int size=digits.length(); List res=new ArrayList(); ... 阅读全文
posted @ 2016-07-21 15:58 阿怪123 阅读(150) 评论(0) 推荐(0)
摘要:import java.util.Stack; public class Solution { public boolean isValid(String s) { int size=s.length(); if(size==0) return true; boolean res=true; Sta... 阅读全文
posted @ 2016-07-18 21:43 阿怪123 阅读(130) 评论(0) 推荐(0)
摘要:import java.util.ArrayList; import java.util.List; public class Solution { public List> combine(int n, int k) { List> res=new ArrayList>(); List temp=new ArrayList(); bfs... 阅读全文
posted @ 2016-07-18 14:49 阿怪123 阅读(146) 评论(0) 推荐(0)

1 2 3 4 5 ··· 8 下一页