Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to…
分类:LeetCode
[LintCode][System Design] Parking Lot
Problem More LeetCode Discussions Design a parking lot. see CC150 OO Design for details. n levels, each level …
75. Sort Colors,【LeetCode】75. Sort Colors (3 solutions)
75. Sort Colors 题目 Given an array with n objects colored red, white or blue, sort them so that objects of the …
[Leetcode] Alien Dictionary 外文字典
Alien Dictionary There is a new alien language which uses the latin alphabet. However, the order among letters…
Leetcode - Shortest Distance from All Buildings
My code: import java.util.LinkedList; import java.util.Queue; public class Solution { private int row = 0; pri…
[Leetcode]19. 删除链表的倒数第N个节点
题目描述: 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 示例:给定一个链表: 1->2->3->4->5, 和 n = 2. 当删除了倒数第二个节点后,链表变为 1->…
518. 零钱兑换 II
使用滚动数组来优化题目 一般二维 dp 的矩阵可以使用滚动数组来解决问题 DP 规划 dp[i][j]表示的是使用前i个硬币可以凑成j数目的总数. 初始条件 dp[0][0] = 1 表示使用0个硬币, 组成数目0的总数…
64. 最小路径和
class Solution(object): def minPathSum(self, grid): """ :type grid: List[List[int]] :rtype: int """ # 注意初始化 # …
[LeetCode] Sqrt(x) 求平方根
Implement int sqrt(int x). Compute and return the square root of x. 这道题要求我们求平方根,我们能想到的…
[LeetCode] Strobogrammatic Number III 对称数之三
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside dow…
[LeetCode] H-Index 求H指数
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function…
[LeetCode] K-th Smallest in Lexicographical Order 字典顺序的第K小数字
Given integers n and k, find the lexicographically k-th smallest integer in the range fr…