Skip to content

Python implementation for leetcode problems

Fanziyang-v/leetcode

Repository files navigation

leetcode

Binary Tree

Problem Difficulty Solution
Add One Row to Tree Medium add_one_row.py
Average of Levels in Binary Tree Easy average_of_levels.py
Balanced Binary Tree Easy is_balanced.py
Binary Search Tree Iterator Medium bst_iterator.py
Binary Tree Inorder Traversal Easy inorder_traversal.py
Binary Tree Level Order Traversal Medium level_order.py
Binary Tree Postorder Traversal Easy postorder_traversal.py
Binary Tree Preorder Traversal Easy preorder_traversal.py
Binary Tree Right Side View Medium right_side_view.py
Construct Binary Tree from Inorder and Postorder Traversal Medium build_tree2.py
Construct Binary Tree from Preorder and Inorder Traversal Medium build_tree1.py
Construct Sorted Array to Binary Search Tree Medium sorted_array2BST.py
Convert Sorted List to Binary Search Tree Medium sorted_list2BST.py
Delete Node in a Binary Search Tree Medium delete_node.py
Find Largest Values in Each Tree Row Medium largest_values
Flatten Binary Tree To Linked List Medium flatten.py
Insert into a Binary Search Tree Medium insert_intoBST.py
Invert Binary Tree Easy invert_tree
Kth Smallest Element in a Binary Search Tree Medium kth_smallest.py
Lowest Common Ancestor of a Binary Tree Medium lowest_common_ancestor.py
Maximum Depth of Binary Tree Easy max_depth.py
Minimum Depth of Binary Tree Easy min_depth.py
Most Frequent Subtree Sum Medium find_frequent_tree_sum.py
Path Sum I Medium has_path_sum.py
Path Sum II Medium path_sum.py
Path Sum III Medium path_sum2.py
Recover Binary Search Tree Medium recover_tree.py
Same Tree Easy is_same_tree.py
Search in a Binary Search Tree Easy searchBST.py
Serialize and Deserialize Binary Tree Hard codec.py
Symmetric Tree Easy is_symmetric.py
Validate Binary Search Tree Medium is_validBST.py

Linked List

Problem Difficulty Solution
Convert a Binary Number in a Linked List to Integer Easy get_decimal_value.py
Delete the Middle Node of a Linked List Medium delete_middle.py
Design Circular Queue Medium circular_queue.py
Insert Greatest Common Divisors in Linked List Medium insert_greatest_common_divisors.py
Intersection of Two Linked Lists Easy get_intersection_node.py
Linked List Cycle Easy has_cycle.py
Linked List Cycle II Medium detect_cycle.py
LRU Cache Medium lru_cache.py
Merge K Sorted Lists Hard merge_k_lists.py
Merge Two Sorted Lists Easy merge_two_lists.py
Middle of Linked List Easy middle_node.py
Odd Even Linked List Medium odd_even_list.py
Palindrome Linked List Easy is_palindrome.py
Remove Elements Easy remove_elements.py
Remove Nth Node from End of List Medium remove_nth_from_end.py
Remove Duplicates from Sorted List Easy remove_duplicates.py
Remove Zero Sum Consecutive Nodes from Linked List Medium remove_zero_sum_sublists.py
Reverse Linked List Easy reverse_list.py
Remove Nodes in Even Length Groups Medium remove_even_length_groups.py
Sort List Medium sort_list.py
Split Linked List in Parts Medium split_list_to_parts.py
Next Greater Node in Linked List Medium next_larger_nodes.py

Priority Queue

Problem Difficulty Solution
Find Subsequence of Length K With the Largest Sum Easy max_subsequence.py
Kth Largest Element in an Array Medium find_kth_largest.py
Kth Largest Element in a Stream Easy kth_largest.py
The K Weakest Rows in a Matrix Easy k_weakest_row.py
Top K Frequent Words Medium top_k_frequent.py

Binary Search

Problem Difficulty Solution
Binary Search Easy search.py
Find First and Last Position of Element in Sorted Array Medium search_range.py
Search in Rotated Sorted Array I Medium search_rotated_array.py
Search in Rotated Sorted Array II Medium search_rotated_array2.py
Missing Number Easy find_missing_number.py

Sliding Window

Problem Difficulty Solution
Minimum Size Subarray Sum Medium min_sub_array_len.py
Sliding Window Maximum Hard max_sliding_window.py
Find the Power of K-Size Subarray I Medium results_array.py

Dynamic Programming

Problem Difficulty Solution
Coin Change Medium coin_change.py
Count Sorted Vowel Strings Medium count_vowel_strings.py
Decode Ways Medium num_decodings.py
Delete Operation for Two Strings Medium min_distance2.py
Edit Distance Medium min_distance.py
Fibonacci Number Easy fib.py
House Robber I Medium rob1.py
House Robber II Medium rob2.py
House Robber III Medium rob3.py
Integer Break Medium integer_break.py
Jump Game I Medium can_jump.py
Jump Game II Medium jump.py
Longest Increasing Subsequence Medium length_of_lis.py
Longest Palindrome Medium longest_palindrome.py
Maximal Squares Medium maximal_squares.py
Maximum Subarray Medium max_sub_array.py
Minimum Path Sum Medium min_path_sum.py
Minimum Total Medium minimum_total.py
Pascal's Triangle I Easy pasacals_triangle1.py
Pascal's Triangle II Easy pasacals_triangle2.py
Perfect Squares Medium num_sqaures.py
Ugly Number II Medium nth_ugly_number.py
Unique Paths I Medium unique_paths.py
Unique Paths II Medium unique_paths_with_obstacles.py
Wiggle Subsequence Medium wiggle_max_length.py

Combinatorics

Problem Difficulty Solution
Unique Paths Medium unique_paths.py
Count Numbers with Unique Digits Medium count_numbers_with_unique_digits.py

Backtrack

Problem Difficulty Solution
Beautiful Arrangement Medium count_arrangement.py
Combination Sum Medium combination_sum.py
Letter Combinations of a Phone Number Medium letter_combinations.py
N-Queens I Hard solve_n_queens1.py
N-Queens II Hard solve_n_queens2.py
Permutations Medium permute.py
Subset I Medium subset1.py
Subset II Medium subset2.py
Sudoku Solver Hard solve_sudoku.py

About

Python implementation for leetcode problems

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages