[LintCode/LeetCode] Binary Tree Level Order Traversal I & II

2016-06-04
阅读 3 分钟
2.3k
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

[LeetCode] Longest Substring Without Repeating Characters

2016-06-03
阅读 2 分钟
2k
Given a string, find the length of the longest substring without repeating characters.

[LeetCode] Combination Sum III | Combination Sum IV

2016-06-03
阅读 4 分钟
3.5k
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.

[LeetCode] Remove LinkedList Elements

2016-06-02
阅读 2 分钟
2.3k
Remove all elements from a linked list of integers that have value val.

[LeetCode] Number of Digit One

2016-06-02
阅读 2 分钟
2.7k
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

[LeetCode] Range Sum Query Immutable

2016-06-02
阅读 1 分钟
2.2k
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.

[LeetCode] Reconstruct Itinerary

2016-06-02
阅读 3 分钟
3.1k
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.

[LeetCode] Increasing Triplet Subsequence

2016-06-02
阅读 1 分钟
2.4k
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.

[LeetCode] Palindrome Pairs

2016-05-31
阅读 5 分钟
5.1k
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.

[LeetCode] Counting Bits

2016-05-31
阅读 1 分钟
2.2k
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.

[HackerRank] Time Conversion

2016-05-31
阅读 2 分钟
2.4k
Problem Given a time in AM/PM format, convert it to military (24-hour) time. Input Format A single string containing a time in 12-hour clock format. Output Format Convert and print the given time in 24-hour format. Sample Input {代码...} Sample Output {代码...} Solution 1. using char[] {代码...} ...

[HackerRank] Staircase

2016-05-31
阅读 1 分钟
2.1k
Your teacher has given you the task of drawing a staircase structure. Being an expert programmer, you decided to make a program to draw it for you instead. Given the required height, can you print a staircase as shown in the example?

[HackerRank] Plus Minus

2016-05-31
阅读 2 分钟
3k
Given an array of integers, calculate which fraction of its elements are positive, which fraction of its elements are negative, and which fraction of its elements are zeroes, respectively. Print the decimal value of each fraction on a new line.

[HackerRank] Diagonal Difference

2016-05-30
阅读 2 分钟
2.7k
Given a square matrix of size N x N, calculate the absolute difference between the sums of its diagonals.

[HackerRank] Simple Array Sum | A Very Big Sum

2016-05-30
阅读 2 分钟
3.2k
The first line contains an integer, N, denoting the size of the array. The second line contains N space-separated integers representing the array's elements.

[LeetCode] Power of Two, Power of Three, Power of Four

2016-05-30
阅读 2 分钟
2.3k
三道基本相同的题目,都可以用位操作、递归和迭代来做。 Power of Two 1. Bit Manipulation -- 2 ms beats 21.88% {代码...} 2. Iteration -- 2 ms beats 21.88% {代码...} Power of Three 1. Recursion -- 20 ms beats 24% {代码...} 2. Iteration -- 15-17 ms beats 72.54%-91.74% {代码...} Power of Four Bit Manipu...

[LeetCode] Integer Break

2016-05-30
阅读 2 分钟
2.7k
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.

[LeetCode] Reverse String

2016-05-30
阅读 1 分钟
2.8k
Write a function that takes a string as input and returns the string reversed.

[LeetCode] Reverse Vowels of a String

2016-05-30
阅读 2 分钟
2.3k
Write a function that takes a string as input and reverse only the vowels of a string.

[LeetCode] Top K Frequent Elements

2016-05-30
阅读 3 分钟
3.9k
Given a non-empty array of integers, return the k most frequent elements.

[LeetCode] Intersection of Two Arrays I & II

2016-05-30
阅读 5 分钟
4.2k
Each element in the result must be unique.The result can be in any order.

[LintCode/LeetCode] Scramble String

2016-05-30
阅读 2 分钟
2.2k
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.

[LintCode] Move Zeroes

2016-05-29
阅读 2 分钟
2.2k
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.

[LintCode] Previous Permutation

2016-05-26
阅读 1 分钟
2.8k
Problem Given a list of integers, which denote a permutation. Find the previous permutation in ascending order. Notice The list may contains duplicate integers. Example For [1,3,2,3], the previous permutation is [1,2,3,3] For [1,2,3,4], the previous permutation is [4,3,2,1] Note Solution {代码...}

[LintCode/LeetCode] Flatten Nested List Iterator

2016-05-25
阅读 4 分钟
5k
Each element is either an integer, or a list -- whose elements may also be integers or other lists.

[LintCode] Kth Smallest Number in Sorted Matrix

2016-05-25
阅读 2 分钟
3.1k
Problem Find the kth smallest number in at row and column sorted matrix. Example Given k = 4 and a matrix: {代码...} return 5 Challenge O(k log n), n is the maximal number in width and height. Note Solution I. Muggle (95% ac, last case exceeded time limit) {代码...} II. 堆排序 {代码...}

[LintCode/LeetCode] Candy

2016-05-25
阅读 2 分钟
3.2k
There are N children standing in a line. Each child is assigned a rating value.

[LintCode/LeetCode] Wildcard Matching

2016-05-24
阅读 3 分钟
2.2k
'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).

[LintCode] Majority Number I II III

2016-05-24
阅读 3 分钟
3.1k
Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it.

[LintCode/LeetCode] Minimum Window Substring

2016-05-23
阅读 3 分钟
2.4k
Given a string source and a string target, find the minimum window in source which will contain all the characters in target.