mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
添加内容
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
# [4. Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
There are two sorted arrays **nums1** and **nums2** of size m and n respectively.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [7. Reverse Integer](https://leetcode.com/problems/reverse-integer/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a 32-bit signed integer, reverse digits of an integer.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [17. Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a string containing digits from `2-9` inclusive, return all possible letter combinations that the number could represent.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [29. Divide Two Integers](https://leetcode.com/problems/divide-two-integers/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given two integers `dividend` and `divisor`, divide two integers without using multiplication, division and mod operator.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [34. Find First and Last Position of Element in Sorted Array](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an array of integers `nums` sorted in ascending order, find the starting and ending position of a given `target` value.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [35. Search Insert Position](https://leetcode.com/problems/search-insert-position/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [36. Valid Sudoku](https://leetcode.com/problems/valid-sudoku/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated **according to the following rules**:
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Write a program to solve a Sudoku puzzle by filling the empty cells.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 55. Jump Game
|
||||
# [55. Jump Game](https://leetcode.com/problems/jump-game/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [66. Plus One](https://leetcode.com/problems/plus-one/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a **non-empty** array of digits representing a non-negative integer, plus one to the integer.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [74. Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Write an efficient algorithm that searches for a value in an *m* x *n* matrix. This matrix has the following properties:
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [81. Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [95. Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer *n*, generate all structurally unique **BST's** (binary search trees) that store values 1 ... *n*.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [105. Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given preorder and inorder traversal of a tree, construct the binary tree.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [106. Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given inorder and postorder traversal of a tree, construct the binary tree.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [128. Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a 2D board containing `'X'` and `'O'` (**the letter O**), capture all regions surrounded by `'X'`.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [136. Single Number](https://leetcode.com/problems/single-number/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a **non-empty** array of integers, every element appears *twice* except for one. Find that single one.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [137. Single Number II](https://leetcode.com/problems/single-number-ii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a **non-empty** array of integers, every element appears *three* times except for one, which appears exactly once. Find that single one.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an input string, reverse the string word by word.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [153. Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [154. Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [162. Find Peak Element](https://leetcode.com/problems/find-peak-element/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
A peak element is an element that is greater than its neighbors.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [169. Majority Element](https://leetcode.com/problems/majority-element/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an array of size n, find the majority element. The majority element is the element that appears **more than** `⌊ n/2 ⌋` times.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [172. Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer n, return the number of trailing zeroes in n!.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [174. Dungeon Game](https://leetcode.com/problems/dungeon-game/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
The demons had captured the princess (**P**) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (**K**) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [187. Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [190. Reverse Bits](https://leetcode.com/problems/reverse-bits/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Reverse bits of a given 32 bits unsigned integer.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [201. Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [204. Count Primes](https://leetcode.com/problems/count-primes/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Count the number of prime numbers less than a non-negative number, **n**.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [218. The Skyline Problem](https://leetcode.com/problems/the-skyline-problem/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are **given the locations and height of all the buildings** as shown on a cityscape photo (Figure A), write a program to **output the skyline** formed by these buildings collectively (Figure B).
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [223. Rectangle Area](https://leetcode.com/problems/rectangle-area/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Find the total area covered by two **rectilinear** rectangles in a **2D** plane.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [229. Majority Element II](https://leetcode.com/problems/majority-element-ii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer array of size n, find all elements that appear more than `⌊ n/3 ⌋` times.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [240. Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [260. Single Number III](https://leetcode.com/problems/single-number-iii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an array of numbers `nums`, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [268. Missing Number](https://leetcode.com/problems/missing-number/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an array containing n distinct numbers taken from `0, 1, 2, ..., n`, find the one that is missing from the array.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [275. H-Index II](https://leetcode.com/problems/h-index-ii/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an array of citations **sorted in ascending order** (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [303. Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query-immutable/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [307. Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query-mutable/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [315. Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
You are given an integer array nums and you have to return a new counts array. The counts array has the property where `counts[i]` is the number of smaller elements to the right of `nums[i]`.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [318. Maximum Product of Word Lengths](https://leetcode.com/problems/maximum-product-of-word-lengths/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a string array `words`, find the maximum value of `length(word[i]) * length(word[j])` where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [327. Count of Range Sum](https://leetcode.com/problems/count-of-range-sum/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer array `nums`, return the number of range sums that lie in `[lower, upper]` inclusive.Range sum `S(i, j)` is defined as the sum of the elements in `nums` between indices `i` and `j` (`i` ≤ `j`), inclusive.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [329. Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer matrix, find the length of the longest increasing path.
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# 337. House Robber III
|
||||
# [337. House Robber III](https://leetcode.com/problems/house-robber-iii/)
|
||||
|
||||
|
||||
|
||||
## 题目
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [354. Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
You have a number of envelopes with widths and heights given as a pair of integers `(w, h)`. One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [367. Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a positive integer num, write a function which returns True if num is a perfect square else False.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [371. Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Calculate the sum of two integers a and b, but you are **not allowed** to use the operator `+` and `-`.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [372. Super Pow](https://leetcode.com/problems/super-pow/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [373. Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
You are given two integer arrays **nums1** and **nums2** sorted in ascending order and an integer **k**.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [378. Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [385. Mini Parser](https://leetcode.com/problems/mini-parser/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a nested list of integers represented as a string, implement a parser to deserialize it.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [386. Lexicographical Numbers](https://leetcode.com/problems/lexicographical-numbers/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer n, return 1 - n in lexicographical order.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [387. First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [389. Find the Difference](https://leetcode.com/problems/find-the-difference/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given two strings **s** and **t** which consist of only lowercase letters.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
A character in UTF8 can be from **1 to 4 bytes** long, subjected to the following rules:
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [397. Integer Replacement](https://leetcode.com/problems/integer-replacement/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a positive integer n and you can do operations as follow:
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [399. Evaluate Division](https://leetcode.com/problems/evaluate-division/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Equations are given in the format `A / B = k`, where `A` and `B` are variables represented as strings, and `k` is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return `-1.0`.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [405. Convert a Number to Hexadecimal](https://leetcode.com/problems/convert-a-number-to-hexadecimal/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, [two’s complement](https://en.wikipedia.org/wiki/Two%27s_complement) method is used.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [409. Longest Palindrome](https://leetcode.com/problems/longest-palindrome/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [410. Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
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.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [421. Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a **non-empty** array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [436. Find Right Interval](https://leetcode.com/problems/find-right-interval/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on the "right" of i.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [441. Arranging Coins](https://leetcode.com/problems/arranging-coins/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [457. Circular Array Loop](https://leetcode.com/problems/circular-array-loop/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
You are given a **circular** array `nums` of positive and negative integers. If a number k at an index is positive, then move forward k steps. Conversely, if it's negative (-k), move backward k steps. Since the array is circular, you may assume that the last element's next element is the first element, and the first element's previous element is the last element.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [461. Hamming Distance](https://leetcode.com/problems/hamming-distance/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [463. Island Perimeter](https://leetcode.com/problems/island-perimeter/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [470. Implement Rand10() Using Rand7()](https://leetcode.com/problems/implement-rand10-using-rand7/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a function `rand7` which generates a uniform random integer in the range 1 to 7, write a function `rand10` which generates a uniform random integer in the range 1 to 10.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [474. Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [475. Heaters](https://leetcode.com/problems/heaters/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [476. Number Complement](https://leetcode.com/problems/number-complement/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [477. Total Hamming Distance](https://leetcode.com/problems/total-hamming-distance/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [483. Smallest Good Base](https://leetcode.com/problems/smallest-good-base/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
For an integer n, we call k>=2 a **good base** of n, if all digits of n base k are 1.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [491. Increasing Subsequences](https://leetcode.com/problems/increasing-subsequences/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [493. Reverse Pairs](https://leetcode.com/problems/reverse-pairs/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an array `nums`, we call `(i, j)` an **important reverse pair** if `i < j` and `nums[i] > 2*nums[j]`.
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# 494. Target Sum
|
||||
# [494. Target Sum](https://leetcode.com/problems/target-sum/)
|
||||
|
||||
|
||||
## 题目
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [497. Random Point in Non-overlapping Rectangles](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a list of **non-overlapping** axis-aligned rectangles `rects`, write a function `pick` which randomly and uniformily picks an **integer point** in the space covered by the rectangles.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [498. Diagonal Traverse](https://leetcode.com/problems/diagonal-traverse/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [500. Keyboard Row](https://leetcode.com/problems/keyboard-row/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a List of words, return the words that can be typed using letters of **alphabet** on only one row's of American keyboard like the image below.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [508. Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself). So what is the most frequent subtree sum value? If there is a tie, return all the values with the highest frequency in any order.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [509. Fibonacci Number](https://leetcode.com/problems/fibonacci-number/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is,
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [513. Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a binary tree, find the leftmost value in the last row of the tree.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [528. Random Pick with Weight](https://leetcode.com/problems/random-pick-with-weight/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an array `w` of positive integers, where `w[i]` describes the weight of index `i`, write a function `pickIndex` which randomly picks an index in proportion to its weight.
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# 529. Minesweeper
|
||||
# [529. Minesweeper](https://leetcode.com/problems/minesweeper/)
|
||||
|
||||
|
||||
|
||||
## 题目
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [541. Reverse String II](https://leetcode.com/problems/reverse-string-ii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and left the other as original.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [547. Friend Circles](https://leetcode.com/problems/friend-circles/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
There are **N** students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a **direct** friend of B, and B is a **direct**friend of C, then A is an **indirect** friend of C. And we defined a friend circle is a group of students who are direct or indirect friends.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [557. Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [563. Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a binary tree, return the tilt of the **whole tree**.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [572. Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given two non-empty binary trees **s** and **t**, check whether tree **t** has exactly the same structure and node values with a subtree of **s**. A subtree of **s** is a tree consists of a node in **s** and all of this node's descendants. The tree **s** could also be considered as a subtree of itself.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [575. Distribute Candies](https://leetcode.com/problems/distribute-candies/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given an integer array with **even** length, where different numbers in this array represent different **kinds** of candies. Each number means one candy of the corresponding kind. You need to distribute these candies **equally** in number to brother and sister. Return the maximum number of **kinds** of candies the sister could gain.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [594. Longest Harmonious Subsequence](https://leetcode.com/problems/longest-harmonious-subsequence/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
We define a harmounious array as an array where the difference between its maximum value and its minimum value is **exactly** 1.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [599. Minimum Index Sum of Two Lists](https://leetcode.com/problems/minimum-index-sum-of-two-lists/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [632. Smallest Range Covering Elements from K Lists](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
You have `k` lists of sorted integers in ascending order. Find the **smallest** range that includes at least one number from each of the `k` lists.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [633. Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a non-negative integer `c`, your task is to decide whether there're two integers `a` and `b` such that a^2 + b^2 = c.
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# 638. Shopping Offers
|
||||
# [638. Shopping Offers](https://leetcode.com/problems/shopping-offers/)
|
||||
|
||||
|
||||
|
||||
## 题目
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [645. Set Mismatch](https://leetcode.com/problems/set-mismatch/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
The set `S` originally contains numbers from 1 to `n`. But unfortunately, due to the data error, one of the numbers in the set got duplicated to **another** number in the set, which results in repetition of one number and loss of another number.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# [653. Two Sum IV - Input is a BST](https://leetcode.com/problems/two-sum-iv-input-is-a-bst/)
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [658. Find K Closest Elements](https://leetcode.com/problems/find-k-closest-elements/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a sorted array, two integers `k` and `x`, find the `k` closest elements to `x` in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always preferred.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# [662. Maximum Width of Binary Tree](https://leetcode.com/problems/maximum-width-of-binary-tree/)
|
||||
|
||||
|
||||
## 题目:
|
||||
## 题目
|
||||
|
||||
Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a **full binary tree**, but some nodes are null.
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user