leetcode/problems

problems

dz / leetcode / problems

Node Tree

Nodes

322_coin_change
content 322: Coin Change
children leetcode/references/optimization_problem (can be modeled as an optimization problem,using the "standard form"), leetcode/references/optimal_substructure (the coin change problem has an optimal substructure property), leetcode/python/lru_cache (used in top-down dynamic programming solution to avoid TLE), leetcode/references/bottom_up_top_down (DP solutions for top-down and bottoms-up), leetcode/references/recurrence_relation (Editorial: "the following recurrence relation holds")
parents leetcode/paradigms/dynamic_programming, leetcode/grind75
hyperlink https://leetcode.com/problems/coin-change

238_product_of_array_except_self
content 238: Product of array except self
children leetcode/references/prefix_sum (Left/right product sum solution reminds me of prefix sum tables)
parents leetcode/grind75
hyperlink https://leetcode.com/problems/product-of-array-except-self

155_min_stack
content 155: Min Stack
parents leetcode/grind75
hyperlink https://leetcode.com/problems/min-stack

89_validate_binary_search_tree
content 89: Validate Binary Search Tree
children leetcode/references/tree_traversal/in_order (one solution for validating BST is using in-order traversal), leetcode/data_structures/binary_search_tree
parents leetcode/grind75
hyperlink https://leetcode.com/problems/validate-binary-search-tree

200_number_of_islands
content LC 200: number of islands
children leetcode/paradigms/breadth_first_search, leetcode/references/disjoint_data_set (One of the esoteric solutions involves using a union find,disjoint data set)
parents leetcode/paradigms/depth_first_search, leetcode/grind75
hyperlink https://leetcode.com/problems/number-of-islands

994_rotting_oranges
content 994: number of islands
parents leetcode/paradigms/breadth_first_search
hyperlink https://leetcode.com/problems/rotting-oranges/description/

33_search_in_rotated_sorted_array
content 33: search in rotated sorted array
children leetcode/paradigms/binary_search
parents leetcode/grind75
hyperlink https://leetcode.com/problems/search-in-rotated-sorted-array

39_combination_sum
content 39: Combination sum
children leetcode/references/knapsack_problem (this problem initially reminded me of a knapsack problem,,except that this problem enumerating all possibilities,instead of finding an optimal one)
parents leetcode/paradigms/backtracking, leetcode/grind75
hyperlink https://leetcode.com/problems/combination-sum/

34_first_last_sorted_array
content 34: Find first and last element in sorted array
parents leetcode/paradigms/binary_search/upper_bound, leetcode/paradigms/binary_search
remarks "find a range" problem
hyperlink https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/

278_first_bad_version
content 278: First Bad Version
parents leetcode/paradigms/binary_search, leetcode/paradigms/binary_search/lower_bound
hyperlink https://leetcode.com/problems/first-bad-version

875_koko_eating_bananas
content 875: Koko eating bananas
parents leetcode/paradigms/binary_search, leetcode/paradigms/binary_search/lower_bound
hyperlink https://leetcode.com/problems/koko-eating-bananas

1011_capacity_ship_packages_d_days
content 1011: Capacity to ship packages within D days
parents leetcode/paradigms/binary_search/lower_bound
hyperlink https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/

1_two_sum
content 1: two-sum
parents leetcode/data_structures/hash_table, leetcode/grind75
hyperlink https://leetcode.com/problems/two-sum/

20_valid_parentheses
content 20: Valid Parentheses
parents leetcode/data_structures/stack, leetcode/grind75
hyperlink https://leetcode.com/problems/valid-parentheses/

21_merge_two_sorted_lists
content 21: Merge two sorted lists
parents leetcode/data_structures/linked_list, leetcode/grind75
hyperlink https://leetcode.com/problems/merge-two-sorted-lists/

121_best_time_to_sell_and_buy_stock
content 121: Best Time to Sell and Buy Stock
children leetcode/references/maximum_subarray_problem (reminds me of this problem), leetcode/references/kadanes (I thought of Kadane's while working through this, though,I'm not sure how related they are)
parents leetcode/grind75, leetcode/paradigms/greedy

125_valid_palindrome
content 125: valid palindrome
children python/docs/stdtypes/str/isnumeric (I used this initially because I didn't know about isalnum), python/docs/reference/expressions/lambda (used with map/filter in reverse approach), python/double_colon_reverse (trick used in reverse approach to do reversing. Not sure,why it didn't use reverse()), python/docs/stdtypes/str/lower (Converted to all lowercase to make string case-insensitive), python/docs/stdlib/filter (In reversed approach, filter is used to whittle down the,input string to only contain alphanumeric characters), python/docs/stdtypes/str/isalnum (used to detect if string is alphanumeric), python/docs/stdtypes/str/isalpha (I used this initially because I didn't know about isalnum), python/docs/stdlib/map (In reversed approach, map is used to converted characters,to be lowercase)
parents leetcode/paradigms/two_pointer, leetcode/grind75
hyperlink https://leetcode.com/problems/valid-palindrome

242_valid_anagram
content 242: valid anagram
children python/docs/stdlib/data_types/collections/counter (built-in counter() turns this problem into a one-liner solution)
parents leetcode/data_structures/hash_table, leetcode/grind75
hyperlink https://leetcode.com/problems/valid-anagram

704_binary_search
content 704: binary search
parents leetcode/paradigms/binary_search, leetcode/grind75
hyperlink https://leetcode.com/problems/binary-search/

235_lowest_common_ancestor_BST
content 235: Lowest Common Ancestor (LCA) of a Binary Search Tree
children leetcode/references/lowest_common_ancestor
parents leetcode/data_structures/binary_search_tree, leetcode/grind75

2034_stock_price_fluctuation
content 2034: Stock Price Fluctuation
hyperlink https://leetcode.com/problems/stock-price-fluctuation

635_design_log_storage_system
content 635: Design Log Storage System
hyperlink https://leetcode.com/problems/design-log-storage-system

110_balanced_binary_tree
content 110: balanced binary tree
parents leetcode/data_structures/binary_tree, leetcode/grind75
hyperlink https://leetcode.com/problems/balanced-binary-tree

141_linked_list_cycle
content 141: Linked List Cycle
children leetcode/references/floyds_algorithm (Elegant solution with O(n) time and O(1) space), python/docs/glossary/hashable ("Objects which are instances of user-defined classes are hashable by default". This would have been good to know while attempting to solve this problem.), python/docs/stdtypes/set (useful data structure in python for simple case)
parents leetcode/data_structures/linked_list, leetcode/grind75
hyperlink https://leetcode.com/problems/linked-list-cycle/

287_find_the_duplicate_number
content 287: Find the duplicate number
children leetcode/references/floyds_algorithm (one solution this problem uses a variant on floyd's algorithm)
parents leetcode/grind75
hyperlink https://leetcode.com/problems/find-the-duplicate-number/

232_implement_queue_using_stacks
content Implement Queue using stacks
parents leetcode/data_structures/stack, leetcode/data_structures/queue
hyperlink https://leetcode.com/problems/implement-queue-using-stacks

169_majority_element
content 169: Majority Element
children python/docs/stdtypes/generator (divide-and-conquer solution, made use of iterator generators in sum() object), leetcode/references/boyer_moore_majority_vote_algorithm (A way to solve in linear time with O(1) space)
parents leetcode/data_structures/hash_table, leetcode/grind75
remarks lots of weird solutions for this one, but hash map
hyperlink https://leetcode.com/problems/majority-element

67_add_binary
content 67: Add Binary
children python/docs/stdlib/int (int(a,2) will convert a base 2 represented string value a to number), python/docs/stdtypes/str/format (One-liner: "{0:b}".format(int(a, 2) + int(b, 2))), python/docs/stdtypes/str/zfill (in bit-by-bit manipulation problem, zfill is used to leftpad with 0s), python/docs/stdlib/bin (used by bitwise manipulation solution to convert number to binary string,at the end.)
parents leetcode/paradigms/bit_manipulation, leetcode/grind75
hyperlink https://leetcode.com/problems/add-binary/description/

137_single_number_2
content 137: Single number 2
parents leetcode/paradigms/bit_manipulation
hyperlink https://leetcode.com/problems/single-number-ii

260_single_number_3
content 260: single number 3
parents leetcode/paradigms/bit_manipulation
hyperlink https://leetcode.com/problems/single-number-iii

187_repeated_DNA_sequences
content 187: repeated DNA sequences
parents leetcode/paradigms/bit_manipulation
hyperlink https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array

318_max_product_word_lengths
content 318: Maximum product of word lengths
parents leetcode/paradigms/bit_manipulation
hyperlink https://leetcode.com/problems/maximum-product-of-word-lengths

543_diameter_of_binary_tree
content 543: Diameter of Binary Tree
children python/docs/reference/simple_statements/nonlocal (used in the editorial example, when a "global", declared inside,of a function, was used inside of nested function), leetcode/references/binary_tree/terminology/degree (Article refers to a leaf as any node having 1 degree,,including the root node if it has 1 degree or less)
parents leetcode/data_structures/binary_tree, leetcode/data_structures/binary_tree/depth_first_traversal
hyperlink https://leetcode.com/problems/diameter-of-binary-tree

876_middle_of_linked_list
content 876: Middle of Linked List
parents leetcode/references/floyds_algorithm, leetcode/data_structures/linked_list, leetcode/grind75
remarks Fast/slow pointer
hyperlink https://leetcode.com/problems/middle-of-the-linked-list

104_max_depth_binary_tree
content 104: maximum depth of binary tree
children leetcode/references/tail_call (an optimzed solution involves tail recursion and BFS,,where the tail call is the recursive function)
parents leetcode/data_structures/binary_tree, leetcode/grind75
hyperlink https://leetcode.com/problems/maximum-depth-of-binary-tree

217_contains_duplicate
content 217: Contains duplicate
children python/docs/stdtypes/set
parents leetcode/data_structures/hash_table
hyperlink https://leetcode.com/problems/contains-duplicate/

1768_merge_strings_alternately
content 1768: merge strings alternative
parents leetcode/paradigms/array_string, leetcode/leetcode75
hyperlink https://leetcode.com/problems/merge-strings-alternately

1071_GCD_of_strings
content 1071: greatest common divisor of strings
children python/docs/stdlib/re/sub (The C++ brute force solution uses string substitution, which,can be reproduced with re.sub()), python/docs/stdlib/math/gcd (there's this really proof-y math-y solution that is quite,short in python because it uses the built-in gcd() function), python/repeat_strings (Really helpful to use this operator in brute force solution to this problem)
parents leetcode/paradigms/array_string, leetcode/leetcode75
hyperlink https://leetcode.com/problems/greatest-common-divisor-of-strings

1431_kids_with_greatest_number_of_candies
content 1431: Kids with greatest number of candies
parents leetcode/leetcode75, leetcode/paradigms/array_string
hyperlink https://leetcode.com/problems/kids-with-the-greatest-number-of-candies

605_can_place_flowers
content 605: Can place flowers
parents leetcode/paradigms/array_string, leetcode/leetcode75
hyperlink https://leetcode.com/problems/can-place-flowers

345_reverse_vowels_stringa
content 345: reverse vowels of a string
parents leetcode/paradigms/two_pointer, leetcode/leetcode75
hyperlink https://leetcode.com/problems/reverse-vowels-of-a-string

151_reverse_words_in_a_string
content 151: Reverse words in a string
parents leetcode/leetcode75, leetcode/paradigms/array_string
hyperlink https://leetcode.com/problems/reverse-words-in-a-string

334_increasing_triplet_subseq
content 334: Increasing triplet subsequence
parents leetcode/leetcode75
hyperlink https://leetcode.com/problems/increasing-triplet-subsequence

443_string_compression
content 443: String Compression
parents leetcode/paradigms/array_string, leetcode/leetcode75
hyperlink https://leetcode.com/problems/string-compression/description

282_move_zeros
content 282: move zeros
parents leetcode/paradigms/two_pointer, leetcode/leetcode75
hyperlink https://leetcode.com/problems/move-zeroes

392_is_subsequence
content 392: is subsequence
parents leetcode/paradigms/two_pointer, leetcode/leetcode75
hyperlink https://leetcode.com/problems/is-subsequence

1679_max_number_of_ksum_pairs
content 1679: Max number of ksum pairs
parents leetcode/leetcode75, leetcode/paradigms/two_pointer
hyperlink https://leetcode.com/problems/max-number-of-k-sum-pairs

643_maximum_average_subarray
content 643: maximum average subarray
children leetcode/references/prefix_sum (editorial used a cumulative sum to solve this,,AKA prefix sum. It was a little strange.)
parents leetcode/paradigms/sliding_window, leetcode/leetcode75
hyperlink https://leetcode.com/problems/maximum-average-subarray-i

1456_max_vowels_in_substring
content 1456 max vowels in a substring of given length
children python/boolean_value_coercion (coercing bools to ints shaves some lines off code)
parents leetcode/paradigms/sliding_window, leetcode/leetcode75
hyperlink https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length

1004_max_consecutive_ones_iii
content 1001 Max consecutive ones iii
parents leetcode/paradigms/sliding_window
hyperlink https://leetcode.com/problems/max-consecutive-ones-iii

1493_longest_subarray_ones_deleting_elem
content 1493: Longest Subarray of Ones after deleting one element
parents leetcode/paradigms/sliding_window, leetcode/leetcode75
hyperlink https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element

1732_find_highest_altitude
content 1732: find highest altitude
parents leetcode/paradigms/prefix_sum, leetcode/leetcode75
hyperlink https://leetcode.com/problems/find-the-highest-altitude

724_pivot_index
content 724 Pivot Index
parents leetcode/paradigms/prefix_sum, leetcode/leetcode75
hyperlink https://leetcode.com/problems/find-pivot-index

2215_difference_two_arrays
content 2215: Find the difference of two arrays
children python/docs/stdtypes/set/intersection (Got familiar with intersection method for this problem), python/docs/stdtypes/set/difference
parents leetcode/data_structures/set, leetcode/leetcode75
hyperlink https://leetcode.com/problems/find-the-difference-of-two-arrays

1207_unique_number_of_occurrences
content 1207: unique number of occurrences
parents leetcode/data_structures/set, leetcode/data_structures/hash_table, leetcode/leetcode75
hyperlink https://leetcode.com/problems/unique-number-of-occurrences

1657_close_strings
content 1657: Determine if two strings are close
parents leetcode/data_structures/hash_table, leetcode/leetcode75
hyperlink https://leetcode.com/problems/determine-if-two-strings-are-close

2352_equal_row_column_pairs
content 2352: Equal row and column pairs
children python/docs/glossary/hashable (Tuples are hashable, which you can use to build up a counter map to solve this problem efficiently)
parents leetcode/data_structures/hash_table, leetcode/leetcode75
hyperlink https://leetcode.com/problems/equal-row-and-column-pairs