Leetcode121 Best Time to Buy and Sell Stock
题目描述
Example 1:
1 | Input: [7,1,5,3,6,4] |
Example 1:
1 | Input: [7,1,5,3,6,4] |
1 | Merge two sorted linked lists and return it as a new list. |
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
The Linked List is represented in the input/output as a list of n
nodes. Each node is represented as a pair of [val, random_index]
where:
val
: an integer representing Node.val
random_index
: the index of the node (range from 0
to n-1
) where random pointer points to, or null
if it does not point to any node.
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
Note:
Given a 2d grid map of '1'
s (land) and '0'
s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
There are a total of n courses you have to take, labeled from 0
to n-1
.
Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]
Given the total number of courses and a list of prerequisite pairs, return the ordering of courses you should take to finish all courses.
There may be multiple correct orders, you just need to return one of them. If it is impossible to finish all courses, return an empty array.
Convert a non-negative integer to its English words representation. Given input is guaranteed to be less than 2的31 - 1.
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.
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Given a non-empty array of integers, return the k\ most frequent elements.
Example 1:
1 | Input: nums = [1,1,1,2,2,3], k = 2 |