|
| 1 | +# Go Solution for Leetcode algorithm problems |
| 2 | + |
| 3 | +[](https://travis-ci.org/zwfang/leetcode) |
| 4 | +[](https://codecov.io/gh/zwfang/leetcode) |
| 5 | +[](https://www.codacy.com/app/zwfang/leetcode?utm_source=github.com&utm_medium=referral&utm_content=zwfang/leetcode&utm_campaign=Badge_Grade) |
| 6 | +[](https://goreportcard.com/report/github.com/zwfang/leetcode) |
| 7 | + |
| 8 | +continually updating 😃. |
| 9 | + |
| 10 | +### [view by sorted](./src/README.md) |
| 11 | + |
| 12 | +### Array |
| 13 | +* [1. Two Sum](src/0001_two_sum/twosum.go) *`lookup table;`* *`hash table`* |
| 14 | +* [4. Median of Two Sorted Arrays](src/0004_median_of_two_sorted_arrays/motsa.go) *`binary search;`* *`divide and conquer`* |
| 15 | +* [11. Container With Most Water](src/0011_container_with_most_water/container_with_most_water.go) *`double index;`* *`array`* |
| 16 | +* [15. 3Sum](src/0015_3Sum/3sum.go) *`double index;`* *`array`* |
| 17 | +* [26. Remove Duplicates from Sorted Array](src/0026_remove_duplicates_from_sorted_array/rdfsa.go) *`double index;`* *`array`* |
| 18 | +* [27. Remove Element](src/0027_remove_element/remove_element.go) *`double index;`* *`array`* |
| 19 | +* [48. Rotate Image](src/0048_rotate_image/rotate_image.go) |
| 20 | +* [53. Maximum Subarray](src/0053_maximum_subarray/maximum_subarray.go) *`dynamic programming`* |
| 21 | +* [75. Sort Colors](src/0075_sort_colors/sort_colors.go) *`sort;`* *`array`* |
| 22 | +* [80. Remove Duplicates from Sorted Array II](src/0080_remove_duplicates_from_sorted_array2/rdfsa2.go) *`double index;`* *`array`* |
| 23 | +* [88. Merge Sorted Array](src/0088_merge_sorted_array/msa.go) *`sort;`* *`array`* |
| 24 | +* [121. Best Time to Buy and Sell Stock](src/0121_best_time_to_buy_and_sell_stock/maxprofit.go) *`dynamic programming;`* *`array`* |
| 25 | +* [122. Best Time to Buy and Sell Stock II](src/0122_best_time_to_buy_and_sell_stock_2/maxprofit.go) *`greedy;`* *`array`* |
| 26 | +* [136. Single Number](src/0136_single_number/single_number.go) *`hash table;`* *`bit manipulation`* |
| 27 | +* [167. Two Sum II - Input array is sorted](src/0167_two_sum2/two_sum2.go) *`double index;`* *`binary search`* |
| 28 | +* [179. Largest Number](src/0179_largest_number/ln.go) *`sort`* |
| 29 | +* [200. Number of Islands](src/0200_number_of_island/number_of_island.go) *`dfs;`* *`bfs`* |
| 30 | +* [209. Minimum Size Subarray Sum](src/0209_minimum_size_subarray_sum/minimum_size_subarray_sum.go) *`sliding window`* |
| 31 | +* [215. Kth Largest Element in an Array](src/0215_kth_largest_element_in_an_array/kthleiaa.go) *`sort`* |
| 32 | +* [217. Contains Duplicate](src/0217_contains_duplicate/contains_duplicate.go) *`map`* |
| 33 | +* [219. Contains Duplicate II](src/0219_contains_duplicate_2/contains_duplicate_2.go) *`map`* |
| 34 | +* [283. Move Zeroes(solution1)](src/0283_move_zeroes/move_zeroes.go) *`sliding window`* |
| 35 | +* [283. Move Zeroes(solution2)](src/0283_move_zeroes/move_zeroes2.go) *`sliding window`* |
| 36 | +* [303. Range Sum Query - Immutable](src/0303_range_sum_query/rsqim.go) |
| 37 | +* [347. Top K Frequent Elements](src/0347_top_k_frequent_elements/topkfe.go) *`hash table;`* *`heap`* |
| 38 | +* [349. Intersection of Two Arrays](src/0349_intersection_of_2_arrays/intersection_of_two_arrays.go) *`set`* |
| 39 | +* [350. Intersection of Two Arrays II](src/0350_intersection_of_two_arrays2/intersection_of_two_arrays2.go) *`hash table`* |
| 40 | +* [447. Number of Boomerangs](src/0447_number_of_boomerangs/number_of_boomerangs.go) *`hash table`* |
| 41 | +* [454. 4Sum II](src/0454_4sum2/4sum2.go) *`hash table`* |
| 42 | +* [674. Longest Continuous Increasing Subsequence](src/0674_longest_continuous_increasing_subsequence/lcis.go) |
| 43 | +* [713. Subarray Product Less Than K](src/0713_subarray_product_less_than_k/spltk.go) *`sliding window`* *`array`* |
| 44 | +* [717. 1-bit and 2-bit Characters](src/0717_1_bit_and_2_bit_characters/1bitand2bitc.go) |
| 45 | +* [747. Largest Number At Least Twice of Others](src/0747_largest_number_at_least_twice_of_others/largest_number_at_least_twice_of_others.go) |
| 46 | + |
| 47 | +### Stack |
| 48 | +* [155. Min Stack](src/0155_min_stack/min_stack.go) |
| 49 | +* [735. Asteroid Collision](src/0735_asteroid_collision/ac.go) |
| 50 | + |
| 51 | +### String |
| 52 | +* [3. Longest Substring Without Repeating Characters](src/0003_longest_substring_without_repeating_characters/longest_substring_without_repeating_characters.go) *`sliding window;`* *`hash table`* |
| 53 | +* [14. Longest Common Prefix](src/0014_longest_common_prefix/lcp.go) |
| 54 | +* [17. Letter Combinations of a Phone Number](src/0017_letter_combination_of_a_phone_number/letter_combination_of_phone_number.go) *`tree`* |
| 55 | +* [20. Valid Parentheses](src/0020_valid_parentheses/valid_parentheses.go) *`stack`* |
| 56 | +* [28. Implement strStr()](src/0028_implement_strstr/implement_strstr.go) *`double index`* |
| 57 | +* [58. Length of Last Word](src/0058_length_of_last_word/len_of_last_word.go) |
| 58 | +* [67. Add Binary](src/0067_add_binary/add_binary.go) *`brute force`* |
| 59 | +* [76. Minimum Window Substring](src/0076_minimum_window_substring/minimum_window_substring.go) *`sliding window`* |
| 60 | +* [125. Valid Palindrome](src/0125_valid_palindrome/valid_palindrome.go) *`string;`* *`double index`* |
| 61 | +* [165. Compare Version Numbers](src/0165_compare_version_numbers/compare_version_numbers.go) |
| 62 | +* [344. Reverse String](src/0344_reverse_string/reverse_string.go) *`string;`* *`double index`* |
| 63 | +* [345. Reverse Vowels of a String](src/0345_reverse_vowels_of_a_string/reverse_vowels.go) *`string;`* *`double index`* |
| 64 | +* [438. Find All Anagrams in a String](src/0438_all_anagrams_in_a_string/all_anagrams_in_a_string.go) *`sliding window`* |
| 65 | +* [557. Reverse Words in a String III](src/0557_reverse_words_in_a_string_3/reverse_words_in_a_string_3.go) |
| 66 | +* [1021. Remove Outermost Parentheses](src/1021_Remove_Outermost_Parentheses/remove_outmost_parentheses.go) *`stack`* |
| 67 | + |
| 68 | +### Linked List |
| 69 | +* [2. Add Two Numbers](src/0002_add_two_numbers/add_two_numbers.go) *`recursion;`* *`math`* |
| 70 | +* [19. Remove Nth Node From End of List](src/0019_remove_nth_node_from_end_of_list/remove_nth_node_from_end_of_list.go) *`two pointers`* |
| 71 | +* [21. Merge Two Sorted Lists](src/0021_merge_two_sorted_lists/mergeTwoLists.go) |
| 72 | +* [23. Merge k Sorted Lists](src/0023_merge_k_sorted_lists/mksl.go) *`heap`* |
| 73 | +* [24. Swap Nodes in Pairs](src/0024_swap_nodes_in_pairs/swap_nodes_in_pairs.go) |
| 74 | +* [25. Reverse Nodes in k-Group](src/0025_reverse_nodes_in_k_group/reverse_node_k_group.go) |
| 75 | +* [61. Rotate List](src/0061_rotate_list/rotate_list.go) |
| 76 | +* [82. Remove Duplicates from Sorted List II](src/0082_remove_duplicates_from_sorted_list_2/rdfsl.go) |
| 77 | +* [83. Remove Duplicates from Sorted List](src/0083_remove_duplicates_from_sorted_list/rdfsl.go) |
| 78 | +* [86. Partition List](src/0086_partition_list/partition_list.go) *`two pointers`* |
| 79 | +* [92. Reverse Linked List II](src/0092_reverse_linked_list_2/reverse_linked_list2.go) |
| 80 | +* [148. Sort List](src/148_Sort_List/sortlist.go) *`sort`* |
| 81 | +* [203. Remove Linked List Elements](src/0203_remove_linked_list_elements/remove_linked_list_elements.go) |
| 82 | +* [206. Reverse Linked List](src/0206_reverse_linked_list/reverse_linked_list.go) |
| 83 | +* [237. Delete Node in a Linked List](src/0237_delete_node_in_a_linked_list/dniall.go) |
| 84 | +* [328. Odd Even Linked List](src/0328_odd_even_linked_list/odd_even_linked_list.go) |
| 85 | + |
| 86 | +### Dynamic Programming |
| 87 | +* [62. Unique Paths](src/0062_unique_paths/unique_paths.go) *`array`* |
| 88 | +* [63. Unique Paths 2](src/0063_unique_paths_2/unique_paths2.go) *`array`* |
| 89 | +* [64. Minimum Path Sum](src/0064_minimum_path_sum/minimum_path_sum.go) *`array`* |
| 90 | +* [70. Climbing Stairs](src/0070_climbing_stairs/climbing_stairs.go) |
| 91 | +* [120. Triangle](src/0120_triangle/triangle.go) *`array`* |
| 92 | +* [198. House Robber](src/0198_house_robber/house_robber.go) |
| 93 | +* [300. Longest Increasing Subsequence](src/0300_longest_increasing_subsequence/lis.go) |
| 94 | +* [304. Range Sum Query 2D - Immutable](src/304_Range_Sum_Query_2D/rsq.go) |
| 95 | +* [343. Integer Break](src/0343_integer_break/integer_break.go) *`math`* |
| 96 | +* [376. Wiggle Subsequence](src/0376_wiggle_subsequence/wiggle_subsequence.go) *`greedy;`* *`dynamic programming`* |
| 97 | +* [416. Partition Equal Subset Sum](src/0416_partition_equal_subset_sum/partition_equal_subset_sum.go) *`0-1 knapsack problem`* |
| 98 | +* [435. Non-overlapping Intervals](src/0435_non_overlapping_intervals/dp_solution.go) *`greedy;`* *`dynamic programming`* *`0-1 knapsack problem`* |
| 99 | + |
| 100 | +### Greedy |
| 101 | +* [392. Is Subsequence](src/0392_is_subsequence/is_subsequence.go) |
| 102 | +* [435. Non-overlapping Intervals](src/0435_non_overlapping_intervals/greedy_solution.go) *`greedy;`* *`dynamic programming`* |
| 103 | +* [455. Assign Cookies](src/0455_assign_cookies/assign_cookies.go) |
| 104 | + |
| 105 | +### Backtracking |
| 106 | +* [77. Combinations](src/0077_combinations/combinations.go) *`combine`* |
| 107 | +* [79. Word Search](src/0079_word_search/word_search.go) *`array`* |
| 108 | + |
| 109 | +### Tree |
| 110 | +* [94. Binary Tree Inorder Traversal](src/0094_binary_tree_inorder_traversal/binary_tree_inorder_traversal.go) *`binary tree;`* *`stack`* |
| 111 | +* [100. Same Tree](src/0100_same_tree/same_tree.go) *`binary tree;`* *`dfs`* |
| 112 | +* [101. Symmetric Tree](src/0101_symmetric_tree/symmetric_tree.go) *`binary tree;`* *`dfs;`* *`bfs;`* |
| 113 | +* [102. Binary Tree Level Order Traversal](src/0102_binary_tree_level_order_traversal/binary_tree_level_order_traversal.go) *`binary tree;`* *`dfs`* |
| 114 | +* [104. Maximum Depth of Binary Tree](src/0104_maximun_depth_of_binary_tree/maxdobt.go) *`binary tree depth`* |
| 115 | +* [107. Binary Tree Level Order Traversal II](src/0107_binary_tree_level_order_traversal_2/binary_tree_level_order_traversal2.go) *`binary tree;`* *`bfs`* |
| 116 | +* [111. Minimum Depth of Binary Tree](src/0111_minimum_depth_of_binary_tree/minimum_depth_of_binary_tree.go) *`binary tree;`* *`dfs`* |
| 117 | +* [112. Path Sum](src/0112_path_sum/path_sum.go) *`binary tree;`* *`dfs`* |
| 118 | +* [144. Binary Tree Preorder Traversal](src/0144_binary_tree_preorder_traversal/binary_tree_preorder_traversal.go) *`binary tree;`* *`pre-order traversal`* |
| 119 | +* [208. Implement Trie (Prefix Tree)](src/0208_implement_trie_prefix_tree/impltrie.go) *`trie`* |
| 120 | +* [226. Invert Binary Tree](src/0226_invert_binary_tree/invert_binary_tree.go) *`binary tree`* |
| 121 | +* [211. Add and Search Word - Data structure design](src/0211_add_and_search_word/add_and_search_word.go) *`trie`* |
| 122 | +* [235. Lowest Common Ancestor of a Binary Search Tree](src/0235_lowest_common_ancestor_of_a_binary_search_tree/lcaoabst.go) *`binary tree`* |
| 123 | +* [236. Lowest Common Ancestor of a Binary Tree](src/0236_Lowest_Common_Ancestor_of_a_Binary_Tree/lca.go) *`binary tree`* |
| 124 | +* [257. Binary Tree Paths](src/0257_binary_tree_paths/binary_tree_paths.go) *`binary tree`* |
| 125 | +* [307. Range Sum Query - Mutable](src/0307_Range_Sum_Query_Mutable/range_sum_query_mut.go) *`segment tree`* |
| 126 | +* [404. Sum of Left Leaves](src/0404_sum_of_left_leaves/sum_of_left_leaves.go) *`binary tree`* |
| 127 | +* [437. Path Sum III](src/0437_path_sum_3/path_sum_3.go) *`binary tree`* |
| 128 | +* [677. Map Sum Pairs](src/0677_map_sum_pairs/map_sum_pairs.go) *`trie`* |
| 129 | +* [872. Leaf-Similar Trees](src/0872_leaf_similar_trees/leaf_similar_trees.go) *`binary tree`* |
| 130 | + |
| 131 | +### Binary Search |
| 132 | +* [33. Search in Rotated Sorted Array](src/0033_search_in_rotated_sorted_array/search_in_rotated_sorted_array.go) *`array;`* *`binary search`* |
| 133 | +* [34. Find First and Last Position of Element in Sorted Array](src/0034_find_first_and_last_position_of_element_in_sorted_array/find_first_and_last_position_of_element_in_sorted_array.go) *`array;`* *`binary search`* |
| 134 | +* [35. Search Insert Position](src/0035_search_insert_position/search_insert_position.go) *`array;`* *`binary search`* |
| 135 | +* [69. Sqrt(x)](src/0069_sqrtx/sqrtx.go) *`math;`* *`binary search`* |
| 136 | +* [153. Find Minimum in Rotated Sorted Array](src/0153_find_minimum_in_rotated_sorted_array/fmirsa.go) |
| 137 | +* [704. Binary Search](src/0704_binary_search/binary_search.go) |
| 138 | + |
| 139 | +### Math |
| 140 | +* [7. Reverse Integer](src/0007_reverse_integer/reverse_integer.go) |
| 141 | +* [9. Palindrome Number](src/0009_palindrome_number/palindrome_number.go) |
| 142 | +* [13. Roman to Integer](src/0013_roman_to_integer/roman_to_integer.go) *`string`* |
| 143 | +* [66. Plus One](src/0066_plus_one/plus_one.go) *`array`* |
| 144 | +* [150. Evaluate Reverse Polish Notation](src/0150_evaluate_reverse_polish_notation/evaluate_reverse_polish_notation.go) *`stack`* |
| 145 | +* [258. Add Digits](src/0258_add_digits/add_digits.go) |
0 commit comments