/PythonLeetcode

Python Leetcode questions

Primary LanguagePython

PythonLeetcode

Python Leetcode questions

No Description category Leetcode Link Solution Link
1 Find Minimum number of knoght moves to reach. (0,0) Backtracking LC 1197 minimum knight moves knights.py
2 sparse matrix multiplication Array LC 311 Sparse Matrix Multiplication sparse_multiplication.py
3 Design In-Memory File System Design LC 588 Design In-Memory File System filesystemdesign.py
4 Gase Station Greedy LC 134 Gase Station gaststaion.py
5 Maze BFS DFS LC 490 Maze maze.py
6 Spiral Matrix Array LC 54 Spiral Matrix spiral_matrix.py
7 Deisgn TicTacToe Design LC 348 Deisgn TicTacToe tictactoe.py
8 Restore IP addresses String, Backtracking LC 93 Restore IP addresses restore_ip_backtracking.py
9 reconstruct Itinerary Graph, Backtracking , DFS LC 332 Reconstruct Itinerary findItinerary.py
10 Sudoku Solver CSP, Backtracking , DFS LC 37 Sudoku solver sudoku_solver.py
11 Pacific Atlantic Water flow DFS MATRIX , BFS LC 417 Pacific Atlantic Water flow ocean_water_flow.py
12 Angle bw hands of clock Math, Ad hoc LC 1344 Angle between hours and minutes hands of clock angle_bw_hour_minutes.py
13 Longest Substring with At Most K Distinct Characters String, two pointer, HashMap LC 340. Longest Substring with At Most K Distinct Characters longest_repeating_k_distinct.py
13 Longest Palindromic SubString String, two pointer, DP LC 05. Longest Palindromic SubString longest_pallindromic_substring.py
14 Next Permutation Array, two pointer, Ad hoc, LC 31. Next Permutation next_permutation.py
15 Longest substring without repeating character Array, two pointer, String, HashMap LC 3. Longest substring without repeating character longest_nonrepeating_char_substring.py
16 Pallindromic Permutation Array, HashMap 266. Palindrome Permutation pallindromic_permutation.py
17 Pallindromic substring Array, String, DP , Two Pointer 647. palindromic substrings pallindromic_substring.py
18 Edit Distance String, DP 72 . Edit Distance lenenshitine_distance.py
19 Missing Positive Number Array, Binary Search, Math 1539 Missing Positive Number missing_positive_number.py
20 Search in 2d MAtrix Array, Binary Search 74 Search in 2d MAtrix search2dArray.py
21 Largest Rectangle in Histogram Stack, Devide and Conquer, 84 Largest Rectangle in Histogram largest_histogram.py
22 Maximal Area Rectangle Stack, DP 85 Maximal Area Rectangle maximal_area_rectangle.py
23 Open Lock Graph, String, BFS 752 Open Lock open_lock_bfs_string.py
24 Range Sum Query 2D - Immutable Array, prefixsum ,Matrix, cumulative sum 304. Range Sum Query 2D - Immutable range_sum_query_2d_matrix.py
25 Minimum Area Rectangle Geometry, sorting, HashMap , Math 939. Minimum Area Rectangle minimum_area_rectangle.py
26 Sliding Window Maximum Sliding Window, DEQUE 239. Sliding Window Maximum sliding_window_maximum.py
27 Maximum Area of Island Graph, BFS 695. Maximum Area of Island maximu_area_island.py
28 Maximum Consecutive ones Two Pointer, Array, sliding window 1004. Maximum Consecutive ones maximum_one_consecutive.py
29 Shortest Bridge Graph, BFS, DFS 934. Shortest Bridge bridge_between_island.py
30 3Sum Closest Array, Sorting, Two Pointer 16. 3Sum Closest 3sum_closest.py
31 Insert, Delete, Randomized O(1) Array, random, HashTable 380. Insert Delete GetRandom O(1) insert_delete_random_O_1.py
32 Insert, Delete, Randomized O(1) Duplicates allowed Array, random, HashTable, Multiset 381. Insert Delete GetRandom With duplicates O(1) insert_delete_random__with_duplicates_O_1.py
33 Copy Random Pointers LinkedList, Graph 138. Copy List with Random Pointer deep_copy_list.py
34 Continuous Subarray Sum Math, Array 523. Continuous Subarray Sum Continous_subarray_sum.py
35 MERGE accounts GRAPH, DFS, UNION FIND, CONNECTED COMPONENT 729. Account Merge merge_accounts.py
36 Range sum BST BST, Tree, InORder, Binary Search 938. Range sum BST bst_range_sum.py
37 Basic Calculator II Stack, String 227. Basic Calculator II basic_calculator_2.py
38 Basic Calculator Stack, String 224. Basic Calculator basic_calculator.py
39 Read 4 String 157. Read N Characters Given Read4 read.py
40 Read 4 Multiple Calls Buffer, OS 158. Read N Characters Given Read4 Multiple Calls reader4_multiple_Calls.py
41 Walls and Gates GRAPH, BFS 286. Walls and Gates walls_gates.py
42 Time BAsed Key Value pair Design, Binary Search, Array 981. Time Based Key-Value Store time_based_KV.py
43 Binary Search Tree Iterator Design, Binary Search TREE, 173. BST Iterator BST_iterator.py
44 Searilize and Deserialize binary search tree Serialize, Binary Search TREE, 449. Serialize and Deserialize BST searialize_deserialize_bst.py
45 Jump Game IV Graph, BFS, Bidirectional BFS 1345. Jump Game IV jump_game_4.py
46 Validate_BST Tree, BST 98 Validate Binary Search Tree validate_bst.py
47 Rotate Image Array, Matrix, 48 Rotate Image rotateImage.py
48 Kth Closest Element to Origin Heap 973 K Closest Points to Origin kth_closest_point_to_origin.py
49 Trapping Rain Water Array, Two Pointer, Prefix sum, suffix sum, right left sum 42. Trapping Rain Water traipping_rain_water.py
50 Word Search Backtracking, DFS, GRAPH 79. Word Search word_search.py
51 Word Search 2 Backtracking, DFS, GRAPH ,TRIE 212. Word Search II word_search_2.py
52 Trie Implementation TRIE 208. Implement Trie (Prefix Tree) trie.py
53 LCS of Two stirngs STRING, Dynamic Programming 1143. Longest Common Subsequence lcs.py
54 Longest consecutive sequences Array, Hashset 128. Longest Consecutive Sequence longest_consecutive_seq.py
55 Daily Temperature Stack 739. Daily Temperatures daily_temparature.py
56 return forest TREE, DFS 1110. Delete Nodes And Return Forest delete_and_Return_forest.py
57 reverse linkedlist in k groups LinkedList 25. Reverse Nodes in k-Group reverse_linked_list_kgroups.py
58 reverse linkedlist LinkedList 206. Reverse Linked List reverse_linked_list.py
59 reverse linkedlist II LinkedList 92. Reverse Linked List II reverse_linked_list_II.py
60 Merge Two Sorted Lists LinkedList 21. Merge Two Sorted Lists merge_sorted_linkedlist.py
61 Climbing Stairs Dynamic Programming 70. Climbing Stairs staircase.py
62 Min Cost Climbing Stairs Dynamic Programming 746. Min Cost Climbing Stairs min_cost_climibing_stairs.py
63 Lowest Common Ancestor of a Binary Tree Tree 236. Lowest Common Ancestor of a Binary Tree lca_binary_tree.py
64 Lowest Common Ancestor of a Binary Search Tree Tree 235. Lowest Common Ancestor of a Binary Search Tree lca_bst.py
65 House Robber Dynamic Programming 1D 198. House Robber house_robber_1d.py
66 House Robber 2 Dynamic Programming 1D 213. House Robber II house_robber_II_1d.py
67 Longest Pallindromic Substring Dynamic Programming 1D 5. Longest Palindromic Substring longest_pallindromic_substr.py
68 Decode Ways Dynamic Programming 1D 91. Decode Ways decode_ways.py
69 Coin Change Dynamic Programming 1D 322. Coin Change coin_change.py
70 Top K Frequent Elements Array 347. Top K frequent Element topk_frequent.py
71 Longest Repeating Character Replacement Array Hashing 424 Longest Repeating Character Replacement longest_repearing_Char_with_replancement.py
72 Kth Smallest Element in a BST Tree, BST 230. Kth Smallest Element in a BST kth_smallest_bst.py
73 Maximum sum subarray Array, Greedy 53. Maximum Subarray maximum_subarray_sum.py
74 Missing Number MATH, SET 268. Missing Number missing_positive.py
75 Counting Bits MATH, BIT 338. Counting Bits counting_bits.py
76 Combination sums DP 39. Combination Sum combinations_sum.py
77 Find Median from Data Stream Heap 295. Find Median from Data Stream find_meadian_from_stream.py
78 Valid Pallindrome String 125. Valid Palindrome valid_pallindrome.py
79 Valid Analgram String 242. Valid Anagram valid_anagram.py
80 Contains Duplicate HashMap 217. Contains Duplicate contains_duplicate.py
81 Two Sum Array 1. Two Sum two_sum.py
82 Binary Search Binary Search 704. Binary Search binary_search.py
83 Coin Change 2 Dynamic Programmin, Knapsack 518. Coin Change 2 coin_change2.py
84 Rotting Oranges Graph, BFS 994. Rotting Oranges rotting_orange.py
85 Happy Number Math, Hashset 202. Happy Number happy_number.py
86 Target Sum Math, DP 494. Target Sum target_sum.py
87 Group Anagrams Array Hashing 49. Group Anagrams group_anagram.py
88 Design Add and Search Words Data Structure Trie, HashMap 211. Design Add and Search Words Data Structure add_search.py
89 Minimum Window Substring Sliding Window, Hashing, String 76.Minimum Window Substring minimum_window_substring.py
90 Merge k Sorted Lists Linked List 23. Merge k Sorted Lists merge_k_sorted_list.py
91 Reorder List Linked List 143. Reorder List reorder_linkedList.py
92 Generate Parentheses Backtracking, Stack 22. Generate Parentheses generte_parenthesis.py
93 Search in Rotated Sorted Array Backtracking, Stack 33. Search in Rotated Sorted Array search_rotated_sorted_array.py
94 Koko Eating Bananas Binary Search 875. Koko Eating Banana koko_binary_search.py
95 Car Fleet stack 853. Car Fleet car_fleet.py
96 Valid Parenthesis stack 20. Valid Parentheses valid_parenthesis.py
97 Invert Binary Tree Tree 226. Invert Binary Tree invert_binary_tree.py
98 Number of Island Graph 200. Number of Island number_island.py
99 Unique Path Graph 62. Unique Path unique_path.py
100 Word Break DP 139. Word Break word_break.py
101 Insert Interval Intervals 57. Insert Interval insert_interval.py
102 Merge Interval Intervals 56. Merge Interval merge_interval.py
103 Remove Nth Node From End of List Intervals 19. Remove Nth Node From End of List remove_node_from_end_ofList.py
104 Construct Binary Tree from Preorder and Inorder Traversal Tree 105. Construct Binary Tree from Preorder and Inorder Traversal construct_binary_tree_inorder_preorder.py
105 Maximum Product Subarray DP 152. Maximum Product Subarray maximum_product_subarray.py
106 Longest Substring Without Repeating Characters DP 3. Longest Substring Without Repeating Characters longest_substirng_without_repeatiing_chars.py
107 Product of Array Except Self Array Hashing 238. Product of Array Except Self product_array_except_Self.py
108 LinkedList Cycle LinkedList 141 Linkedlist Cycle product_array_except_Self.py
109 Container With Most Water Two Pointer 11 Container With Most Water
110 Find Minimum in Rotated Sorted Array Binary Search 153. Find Minimum in Rotated Sorted Array. find_min_rotated_sorted_arr.py
111 Binary Tree Maximum Path Sum Binary Tree 124. Binary Tree Maximum Path Sum binary_tree_maximum_path_sum.py
112 LIS of Array DP, Binary Search 300. Longest Increasing Subsequences lis.py
113 Same Tree Tree 100. Same Tree sametree.py
114 Maximum Depth of the Tree Tree 104. Max Depth max_depth.py
115 3 Sum Array Hashing, Two Pointer 15. 3 Sum 3sum.py
116 Clone Graph Graph 133. Clone Graph clone_graph.py
117 Encode Decode String String 271. Encode and Decode Strings encode_decode_string.py
118 Subtree of Another Tree Tree 572. Subtree of Another Tree subtree_of_tree.py
119 Meeting Rooms Intervals 252 Meeting Rooms meetingrooms1.py
120 Graph Valid Tree Tree 261 Graph Valid Tree graph_valid_tree.py
121 Course Schedule Graph 207. Course Schedule course_scheduler.py
122 Best Time To Buy Stock Sliding Window 121. Best Time to Buy and Sell Stock best_time_tobuy_stock.py
123 55 Jump Game Greedy, DP 55 Jump Game jump_Game.py
124 Meeting Rooms II Intervals 253 Meeting Rooms meetingrooms_2.py
125 Non-overlapping Intervals Intervals 435. Non-overlapping Intervals non_overlapping_intervals.py
126 Number of Connected Components in an Undirected Graph Graph 323. Number of Connected Components in an Undirected Graph num_of_connected_components.py
127 Number of 1 Bits Bit Manipulation 191 . Number of 1 Bits countBits_1.py
128 Set Matrix Zero Math 73. Set Matrix Zeroes set_matrix_zero.py
129 Reverse Bit Bit Manipulation 190. Reverse Bits reverse_bits.py
130 Sum Of Two Integer Bit Manipulation 371 Sum Of Two Integer sum_of_two_integer.py
131 Alien Dictionary Graph, Topological Sorting 269. Alien Dictionary aliendictionary.py