273.Integer to English Words

Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.

Read More

88.Merge Sorted Array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Solution {
public void merge(int[] nums1, int m, int[] nums2, int n) {
int end1 = m - 1, end2 = n - 1, end = m + n - 1;
while (end1 >= 0 && end2 >= 0) {
if (nums2[end2] > nums1[end1]) {
System.out.println("nums2 " + end2);
nums1[end--] = nums2[end2--];
} else {
System.out.println("nums1 " + end1);
nums1[end--] = nums1[end1--];
}
}
// no need to check nums1 since it's already there and in order
while (end2 >= 0) {
nums1[end--] = nums2[end2--];
}
}
}

Read More

098.Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST).

Read More

257.Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.

Read More

346.Moving Average From Data Stream

Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.

Read More

295.Find Median From Data Stream

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

Read More

374.Guess Number Higher or Lower

We are playing the Guess Game. The game is as follows:

Read More

394.Decode String

Given an encoded string, return it’s decoded string.

Read More

276.Paint Fence

There is a fence with n posts, each post can be painted with one of the k colors.

Read More

265.Paint House II

The cost of painting each house with a certain color is represented by a n x k cost matrix. For example, costs[0][0] is the cost of painting house 0 with color 0; costs[1][2] is the cost of painting house 1 with color 2, and so on… Find the minimum cost to paint all houses. Could you solve it in O(nk) runtime?

Read More

163.Missing Ranges

Given a sorted integer array where the range of elements are [lower, upper] inclusive, return its missing ranges.

Read More

239.Sliding Window Maximum

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.

Read More

049.Group Anagrams

Given an array of strings, group anagrams together.

Read More

347.Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements.

Read More

389.Find the Difference

Given two strings s and t which consist of only lowercase letters.

Read More