Documentation ¶
Index ¶
- func CanMeasureWater(x, y, z int) bool
- func CanPartition(nums []int) bool
- func ClimbStairs(n int) int
- func ClimbStairsDP(n int) int
- func CombinationSum(candidates []int, target int) [][]int
- func CombinationSumII(candidates []int, target int) [][]int
- func Combine(n, k int) [][]int
- func ContainsNearbyAlmostDuplicate(nums []int, k, t int) bool
- func ContainsNearbyDuplicate(nums []int, k int) bool
- func DeleteNode(node *ListNode)
- func FindSubstring(s string, words []string) []int
- func FourSum(nums []int, target int) [][]int
- func HasPathSum(root *TreeNode, sum int) bool
- func Int2Roman(num int) string
- func IntegerBreak(n int) int
- func InterSection(num1, num2 []int) []int
- func IsAnagram(s string, t string) bool
- func IsMatch(target, pattern string) bool
- func IsPowerOfTwo(n int) bool
- func IsSubtree1(s *TreeNode, t *TreeNode) bool
- func IsSymmetric(root *TreeNode) bool
- func IsValidParentheses(s string) bool
- func IsValidSudoku(board [][]int) bool
- func Knapsack01(w, v []int, c int) int
- func Knapsack01DP(w, v []int, c int) int
- func LadderLength(beginWord, endWord string, wordList []string) int
- func LenghtOfLISWithBin(nums []int) int
- func LengthOfLISDPReview(nums []int) int
- func LengthOfLISWithDP(nums []int) int
- func LengthOfLongestSubstring(s string) int
- func LengthOfLongestSubstringReview(s string) int
- func LengthOfLongestSubstringReview2(s string) int
- func LengthOfLongestSubstringTwoDistinct(s string) int
- func LetterCombinations(digits string) []string
- func LevelOrder(root *TreeNode) [][]int
- func LevelOrderBottom(root *TreeNode) [][]int
- func MaxArea(height []int) int
- func MaxDepth(root *TreeNode) int
- func MaxSubArrayDC(nums []int) int
- func MaxSubArrayDP(nums []int) int
- func MaxSubArrayGreedy(nums []int) int
- func MaximalSquare(matrix [][]byte) int
- func MaximalSquare2(matrix [][]byte) int
- func MinDepth(root *TreeNode) int
- func MinSubArrayLen(s int, nums []int) int
- func MinWindow(s, t string) string
- func MinimumTotal(triangle [][]int) int
- func MoveZeros(nums []int) []int
- func Multiply(num1, num2 string) string
- func MySqrt1(x int) int
- func NumSquares(n int) int
- func NumTreesViaCatalan(n int) int
- func NumTreesViaDP(n int) int
- func NumberIslands(grid [][]byte) int
- func Permute(nums []int) [][]int
- func PermuteUnique(nums []int) [][]int
- func PreorderTraversal(root *TreeNode) []int
- func PrintList(head *ListNode)
- func PrintTree(root *TreeNode)
- func RecordList(head *ListNode)
- func RestoreIpAddress(s string) []string
- func Rob(nums []int) int
- func SingleNumber(nums []int) int
- func SingleNumberII(nums []int) int
- func SingleNumberIII(nums []int) []int
- func SolveNQueens(n int) [][]string
- func SortColorReview(nums []int)
- func SortColors(nums []int)
- func SpiralOrder(matrix [][]int) []int
- func SuperEggDrop(k, n int) int
- func ThreeSum(nums []int) [][]int
- func TopKFrequent(nums []int, k int) []int
- func TopKFrequentHeap(nums []int, k int) []int
- func TopKFrequentHeapReview(nums []int, k int) []int
- func TwoSum(nums []int, target int) []int
- func TwoSumII(nums []int, target int) []int
- func WordSearch(board [][]byte, word string) bool
- type ListHeap
- type ListNode
- func BuildList(elements []int) *ListNode
- func MergeKLists(lists []*ListNode) *ListNode
- func NewListNode(val int) *ListNode
- func RemoveElements(head *ListNode, val int) *ListNode
- func RemoveNthFromEnd(head *ListNode, n int) *ListNode
- func ReverseBetween(head *ListNode, m, n int) *ListNode
- func ReverseLinkedListIter(head *ListNode) *ListNode
- func ReverseList(head *ListNode) *ListNode
- func RotateRight(head *ListNode, k int) *ListNode
- type NestedInteger
- type NestedIterator
- type Node
- type NodeHeap
- type Pair
- type PairHeap
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanMeasureWater ¶
1. 数学方法(贝祖定理) 贝祖定理:对应给定的正整数a, b, 方程a*x + b*y = c有解的充要条件为c是gcd(a,b)的整数倍
func CanPartition ¶
func CombinationSum ¶
func CombinationSumII ¶
func ContainsNearbyDuplicate ¶
func DeleteNode ¶
func DeleteNode(node *ListNode)
func HasPathSum ¶
func IntegerBreak ¶
func InterSection ¶
func IsPowerOfTwo ¶
func IsSymmetric ¶
func IsValidParentheses ¶
func IsValidSudoku ¶
func Knapsack01 ¶
func LadderLength ¶
func LengthOfLISDPReview ¶
func LengthOfLongestSubstringTwoDistinct ¶
TODO
func LetterCombinations ¶
func LevelOrder ¶
func LevelOrderBottom ¶
func MaxSubArrayDC ¶
1. Divide-and-Conquer 使用分治法解决问题的典型例子。分治法解决问题的模板:
a) 定义基本情况 b) 将问题分解为子问题并 递归 地解决它们 c) 合并子问题的解以获得原始问题的解
func MaximalSquare2 ¶
func MinSubArrayLen ¶
func MinimumTotal ¶
func MoveZeros ¶
思路:
- 最简单的解法 使用辅助空间,把非零元素copy到辅助空间。时间复杂度O(n),空间复杂度O(n)
- 在原数组中操作 使用辅助索引k,k指向第一个零元素,循环扫描数组nums,遇到非零元素和k交换位置
func NumSquares ¶
func NumberIslands ¶
func PermuteUnique ¶
func PreorderTraversal ¶
func RecordList ¶
func RecordList(head *ListNode)
func RestoreIpAddress ¶
func SingleNumber ¶
func SingleNumberII ¶
func SingleNumberIII ¶
260. Single Number III 给定一个整数数组 nums,其中恰好有两个元素只出现一次,其余所有元素均出现两次。 找出只出现一次的那两个元素。 方便描述,假设这两个元素为a,b
func SolveNQueens ¶
func SpiralOrder ¶
func TopKFrequentHeapReview ¶
func WordSearch ¶
Types ¶
type ListNode ¶
*
- Definition for singly-linked list.
- type ListNode struct {
- Val int
- Next *ListNode
- }
func MergeKLists ¶
func NewListNode ¶
func RemoveElements ¶
func RemoveNthFromEnd ¶
func ReverseBetween ¶
func ReverseLinkedListIter ¶
func ReverseList ¶
func RotateRight ¶
type NestedInteger ¶
type NestedInteger struct {
// contains filtered or unexported fields
}
++++++++++++++++++ TODO
func (*NestedInteger) Add ¶
func (ni *NestedInteger) Add(elem NestedInteger)
func (*NestedInteger) GetInteger ¶
func (ni *NestedInteger) GetInteger() int
func (*NestedInteger) IsInteger ¶
func (ni *NestedInteger) IsInteger() bool
type NestedIterator ¶
type NestedIterator struct {
// contains filtered or unexported fields
}
func Construct ¶
func Construct(nestedList []*NestedInteger) *NestedIterator
func (*NestedIterator) HasNext ¶
func (this *NestedIterator) HasNext() bool
func (*NestedIterator) Next ¶
func (this *NestedIterator) Next() int
type TreeNode ¶
Definition for a binary tree node.
func InvertTree ¶
func LowestCommonAncestor ¶
func LowestCommonAncestorII ¶
func NewTreeNode ¶
Source Files ¶
- 00_base.go
- 01_two_sum.go
- 02_add_two_number.go
- 03_lenth_longest_substring.go
- 101_symmetric_tree.go
- 102_level_order.go
- 104_max_depth.go
- 107_level_order_bottom.go
- 111_min_depth.go
- 112_has_path_sum.go
- 11_max_area.go
- 120_minimum_total.go
- 127_ladder_length.go
- 12_int_to_roman.go
- 136_single_number.go
- 137_single_number_ii.go
- 143_record_list.go
- 144_preorder_traversal.go
- 159_Length_of_longest_substring.go
- 15_three_sum.go
- 167_two_sum_ii.go
- 17_letter_combinations.go
- 18_four_sum.go
- 198_house_robber.go
- 19_remove_nth_from_end.go
- 200_number_of_islands.go
- 203_remove_elements.go
- 206_reverse_list.go
- 209_min_subarray_len.go
- 20_valid_parentheses.go
- 219_contains_nearby_duplicate.go
- 220_contains_nearby_almost_duplicate.go
- 221_maximal_square.go
- 226_invert_tree.go
- 231_is_power_of_two.go
- 235_lowest_common_ancestor.go
- 236_lowest_common_ancestor_ii.go
- 237_delete_node.go
- 23_merge_k_lists.go
- 242_is_anagram.go
- 260_single_number_iii.go
- 26_remove_duplicates.go
- 279_perfect_squares.go
- 27_remove_element.go
- 283_move_zeros.go
- 300_length_of_LIS.go
- 30_find_substring.go
- 341_nested_iterator.go
- 343_integer_break.go
- 347_top_k_frequent.go
- 349_intersection.go
- 365_can_measure_water.go
- 36_is_valid_sudoku.go
- 39_combination_sum.go
- 40_combination_sum_ii.go
- 416_partition_equal_subset_sum.go
- 43_multiply_strings.go
- 44_wildcard_matching.go
- 46_permute.go
- 47_permute_unique.go
- 51_n_queens.go
- 53_max_subarray.go
- 54_spiral_matrix.go
- 572_is_subtree.go
- 61_rotate_right.go
- 69_sqrt_x.go
- 70_climbing_stairs.go
- 75_sort_colors.go
- 76_min_window.go
- 77_combinations.go
- 79_word_search.go
- 80_remove_duplicates_ii.go
- 887_super_egg_drop.go
- 92_ReverseBetween.go
- 93_restore_ip_address.go
- 95_unique_binary_search_trees_ii.go
- 96_unique_binary_search_trees.go
- problem_0-1-backpack.go
Click to show internal directories.
Click to hide internal directories.