原创 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

原创 582. Kill Process

Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has

原创 35. Search Insert Position

當循環結束時,如果沒有找到target,那麼low一定停target應該插入的位置上,high一定停在恰好比target小的index上。 public class Solution { public int searchInse

原创 39. Combination Sum I && II

public class Solution { public List<List<Integer>> combinationSum(int[] c, int t) { if(c == null || c.lengt

原创 76. Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity

原创 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 onl

原创 605. Can Place Flowers

Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be

原创 26. Remove Duplicates from Sorted Array

public class Solution { public int removeDuplicates(int[] nums) { int i=0; for(int j=1; j<nums.leng

原创 152. Maximum Product Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest product. For exam

原创 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. publi

原创 72. Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation

原创 108. Convert Sorted Array to Binary Search Tree

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeN

原创 Convert a Binary Tree to Doubly Linked List

/* Convert a binary search tree to doubly linked list with in-order traversal. Example Given a binary search tree:

原创 88. Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume tha

原创 516. Longest Palindromic Subsequence

Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s