Skip to content
My solutions for all (~350) leetcode problems, including premium.
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
001_two_sum dir structure Feb 4, 2016
002_add_two_numbers
003_longest_substring_without_repeating_chars a few more Jan 5, 2016
004_median_of_2_sorted_arrays
005_longest_palindromic_substring
006_zigzag_conversion dir structure Feb 4, 2016
007_reverse_integer
008_string_to_integer
009_palindrome_number
010_regular_expression_matching
011_container_with_most_water
012_integer_to_roman
013_roman_to_integer
014_longest_common_prefix fix dir Feb 8, 2016
015_three_sum a few Feb 1, 2016
016_three_sum_closest
017_letter_combinations_of_phone_number fix dir Feb 8, 2016
018_four_sum a few Feb 1, 2016
019_remove_nth_node_from_end fix dir Feb 8, 2016
020_valid_parentheses
021_merge_2_sorted_lists fix dir Feb 8, 2016
022_generate_parentheses
023_merge_k_sorted_lists fix dir Feb 8, 2016
024_swap_nodes_in pairs
025_reverse_nodes_in_k_group
026_remove_duplicates_from_sorted_array
027_remove_element fix dir Feb 8, 2016
028_implement_strstr fix dir Feb 8, 2016
029_divide_2integers
030_substring_with_cancatenation_all_words a few Feb 1, 2016
031_next_permutation
032_longest_valid_parentheses
033_search_in_rotated_sorted_array Fix dirs Feb 11, 2016
034_search_for_a_range Fix dirs Feb 11, 2016
035_search_insert_position Fix dirs Feb 11, 2016
036_valid_sudoku Fix dirs Feb 11, 2016
037_sodoku_solver
038_count_and_say
039_combination_sum
040_combination_sum_ii 40 Jan 29, 2016
041_first_missing_positive Fix dirs Feb 11, 2016
042_trapping_rain_water Fix dirs Feb 11, 2016
043_multiply_strings Fix dirs Feb 11, 2016
044_wildcard_matching a few Feb 1, 2016
045_jump_game_ii Fix dirs Feb 11, 2016
046_permutations Fix dirs Feb 11, 2016
047_permutations_ii
048_rotate_image
049_group_anagrams OK May 9, 2016
050_pow_x_n
051_n_queens
052_n_queens_ii
053_maximum_subarray
054_spiral_matrix
055_jump_game fix dirs Feb 12, 2016
056_merge_intervals fix dirs Feb 12, 2016
057_insert_interval
058_length_of_last_word fix dirs Feb 12, 2016
059_spiral_matrix_ii 087 Jan 29, 2016
060_permutation_sequence fix dirs Feb 12, 2016
061_rotate_list fix dirs Feb 12, 2016
062_unique_paths fix dirs Feb 12, 2016
063_unique_paths_ii fix dirs Feb 12, 2016
064_minimum_path_sum
065_valid_number fix dirs Feb 12, 2016
066_plus_one
067_add_binary
068_text_justification
069_sqrt_x
070_climbing_stairs
071_simplify_path fix dirs Feb 14, 2016
072_edit_distance fix dirs Feb 14, 2016
073_set_matrix_zeros
074_search_2d_matrix fix dirs Feb 14, 2016
075_sort_colors fix dirs Feb 14, 2016
076_min_window_substring more Jan 11, 2016
077_combinations fix dirs Feb 14, 2016
078_subsets fix dirs Feb 14, 2016
079_word_search fix dirs Feb 14, 2016
080_reemove_duplicates_from_sorted_array_ii fix dirs Feb 14, 2016
081_search_in_rotated_sorted_array
082_remove_duplicates_from_sorted_list 082 Jan 8, 2016
083_remove_duplicates_from_sorted_list_ii fix dirs Feb 16, 2016
084_largest_rectangle_in_histogram OK May 9, 2016
085_maximal_rectangle
086_partition_list fix dirs Feb 16, 2016
087_scramble_string
088_merge_sorted_arry fix dirs Feb 16, 2016
089_gray_code
090_subsets_ii fix dirs Feb 16, 2016
091_decode_ways vfix dirs Feb 18, 2016
092_reversed_linked_list_ii
093_restore_ip_addresses
094_binary_tree_inorder vfix dirs Feb 18, 2016
095_unique_binary_search_trees_ii
096_unique_binary_search_trees vfix dirs Feb 18, 2016
097_interleaving_string vfix dirs Feb 18, 2016
098_validate_binary_search_tree vfix dirs Feb 18, 2016
099_recover_binary_search_tree vfix dirs Feb 18, 2016
100_same_tree
101_symmetric_tree fix dirs Feb 22, 2016
102_binary_tree_level_order_traversal
103_binary_tree_zigzag_level_order_traversal fix dirs Feb 22, 2016
104_max_depth_of_binary_tree
105_construct_bt_from_preorder_inorder
106_construct_bt_from_postorder_inorder fix dirs Feb 22, 2016
107_binary_tree_level_order_traversal_ii fix dirs Feb 22, 2016
108_sorted_array_to_bst
109_convert_sorted_list_to_BST fix dirs Feb 22, 2016
110_balanced_binary_treee
111_minimum_depth_of_bst
112_path_sum
113_path_sum_ii fix dirs Feb 24, 2016
114_flatten_binary_tree_to_linked_list
115_distinct_subsequences
116_populating_next_right_pointers_in_each_node
117_populating_next_right_pointers_in_each_node_ii fix dirs Feb 24, 2016
118_pascal_triangle
119_pascal_triangle_ii
120_triangle
121_best_time_to_buy_and_sell
122_best_time_to_buy_adn_sell_ii
124_binary_tree_max_path_sum
125_valid_palindrome
126_word_ladder_ii
127_word_ladder 1 more Jan 20, 2016
128_longest_consequetive_sequence
129_sum_root_to_leaf 132 Apr 30, 2016
130_surrounded_regions
131_palindrome_partitioning
132_palindrome_partitioning_ii 132 Apr 30, 2016
133_clone_graph 135 Apr 30, 2016
134_gas_station 135 Apr 30, 2016
135_candies 135 Apr 30, 2016
136_single_number 140 May 1, 2016
137_single_number_ii
138_copy_list_with_random_pointer
139_word_break
140_word_break_ii 145 May 1, 2016
141_linked_list_cycle 145 May 1, 2016
142_linked_list_cycle_ii 145 May 1, 2016
143_reorder_list 145 May 1, 2016
144_binary_tree_preorder_traversal 145 May 1, 2016
145_binary_tree_postorder_traversal 145 May 1, 2016
146_lru_cache 150 May 2, 2016
147_insertion_sort_list 150 May 2, 2016
148_sort_list 150 May 2, 2016
149_max_points_on_a_line
150_evaluate_reverse_polish 150 May 2, 2016
151_reverse_words_in_a_string
152_maximum_products_subarray 155 May 2, 2016
153_find_minimum_rotated_sorted_array
154_find_minimum_in_rotated_array_ii 155 May 2, 2016
155_min_stack 155 May 2, 2016
156_binary_tree_upside_down 156 Mar 29, 2016
157_read_n_chars
158_read_n_chars_ii 158 Apr 1, 2016
159_longest_substring_with_at_most_2_chars
160_intersection_of_linked_lists 166 May 3, 2016
161_one_edit_distance
162_peak_element
163_find_missing_ranges
164_maximum_gap
165_compare_version_numbers 166 May 3, 2016
166_fraction_to_recurring_decimal 166 May 3, 2016
167_two_sum_ii
168_excel_sheet 200 May 5, 2016
169_majority_element
170_two_sum_iii 170 Apr 2, 2016
171_excel_sheet_column_number 200 May 5, 2016
172_factorial_trailing_zeros 200 May 5, 2016
173_binary_tree_iterator
174_dungeon_game 200 May 5, 2016
179_largest_number
186_reverse_words_in_a_string 6 more Apr 6, 2016
187_repeated_dna OK May 9, 2016
188_best_time_to_buy_and_sell_iv
189_rotate_array 200 May 5, 2016
190_reverse_bits 200 May 5, 2016
191_number_of_i_bits 200 May 5, 2016
198_house_robber 200 May 5, 2016
199_binary_tree_right_view 200 May 5, 2016
200_islands
201_bitwise_and_of_number_range
202_happy_number
203_remove_linked_list_elements 279 May 8, 2016
204_count_primes
205_isomorphic_strings 279 May 8, 2016
206_reverse_linked_list OK May 9, 2016
207_course_schedule
208_implement_trie
209_minium_size_subarray_sum 279 May 8, 2016
210_course_schedule_ii
211_add_and_search_word 279 May 8, 2016
212_word_search_ii
213_house_robber_ii 279 May 8, 2016
215_kth_element_in_array 279 May 8, 2016
216_combination_sum_iii 279 May 8, 2016
217_contains_duplicate 279 May 8, 2016
218_skyline_problem
219_contains_duplicate_ii 279 May 8, 2016
220_contains_duplicate_iii
221_maximal_square 279 May 8, 2016
222_count_complete_tree_nodes 279 May 8, 2016
223_rectangle_area 279 May 8, 2016
224_basic_calculator
225_impl_stack_using_queues 279 May 8, 2016
226_invert_binary_tree
227_basic_calculator_ii
228_summary_ranges
229_majority_element_ii 279 May 8, 2016
230_kth_smallest_element 279 May 8, 2016
231_power_of_two
232_make_queue_using_stacks
233_number_of_digit_one 279 May 8, 2016
234_palindrome_linked_list
235_lowst_common_ancestor_bst 279 May 8, 2016
236_lowest_common_ancestor 279 May 8, 2016
237_delete_node_in_linked_list 279 May 8, 2016
238_product_array 279 May 8, 2016
239_sliding_window_maximum 279 May 8, 2016
240_search_2d_matrix 279 May 8, 2016
241_different_ways_to_add_parenthesis
242_valid_anagram
243_shortest_word_distance
244_shortest_word_distance_ii 6 more Apr 6, 2016
245_shortest_word_distance_iii
246_strobogrammatic_number 249 Apr 7, 2016
247_strobogrammatic_number_ii 6 more Apr 6, 2016
248_strobogrammatic_number_iii 249 Apr 7, 2016
249_group_shifted_strings 249 Apr 7, 2016
250_count_univalue_subtrees 251 Apr 8, 2016
251_flatten_2d_vector 251 Apr 8, 2016
252_meeting_rooms
253_meeting_room_ii
254_factor_combinations
255_verify_preorder_sequence
256_paint_house 270 Apr 11, 2016
257_binary_tree_paths 279 May 8, 2016
258_add_digits 279 May 8, 2016
259_threesum_smaller 340 Apr 21, 2016
260_single_number_iii OK May 9, 2016
261_graph_valid_tree
263_ugly_number
264_ugly_number_ii 279 May 8, 2016
265_paint_house_ii
266_palindrome_permutation 277 Apr 12, 2016
267_palindrome_permutation_ii
268_missing_number 279 May 8, 2016
269_alien_dictionary 339 Apr 17, 2016
270_closest_binary_search_tree_value 270 Apr 11, 2016
271_encode_and_decode_strings 277 Apr 12, 2016
272_closest_binary_search_tree_values 340 Apr 21, 2016
273_english_words 279 May 8, 2016
274_h_index 279 May 8, 2016
275_hindex_ii 279 May 8, 2016
276_paint_fence 339 Apr 17, 2016
277_find_the_celebrity
278_first_bad_version
279_perfect_square_numbers
280_wiggle_sort
281_zigzag_iterator
282_expression_add_operators
283_move_zeros
284_peeking_iterator OK May 9, 2016
285_inorder_successor_in_BST
286_walls_and_gates 330 Apr 16, 2016
287_finding_duplicate_number OK May 9, 2016
288_unique_word_abbrevation
289_game_of_life OK May 9, 2016
290_word_pattern
291_word_pattern_ii 293 Apr 15, 2016
292_nim_game
293_flip_game 293 Apr 15, 2016
294_flip_game_ii 330 Apr 16, 2016
295_find_median_from_data_stream 344 Apr 22, 2016
296_best_meeting_point 330 Apr 16, 2016
297_serialize_and_deserialize_binary_tree solve 4 more Dec 20, 2015
298_binary_tree_longest_sequence 330 Apr 16, 2016
299_bulls_and_cows
300_longest_increasing_subsequence 317 Apr 24, 2016
302_smallest_rectangle_enclosing_pixels 339 Apr 17, 2016
303_range_sum_query_imutable
304_range_sum_query_2d 317 Apr 24, 2016
305_number_of_islands_ii 344 Apr 22, 2016
306_additive_number 324 Apr 25, 2016
307_range_sum_query_mutable
309_best_time_to_buy_cooldown
310_minimum_height_trees
311_sparse_matrix_multiplication 339 Apr 17, 2016
312_burst_balloons
313_super_ugly_number 324 Apr 25, 2016
314_binary_tree_vertical_order_traversal 333 Apr 20, 2016
315_count_of_smaller_numbers 315 Jan 24, 2016
316_remove_duplicate_letters
317_shortest_distance_from_all_buildings
318_maximum_product_of_word_lengths a few more Jan 5, 2016
319_bulb_switcher
320_generalized_abbreviation
321_create_maximum_number 321 Jan 23, 2016
322_coin_change
323_number_of_connected_components 339 Apr 17, 2016
324_wiggle_sort_ii
325_maximum_size_subarray
326_power_of_three
327_count_of_range_sum
328_odd_even_linked_list
329_longest_increasing_path 3329 Jan 26, 2016
330_patching_array
332_reconstruct_itinerary OK May 9, 2016
333_largest_BST_subtree
335_self_crossing OK May 9, 2016
336_palindrome_pairs OK May 9, 2016
337_house_robber_iii OK May 9, 2016
338_counting_bits OK May 9, 2016
339_nested_list_weighted_sum 339 Apr 17, 2016
340_longest_substr_at_most_k_chars
341_flatten_nested_list_iterator
342_power_of_four 344 Apr 22, 2016
343_integer_break 344 Apr 22, 2016
344_reverse_string 344 Apr 22, 2016
345_reverse_vowels 345 Apr 23, 2016
347_top_k_frequent_elements
352_data_stream_disjoint_intervals
030_substr
331_verify_preorder_serialization
334-increasing_triplet_subsequences Create 334-increasing_triplet_subsequences Mar 14, 2016
README.md Create README.md Jul 25, 2015
customersNeverOrder.sql initial commit Jul 25, 2015
duplicateEmails.sql initial commit Jul 25, 2015
isomorphic_strings.pyc a few more Aug 10, 2015
secondHighestSalary.sql

README.md

leetcode-solutions

Repo for all leetcode problems that I have solved

  • algorithm problems are solved in python

Note not all scripts generate correct answers, some are just work-in-progress

You can’t perform that action at this time.