14. Longest Common Prefix 很聪明的做法,先假设第一个string是Longest Common Prefix, 跟后面的string一个一个对比,不match就删除最后一个字符,until it matches。
92. Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL./** * Definition for s
108. Convert Sorted Array to Binary Search Tree /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution {
35. Search Insert Position 当循环结束时,如果没有找到target,那么low一定停target应该插入的位置上,high一定停在恰好比target小的index上。public class Solution { public int searchInsert(int[] nums, int target) { if(nums == null || nums.length == 0){
26. Remove Duplicates from Sorted Array public class Solution { public int removeDuplicates(int[] nums) { int i=0; for(int j=1; j<nums.length; j++){ if(nums[i] != nums[j]){ i++;
39. Combination Sum I && II public class Solution { public List> combinationSum(int[] c, int t) { if(c == null || c.length == 0){ return null; } List> result = new ArrayList>(); Li
582. Kill Process Given n processes, each process has a unique PID (process id) and its PPID (parent process id).Each process only has one parent process, but may have one or more children processes. This is just l
317. Shortest Distance from All Buildings You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. You are given a 2D grid of values 0, 1 or 2, wh
12. Integer to Roman Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.要点就是要把900,400等特殊数字的表达方式加上,再按大小依次往下除即可 public String intToRoman(int num) { if(num &...