Given a function rand7 which generates a uniform random integer in the range 1 to 7, write a …
分类:LeetCode
[LeetCode] Max Stack 最大栈
Design a max stack that supports push, pop, top, peekMax and popMax. push(x) — Push elemen…
【leetcode】57. Insert Interval
1. 题目 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).…
【Leetcode】8. String to Integer (atoi) 字符串转整型
1. 题目 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If …
Leetcode - Contains Duplicate III
My code: public class Solution { public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) { if (…
[LeetCode] Integer to English Words 整数转为英文单词
Convert a non-negative integer to its english words representation. Given input is guaranteed to be les…
542. 01 Matrix
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two…
[Leetcode] Count Primes 数素数
Count Primes Description: Count the number of prime numbers less than a non-negative number, n. 埃拉托斯特尼筛法 Sieve…
LeetCode算法题-Minimum Depth of Binary Tree(Java实现)
这是悦乐书的第168次更新,第170篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第27题(顺位题号是111)。给定二叉树,找到它的最小深度。最小深度是沿从根节点到最近的叶节点的最短路径上的…
[LeetCode] Merge Two Sorted Lists 混合插入有序链表
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing toge…
[LeetCode] Unique Paths II 不同的路径之二
Follow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How ma…
[LeetCode] Best Time to Buy and Sell Stock III 买股票的最佳时间之三
Say you have an array for which the ith element is the price of a given stock on day i. …