LeetCode Word Search 79. Word Search [https://leetcode.com/problems/word-search/] LintCode-123.Word Search [http://www.lintcode.com/en/problem/word-search/] Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally

LeetCode Sort Colors 75. Sort Colors [https://leetcode.com/problems/sort-colors/] LintCode-148.Sort Colors [http://www.lintcode.com/en/problem/sort-colors/] Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.

LintCode Sort Colors II LintCode-143.Sort Colors II [http://www.lintcode.com/en/problem/sort-colors-ii/] Given an array of n objects with k different colors (numbered from 1 to k), sort them so that objects of the same color are adjacent, with the colors in the order 1, 2, ... k. Notice: You are not

LeetCode Missing Ranges 163. Missing Ranges [https://leetcode.com/problems/missing-ranges/] Given a sorted integer array where the range of elements are in the inclusive range [lower, upper], return its missing ranges. For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, return ["2", "4->49", "51->74", "76->99"

LeetCode Combination Sum III 216. Combination Sum III [https://leetcode.com/problems/combination-sum-iii/] Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Example 1: Input: k = 3, n

LeetCode Rotate Array 189. Rotate Array [https://leetcode.com/problems/rotate-array] Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to

Array Rotate Image 48. Rotate Image [https://leetcode.com/problems/rotate-image/] You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? public class Solution { public void rotate(int[][] matrix) { if (matrix == null) { return; } int n = matrix.length;

Array Search Insert Position 35. Search Insert Position [https://leetcode.com/problems/search-insert-position/] Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Here are

LeetCode 3Sum 15. 3Sum [https://leetcode.com/problems/3sum/] LintCode-57.3Sum [http://www.lintcode.com/en/problem/3sum] Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

LeetCode Median of Two Sorted Arrays 4. Median of Two Sorted Arrays [https://leetcode.com/problems/median-of-two-sorted-arrays/] There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: nums1 = [1, 3] nums2

LintCode First Position of Target LintCode-14.First Position of Target > For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity. > If the target number does not exist in the array, return -1. > Example > If the array is [1, 2, 3, 3,

LintCode Majority Number LintCode-46. Majority Number [http://www.lintcode.com/en/problem/majority-number/] > Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it. > Example > Given [1, 1, 1, 1, 2, 2, 2], return 1 > Challenge > O(n) time and

LintCode Subarray Sum LintCode-138.Subarray Sum [http://www.lintcode.com/en/problem/subarray-sum/] > Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first number and the index of the last number. > Notice: There is at least one subarray that it's

LintCode The Smallest Difference LintCode-387.The Smallest Difference [http://www.lintcode.com/en/problem/the-smallest-difference/] > Given two array of integers(the first array is array A, the second array is array B), now we are going to find a element in array A which is A[i], and another element in array B which

LintCode Interleaving Positive and Negative Numbers LintCode-144.Interleaving Positive and Negative Numbers [http://www.lintcode.com/en/problem/interleaving-positive-and-negative-numbers/] > Given an array with positive and negative integers. Re-range it to interleaving with positive and negative integers. > Notice: You are not necessary to keep the original order of positive integers or negative integers. > Example: Given [-1, -2,

LintCode Maximum Subarray Difference LintCode-45.Maximum Subarray Difference [http://www.lintcode.com/en/problem/maximum-subarray-difference/] > Given an array with integers. > Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is the largest. > Return the largest difference. > Notice: The subarray should contain at least one number > Example: For [1, 2, -3,

LintCode Maximum Subarray II LintCode-42.Maximum Subarray II [http://www.lintcode.com/en/problem/maximum-subarray-ii/] > Given an array of integers, find two non-overlapping subarrays which have the largest sum. The number in each subarray should be contiguous. Return the largest sum. > Notice: The subarray should contain at least one number > Example: For given [1,

LintCode Best Time to Buy and Sell Stock III LintCode-151.Best Time to Buy and Sell Stock III [http://www.lintcode.com/en/problem/best-time-to-buy-and-sell-stock-iii/] > Say you have an array for which the ith element is the price of a given stock on day i. > Design an algorithm to find the maximum profit. You may complete at most two

LintCode Partition Array by Odd and Even LintCode-373.Partition Array by Odd and Even [http://www.lintcode.com/en/problem/partition-array-by-odd-and-even/] > Partition an integers array into odd number first and even number second. > Example: Given [1, 2, 3, 4], return [1, 3, 2, 4] > Challenge: Do it in-place. public class Solution { /** * @param nums: an array of integers

LintCode Trapping Rain Water LintCode-363.Trapping Rain Water [http://www.lintcode.com/en/problem/trapping-rain-water] > Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. > Example: Given [0,1,0,2,1,0,1,3,2,1,

LintCode Two Sum Closest LintCode-533.Two Sum Closest [http://www.lintcode.com/en/problem/two-sum-closest/] > Given an array nums of n integers, find two integers in nums such that the sum is closest to a given number, target. > Return the difference between the sum of the two integers and the target. > Example: Given array

LintCode Maximum Subarray LintCode-41.Maximum Subarray [http://www.lintcode.com/en/problem/maximum-subarray/] > Given an array of integers, find a contiguous subarray which has the largest sum. > Notice: The subarray should contain at least one number. > Given the array [−2,2,−3,4,−1,2,1,−5,3], the contiguous subarray [4,−1,