mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
chapter four add pre-next
This commit is contained in:
@ -180,7 +180,7 @@ func buildChapterTwo() {
|
||||
util.WriteFile(fmt.Sprintf("../website/content/ChapterTwo/%v.md", chapterTwoFileName[index]), res)
|
||||
count++
|
||||
}
|
||||
fmt.Println("write %v files successful", count)
|
||||
fmt.Printf("write %v files successful", count)
|
||||
}
|
||||
|
||||
func loadMetaData(filePath string) (map[int]m.TagList, error) {
|
||||
|
@ -47,4 +47,11 @@ func twoSum(nums []int, target int) []int {
|
||||
return nil
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0002.Add-Two-Numbers/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -75,4 +75,11 @@ func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
|
||||
return head.Next
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001.Two-Sum/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0003.Longest-Substring-Without-Repeating-Characters/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -122,3 +122,10 @@ func max(a int, b int) int {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0002.Add-Two-Numbers/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0004.Median-of-Two-Sorted-Arrays/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -96,3 +96,10 @@ func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0003.Longest-Substring-Without-Repeating-Characters/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0007.Reverse-Integer/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -53,3 +53,10 @@ func reverse7(x int) int {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0004.Median-of-Two-Sorted-Arrays/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0009.Palindrome-Number/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -66,4 +66,11 @@ func isPalindrome(x int) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0007.Reverse-Integer/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0011.Container-With-Most-Water/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -57,3 +57,10 @@ func maxArea(height []int) int {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0009.Palindrome-Number/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0013.Roman-to-Integer/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -129,4 +129,11 @@ func romanToInt(s string) int {
|
||||
return total
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0011.Container-With-Most-Water/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0015.3Sum/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -119,3 +119,10 @@ func threeSum1(nums []int) [][]int {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0013.Roman-to-Integer/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0016.3Sum-Closest/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -87,3 +87,10 @@ func abs(a int) int {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0015.3Sum/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0017.Letter-Combinations-of-a-Phone-Number/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -142,3 +142,10 @@ func letterFunc(res string, digits string) {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0016.3Sum-Closest/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0018.4Sum/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -95,3 +95,10 @@ func fourSum(nums []int, target int) [][]int {
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0017.Letter-Combinations-of-a-Phone-Number/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0019.Remove-Nth-Node-From-End-of-List/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -98,3 +98,10 @@ func removeNthFromEnd1(head *ListNode, n int) *ListNode {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0018.4Sum/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0020.Valid-Parentheses/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -94,3 +94,10 @@ func isValid(s string) bool {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0019.Remove-Nth-Node-From-End-of-List/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0021.Merge-Two-Sorted-Lists/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -51,3 +51,10 @@ func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0020.Valid-Parentheses/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0022.Generate-Parentheses/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -58,3 +58,10 @@ func findGenerateParenthesis(lindex, rindex int, str string, res *[]string) {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0021.Merge-Two-Sorted-Lists/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0023.Merge-k-Sorted-Lists/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -72,3 +72,10 @@ func mergeTwoLists1(l1 *ListNode, l2 *ListNode) *ListNode {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0022.Generate-Parentheses/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0024.Swap-Nodes-in-Pairs/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -69,3 +69,10 @@ func swapPairs(head *ListNode) *ListNode {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0023.Merge-k-Sorted-Lists/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0025.Reverse-Nodes-in-k-Group/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -72,3 +72,10 @@ func reverse(first *ListNode, last *ListNode) *ListNode {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0024.Swap-Nodes-in-Pairs/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0026.Remove-Duplicates-from-Sorted-Array/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -126,3 +126,10 @@ func removeElement1(nums []int, start, val int) int {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0025.Reverse-Nodes-in-k-Group/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0027.Remove-Element/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -89,3 +89,10 @@ func removeElement(nums []int, val int) int {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0026.Remove-Duplicates-from-Sorted-Array/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0028.Implement-strStr/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -84,3 +84,10 @@ func strStr1(haystack string, needle string) int {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0027.Remove-Element/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0029.Divide-Two-Integers/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -146,3 +146,10 @@ func divide1(divided int, divisor int) int {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0028.Implement-strStr/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0030.Substring-with-Concatenation-of-All-Words/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -96,3 +96,10 @@ func copyMap(s map[string]int) map[string]int {
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0029.Divide-Two-Integers/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0033.Search-in-Rotated-Sorted-Array/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -76,3 +76,10 @@ func search33(nums []int, target int) int {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0030.Substring-with-Concatenation-of-All-Words/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0034.Find-First-and-Last-Position-of-Element-in-Sorted-Array/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -119,3 +119,10 @@ func searchLastLessElement(nums []int, target int) int {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0033.Search-in-Rotated-Sorted-Array/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0035.Search-Insert-Position/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -63,3 +63,10 @@ func searchInsert(nums []int, target int) int {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0034.Find-First-and-Last-Position-of-Element-in-Sorted-Array/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0036.Valid-Sudoku/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -166,3 +166,10 @@ func isValidSudoku1(board [][]byte) bool {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0035.Search-Insert-Position/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0037.Sudoku-Solver/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -116,3 +116,10 @@ func checkSudoku(board *[][]byte, pos position, val int) bool {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0036.Valid-Sudoku/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0039.Combination-Sum/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -85,3 +85,10 @@ func findcombinationSum(nums []int, target, index int, c []int, res *[][]int) {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0037.Sudoku-Solver/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0040.Combination-Sum-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -87,3 +87,10 @@ func findcombinationSum2(nums []int, target, index int, c []int, res *[][]int) {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0039.Combination-Sum/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0041.First-Missing-Positive/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -64,3 +64,10 @@ func firstMissingPositive(nums []int) int {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0040.Combination-Sum-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0042.Trapping-Rain-Water/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -59,3 +59,10 @@ func trap(height []int) int {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0041.First-Missing-Positive/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0046.Permutations/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -64,3 +64,10 @@ func generatePermutation(nums []int, index int, p []int, res *[][]int, used *[]b
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0042.Trapping-Rain-Water/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0047.Permutations-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -68,3 +68,10 @@ func generatePermutation47(nums []int, index int, p []int, res *[][]int, used *[
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0046.Permutations/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0048.Rotate-Image/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -125,3 +125,10 @@ func rotate(matrix [][]int) {
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0047.Permutations-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0049.Group-Anagrams/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -70,3 +70,10 @@ func groupAnagrams(strs []string) [][]string {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0048.Rotate-Image/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0050.Powx-n/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -67,3 +67,10 @@ func myPow(x float64, n int) float64 {
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0049.Group-Anagrams/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0051.N-Queens/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -131,4 +131,11 @@ func generateBoard(n int, row *[]int) []string {
|
||||
// }
|
||||
// };
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0050.Powx-n/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0052.N-Queens-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -104,4 +104,11 @@ func putQueen52(n, index int, col, dia1, dia2 *[]bool, row *[]int, res *int) {
|
||||
// }
|
||||
// };
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0051.N-Queens/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0053.Maximum-Subarray/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -72,4 +72,11 @@ func maxSubArray1(nums []int) int {
|
||||
return maxSum
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0052.N-Queens-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0054.Spiral-Matrix/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -162,4 +162,11 @@ func spiralOrder2(matrix [][]int) []int {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0053.Maximum-Subarray/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0055.Jump-Game/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -55,4 +55,11 @@ func canJump(nums []int) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0054.Spiral-Matrix/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0056.Merge-Intervals/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -106,4 +106,11 @@ func quickSort(a []Interval, lo, hi int) {
|
||||
quickSort(a, p+1, hi)
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0055.Jump-Game/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0057.Insert-Interval/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -72,4 +72,11 @@ func insert(intervals []Interval, newInterval Interval) []Interval {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0056.Merge-Intervals/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0059.Spiral-Matrix-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -91,4 +91,11 @@ func generateMatrix(n int) [][]int {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0057.Insert-Interval/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0060.Permutation-Sequence/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -93,4 +93,11 @@ func findPermutation(n, index int, k *int, p []int, res *string, used *[]bool) {
|
||||
return
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0059.Spiral-Matrix-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0061.Rotate-List/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -78,4 +78,11 @@ func rotateRight(head *ListNode, k int) *ListNode {
|
||||
return res.Next
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0060.Permutation-Sequence/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0062.Unique-Paths/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -66,4 +66,11 @@ func uniquePaths(m int, n int) int {
|
||||
return dp[n-1][m-1]
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0061.Rotate-List/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0063.Unique-Paths-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -77,4 +77,11 @@ func uniquePathsWithObstacles(obstacleGrid [][]int) int {
|
||||
return dp[m-1][n-1]
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0062.Unique-Paths/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0064.Minimum-Path-Sum/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -90,4 +90,11 @@ func minPathSum1(grid [][]int) int {
|
||||
return dp[m-1][n-1]
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0063.Unique-Paths-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0066.Plus-One/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -60,4 +60,11 @@ func plusOne(digits []int) []int {
|
||||
return digits
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0064.Minimum-Path-Sum/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0067.Add-Binary/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -73,4 +73,11 @@ func addBinary(a string, b string) string {
|
||||
return strings.Join(res, "")
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0066.Plus-One/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0069.Sqrtx/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -88,4 +88,11 @@ func mySqrt1(x int) int {
|
||||
// return y;
|
||||
// }
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0067.Add-Binary/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0070.Climbing-Stairs/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -52,4 +52,11 @@ func climbStairs(n int) int {
|
||||
return dp[n]
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0069.Sqrtx/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0071.Simplify-Path/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -114,4 +114,11 @@ func simplifyPath1(path string) string {
|
||||
return filepath.Clean(path)
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0070.Climbing-Stairs/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0074.Search-a-2D-Matrix/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -69,4 +69,11 @@ func searchMatrix(matrix [][]int, target int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0071.Simplify-Path/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0075.Sort-Colors/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -69,4 +69,11 @@ func sortColors(nums []int) {
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0074.Search-a-2D-Matrix/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0076.Minimum-Window-Substring/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -74,3 +74,10 @@ func minWindow(s string, t string) string {
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0075.Sort-Colors/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0077.Combinations/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -57,4 +57,11 @@ func generateCombinations(n, k, start int, c []int, res *[][]int) {
|
||||
return
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0076.Minimum-Window-Substring/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0078.Subsets/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -102,4 +102,11 @@ func subsets2(nums []int) [][]int {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0077.Combinations/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0079.Word-Search/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -80,4 +80,11 @@ func searchWord(board [][]byte, visited [][]bool, word string, index, x, y int)
|
||||
return false
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0078.Subsets/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0080.Remove-Duplicates-from-Sorted-Array-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -102,4 +102,11 @@ func removeDuplicates80(nums []int) int {
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0079.Word-Search/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0081.Search-in-Rotated-Sorted-Array-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -82,4 +82,11 @@ func search(nums []int, target int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0080.Remove-Duplicates-from-Sorted-Array-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0082.Remove-Duplicates-from-Sorted-List-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -188,4 +188,11 @@ func deleteDuplicates4(head *ListNode) *ListNode {
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0081.Search-in-Rotated-Sorted-Array-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0083.Remove-Duplicates-from-Sorted-List/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -63,4 +63,11 @@ func deleteDuplicates(head *ListNode) *ListNode {
|
||||
return head
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0082.Remove-Duplicates-from-Sorted-List-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0084.Largest-Rectangle-in-Histogram/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -72,4 +72,11 @@ func largestRectangleArea(heights []int) int {
|
||||
return maxArea
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0083.Remove-Duplicates-from-Sorted-List/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0086.Partition-List/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -145,4 +145,11 @@ func genListNode(head *DoublyListNode) *ListNode {
|
||||
return LNHead
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0084.Largest-Rectangle-in-Histogram/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0088.Merge-Sorted-Array/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -66,4 +66,11 @@ func merge(nums1 []int, m int, nums2 []int, n int) {
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0086.Partition-List/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0089.Gray-Code/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -114,4 +114,11 @@ func grayCode1(n int) []int {
|
||||
return out
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0088.Merge-Sorted-Array/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0090.Subsets-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -73,4 +73,11 @@ func generateSubsetsWithDup(nums []int, k, start int, c []int, res *[][]int) {
|
||||
return
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0089.Gray-Code/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0091.Decode-Ways/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -79,4 +79,11 @@ func numDecodings(s string) int {
|
||||
return dp[len(s)]
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0090.Subsets-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0092.Reverse-Linked-List-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -62,4 +62,11 @@ func reverseBetween(head *ListNode, m int, n int) *ListNode {
|
||||
return newHead.Next
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0091.Decode-Ways/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0093.Restore-IP-Addresses/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -75,4 +75,11 @@ func getString(ip []int) string {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0092.Reverse-Linked-List-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0094.Binary-Tree-Inorder-Traversal/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -70,4 +70,11 @@ func inorder(root *TreeNode, output *[]int) {
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0093.Restore-IP-Addresses/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0095.Unique-Binary-Search-Trees-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -75,4 +75,11 @@ func generateBSTree(start, end int) []*TreeNode {
|
||||
return tree
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0094.Binary-Tree-Inorder-Traversal/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0096.Unique-Binary-Search-Trees/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -50,4 +50,11 @@ func numTrees(n int) int {
|
||||
return dp[n]
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0095.Unique-Binary-Search-Trees-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0098.Validate-Binary-Search-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -96,4 +96,11 @@ func inOrder(root *TreeNode, arr *[]int) {
|
||||
inOrder(root.Right, arr)
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0096.Unique-Binary-Search-Trees/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0099.Recover-Binary-Search-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -98,4 +98,11 @@ func inOrderTraverse(root, prev, target1, target2 *TreeNode) (*TreeNode, *TreeNo
|
||||
return prev, target1, target2
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0098.Validate-Binary-Search-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0100.Same-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -89,4 +89,11 @@ func isSameTree(p *TreeNode, q *TreeNode) bool {
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0099.Recover-Binary-Search-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0101.Symmetric-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -68,4 +68,11 @@ func isSymmetric(root *TreeNode) bool {
|
||||
return isSameTree(invertTree(root.Left), root.Right)
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0100.Same-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0102.Binary-Tree-Level-Order-Traversal/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -112,4 +112,11 @@ func dfsLevel(node *TreeNode, level int, res *[][]int) {
|
||||
dfsLevel(node.Right, currLevel, res)
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0101.Symmetric-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0103.Binary-Tree-Zigzag-Level-Order-Traversal/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -123,4 +123,11 @@ func search(root *TreeNode, depth int, res *[][]int) {
|
||||
search(root.Right, depth+1, res)
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0102.Binary-Tree-Level-Order-Traversal/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0104.Maximum-Depth-of-Binary-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -57,4 +57,11 @@ func maxDepth(root *TreeNode) int {
|
||||
return max(maxDepth(root.Left), maxDepth(root.Right)) + 1
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0103.Binary-Tree-Zigzag-Level-Order-Traversal/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -70,4 +70,11 @@ func buildPreIn2TreeDFS(pre []int, preStart int, preEnd int, inStart int, inPos
|
||||
return root
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0104.Maximum-Depth-of-Binary-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -68,4 +68,11 @@ func buildInPos2TreeDFS(post []int, postStart int, postEnd int, inStart int, inP
|
||||
return root
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0107.Binary-Tree-Level-Order-Traversal-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -67,4 +67,11 @@ func levelOrderBottom(root *TreeNode) [][]int {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0106.Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0108.Convert-Sorted-Array-to-Binary-Search-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -49,4 +49,11 @@ func sortedArrayToBST(nums []int) *TreeNode {
|
||||
return &TreeNode{Val: nums[len(nums)/2], Left: sortedArrayToBST(nums[:len(nums)/2]), Right: sortedArrayToBST(nums[len(nums)/2+1:])}
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0107.Binary-Tree-Level-Order-Traversal-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0109.Convert-Sorted-List-to-Binary-Search-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -94,4 +94,11 @@ func middleNodeAndPreNode(head *ListNode) (middle *ListNode, pre *ListNode) {
|
||||
return p1, pre
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0108.Convert-Sorted-Array-to-Binary-Search-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0110.Balanced-Binary-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -87,4 +87,11 @@ func depth(root *TreeNode) int {
|
||||
return max(depth(root.Left), depth(root.Right)) + 1
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0109.Convert-Sorted-List-to-Binary-Search-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0111.Minimum-Depth-of-Binary-Tree/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -59,4 +59,11 @@ func minDepth(root *TreeNode) int {
|
||||
return min(minDepth(root.Left), minDepth(root.Right)) + 1
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0110.Balanced-Binary-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0112.Path-Sum/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -56,4 +56,11 @@ func hasPathSum(root *TreeNode, sum int) bool {
|
||||
return hasPathSum(root.Left, sum-root.Val) || hasPathSum(root.Right, sum-root.Val)
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0111.Minimum-Depth-of-Binary-Tree/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0113.Path-Sum-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -105,4 +105,11 @@ func pathSum1(root *TreeNode, sum int) [][]int {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0112.Path-Sum/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0114.Flatten-Binary-Tree-to-Linked-List/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -188,4 +188,11 @@ func flatten2(root *TreeNode) {
|
||||
root.Left = nil
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0113.Path-Sum-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0118.Pascals-Triangle/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -58,3 +58,10 @@ func generate(numRows int) [][]int {
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0114.Flatten-Binary-Tree-to-Linked-List/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0120.Triangle/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -86,4 +86,11 @@ func minimumTotal1(triangle [][]int) int {
|
||||
return minNum
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0118.Pascals-Triangle/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0121.Best-Time-to-Buy-and-Sell-Stock/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -79,4 +79,11 @@ func maxProfit1(prices []int) int {
|
||||
return res
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0120.Triangle/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0122.Best-Time-to-Buy-and-Sell-Stock-II/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -57,4 +57,11 @@ func maxProfit122(prices []int) int {
|
||||
return profit
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0121.Best-Time-to-Buy-and-Sell-Stock/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0124.Binary-Tree-Maximum-Path-Sum/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
@ -77,4 +77,11 @@ func getPathSum(root *TreeNode, maxSum *int) int {
|
||||
return currMax
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
<div style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0122.Best-Time-to-Buy-and-Sell-Stock-II/">⬅️上一页</a></p>
|
||||
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0125.Valid-Palindrome/">下一页➡️</a></p>
|
||||
</div>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user