[LeetCode] 177. Nth Highest Salary

2018-12-26
阅读 1 分钟
2.3k
Write a SQL query to get the nth highest salary from the Employee table.

[LeetCode] 258. Add Digits

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

[LeetCode] 722. Remove Comments

2018-12-26
阅读 4 分钟
1.3k
Given a C++ program, remove comments from it. The program source is an array where source[i] is the i-th line of the source code. This represents the result of splitting the original source code string by the newline character n.

[LeetCode] 385. Mini Parser

2018-12-26
阅读 3 分钟
1.8k
Given a nested list of integers represented as a string, implement a parser to deserialize it.

[LeetCode] 657. Robot Return to Origin

2018-12-25
阅读 2 分钟
1.2k
There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.

[LeetCode] 130. Surrounded Regions

2018-12-25
阅读 2 分钟
1.5k
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.

[LeetCode] 410. Split Array Largest Sum

2018-12-25
阅读 2 分钟
1.9k
Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays.

[LeetCode] 480. Sliding Window Median

2018-12-17
阅读 3 分钟
2.7k
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.

[LeetCode] 71. Simplify Path

2018-12-17
阅读 2 分钟
1.5k
In a UNIX-style file system, a period ('.') refers to the current directory, so it can be ignored in a simplified path. Additionally, a double period ("..") moves up a directory, so it cancels out whatever the last directory was. For more information, look here: [链接]

[LeetCode] 702. Search in a Sorted Array of Unknown Size

2018-12-14
阅读 2 分钟
4.7k
Given an integer array sorted in ascending order, write a function to search target in nums. If target exists, then return its index, otherwise return -1. However, the array size is unknown to you. You may only access the array using an ArrayReader interface, where ArrayReader.get(k) returns the ...

[LeetCode] 280. Wiggle Sort

2018-12-14
阅读 1 分钟
1.8k
Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3]....

[LeetCode] 245. Shortest Word Distance III

2018-12-14
阅读 2 分钟
2.2k
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

[LeetCode] 244. Shortest Word Distance II

2018-12-14
阅读 2 分钟
2k
Design a class which receives a list of words in the constructor, and implements a method that takes two words word1 and word2 and return the shortest distance between these two words in the list. Your method will be called repeatedly many times with different parameters.

[LeetCode] 243. Shortest Word Distance

2018-12-14
阅读 1 分钟
1.6k
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

[LeetCode] 487. Max Consecutive Ones II

2018-12-14
阅读 1 分钟
1.9k
Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0.

[LeetCode] 873. Length of Longest Fibonacci Subsequence

2018-12-13
阅读 2 分钟
2.3k
n >= 3X_i + X_{i+1} = X_{i+2} for all i + 2 <= nGiven a strictly increasing array A of positive integers forming a sequence, find the length of the longest fibonacci-like subsequence of A. If one does not exist, return 0.

[LeetCode] 150. Evaluate Reverse Polish Notation

2018-12-13
阅读 2 分钟
2.3k
Evaluate the value of an arithmetic expression in Reverse Polish Notation.

[LeetCode] 787. Cheapest Flights Within K Stops

2018-12-13
阅读 3 分钟
2k
There are n cities connected by m flights. Each fight starts from city u and arrives at v with a price w.

[LeetCode] 48. Rotate Image

2018-12-13
阅读 2 分钟
1.6k
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

[LeetCode] 763. Partition Labels

2018-12-12
阅读 3 分钟
1.9k
A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.

[LeetCode] 93. Restore IP Addresses

2018-12-12
阅读 1 分钟
2.4k
Given a string containing only digits, restore it by returning all possible valid IP address combinations.

[LeetCode] 588. Design In-Memory File System

2018-12-11
阅读 4 分钟
6.4k
ls: Given a path in string format. If it is a file path, return a list that only contains this file's name. If it is a directory path, return the list of file and directory names in this directory. Your output (file and directory names together) should in lexicographic order.

[LeetCode] 675. Cut Off Trees for Golf Event

2018-12-11
阅读 3 分钟
2.7k
You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-negative 2D map, in this map:

[LeetCode] 279. Perfect Squares

2018-12-10
阅读 1 分钟
1.8k
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.

[LeetCode] 934. Shortest Bridge

2018-12-10
阅读 2 分钟
2.3k
In a given 2D binary array A, there are two islands. (An island is a 4-directionally connected group of 1s not connected to any other 1s.)

[LeetCode] 953. Verifying an Alien Dictionary

2018-12-10
阅读 2 分钟
2.2k
In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.

[LeetCode] 41. First Missing Positive

2018-12-06
阅读 1 分钟
1.6k
Given an unsorted integer array, find the smallest missing positive integer.

[LeetCode] 894. All Possible Full Binary Trees

2018-12-06
阅读 2 分钟
3.5k
A full binary tree is a binary tree where each node has exactly 0 or 2 children.

[LeetCode] 159. Longest Substring with At Most Two Distinct

2018-12-05
阅读 1 分钟
2.2k
Given a string s , find the length of the longest substring t that contains at most 2 distinct characters.

[LeetCode] 214. Shortest Palindrome

2018-12-05
阅读 1 分钟
1.8k
Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.