[LeetCode] Shuffle an Array

2018-04-30
阅读 2 分钟
2.3k
// Init an array with set 1, 2, and 3.int[] nums = {1,2,3};Solution solution = new Solution(nums);

[LeetCode/LintCode] First Bad Version

2018-04-30
阅读 2 分钟
2.3k
The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version and the following versions are all failed in the unit tests. Find the first bad version.

[LeetCode] Symmetric Tree

2018-04-29
阅读 2 分钟
1.7k
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

[LeetCode] Combine Two Tables

2018-04-16
阅读 1 分钟
1.4k
Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:

[LeetCode] Majority Element

2018-04-16
阅读 1 分钟
1.5k
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.

[LeetCode] Length of Last Word

2018-04-15
阅读 1 分钟
1.7k
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.

[LeetCode] Contains Duplicate

2018-03-26
阅读 1 分钟
1.6k
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.

[LeetCode] Rotate Array

2018-03-26
阅读 1 分钟
1.3k
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].

[LintCode] Kth Prime Number

2018-02-26
阅读 1 分钟
3.4k
n <= 100000The prime number is defined as a natural number greater than 1, and there are no other factors except 1 and it itself.

[LintCode] Top k Largest Numbers II

2018-02-26
阅读 2 分钟
2.2k
add(number). Add a new number in the data structure.topk(). Return the top k largest numbers in this data structure. k is given when we create the data structure.

[LintCode] Missing String

2018-02-08
阅读 2 分钟
2k
Given a string str1 = This is an exampleGiven another string str2 = is example

[LintCode] Split String

2018-02-07
阅读 2 分钟
2.8k
Give a string, you can choose to split the string after one character or two adjacent characters, and make the string to be composed of only one character or two characters. Output all possible results.

[LintCode] String Homomorphism

2018-02-05
阅读 2 分钟
1.7k
Two strings are isomorphic if the characters in s can be replaced to get t.

[LintCode] Longest Palindrome

2018-01-16
阅读 1 分钟
1.8k
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.

[LintCode] Word Count (Map Reduce)

2018-01-16
阅读 2 分钟
2k
Problem Using map reduce to count word frequency. [链接] Example chunk1: "Google Bye GoodBye Hadoop code"chunk2: "lintcode code Bye" Get MapReduce result: {代码...} Solution {代码...}

[LintCode] Add Digits

2018-01-16
阅读 1 分钟
1.5k
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

[LeetCode] Maximum Subarray

2018-01-15
阅读 1 分钟
2.3k
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.

[LeetCode] Excel Sheet Column Number

2018-01-15
阅读 1 分钟
1.8k
Given a column title as appear in an Excel sheet, return its corresponding column number.

[LintCode] Amicable Pair

2018-01-12
阅读 2 分钟
2.4k
An amicable pair (m,n) consists of two integers m,n for which the sum of proper divisors (the divisors excluding the number itself) of one number equals the other.

[LintCode] Longest Repeating Subsequence

2018-01-10
阅读 1 分钟
3k
Given a string, find length of the longest repeating subsequence such that the two subsequence don’t have same string character at same position, i.e., any ith character in the two subsequences shouldn’t have the same index in the original string.

[LintCode] K Closest Points

2018-01-09
阅读 2 分钟
3.2k
Given some points and a point origin in two dimensional space, find k points out of the some points which are nearest to origin.Return these points sorted by distance, if they are same with distance, sorted by x-axis, otherwise sorted by y-axis.

[LintCode] Swap Bits

2018-01-09
阅读 1 分钟
2.2k
Write a program to swap odd and even bits in an integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, and so on).

[LintCode] Climbing Stairs II

2018-01-07
阅读 1 分钟
2k
A child is running up a staircase with n steps, and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs.

[LeetCode/LintCode] Top K Frequent Words

2018-01-07
阅读 5 分钟
4.5k
Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the lower alphabetical order comes first.

[LintCode/LeetCode] First Unique Character in a String

2018-01-01
阅读 2 分钟
1.5k
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.

[LintCode] Insert into a Cyclic Sorted List

2018-01-01
阅读 2 分钟
1.8k
Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be any single node in the list. Return the inserted new node.

[LintCode] Top k Largest Numbers I

2017-12-30
阅读 1 分钟
3k
Problem Given an integer array, find the top k largest numbers in it. Example Given [3,10,1000,-99,4,100] and k = 3.Return [1000, 100, 10]. Tags Heap Priority Queue Solution {代码...}

[LintCode] Insert Node in Sorted Linked List

2017-12-29
阅读 2 分钟
2.1k
Problem Insert a node in a sorted linked list. Example Given list = 1->4->6->8 and val = 5. Return 1->4->5->6->8. Solution {代码...}

[LintCode] String Compression

2017-12-29
阅读 2 分钟
2.1k
Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3.

[LintCode] Implement Stack (using ListNode)

2017-12-29
阅读 1 分钟
2.4k
Implement a stack. You can use any data structure inside a stack except stack itself to implement it.