Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NeetCode 150 Java Solutions

Topic-wise Java solutions scaffold based on the NeetCode Top 150 list from this LeetCode Discuss post: https://leetcode.com/discuss/post/5808617/heres-the-list-of-neetcodes-top-150-ques-rydm/

Each topic lives under src/main/java. Topic and problem packages are numbered in source-list order while remaining Java-valid. Each problem starts with BruteForce.java; add additional approach classes when needed.

Example:

src/main/java/t01_array_and_hashing/
  p005_maximum_subarray/
    BruteForce.java
    KadanesAlgorithm.java

Build

Run:

mvn clean package

The Maven build compiles the Java files under src/main/java. Package names are Java-valid and include order prefixes, for example t01_array_and_hashing.p005_maximum_subarray.

If Maven cannot reach the configured artifact repository, use the network-free local build:

./scripts/build.sh

Progress

Topic Completed Total Progress
Array & Hashing 0 10 0%
Two Pointers 0 9 0%
Sliding Window 0 6 0%
Stack 0 9 0%
Binary Search 0 7 0%
Linked List 0 9 0%
Trees 0 10 0%
Tries 0 3 0%
Heap / Priority Queue 0 6 0%
Backtracking 0 6 0%
Graphs 0 11 0%
1-D Dynamic Programming 0 9 0%
2-D Dynamic Programming 0 8 0%
Greedy 0 10 0%
Intervals 0 5 0%
Math & Geometry 0 8 0%
Bit Manipulation 0 6 0%
Advanced Topics (Hard) 0 18 0%

Summary

Metric Count
Topic groups 18
Listed problem entries 150

Note: the source list intentionally repeats some problems across multiple topics. This repo preserves that topic-wise segregation.

All Entries

# Topic Problem Directory
1 Array & Hashing Two Sum t01_array_and_hashing/p001_two_sum
2 Array & Hashing Valid Anagram t01_array_and_hashing/p002_valid_anagram
3 Array & Hashing Contains Duplicate t01_array_and_hashing/p003_contains_duplicate
4 Array & Hashing Product of Array Except Self t01_array_and_hashing/p004_product_of_array_except_self
5 Array & Hashing Maximum Subarray t01_array_and_hashing/p005_maximum_subarray
6 Array & Hashing Maximum Product Subarray t01_array_and_hashing/p006_maximum_product_subarray
7 Array & Hashing Find Minimum in Rotated Sorted Array t01_array_and_hashing/p007_find_minimum_in_rotated_sorted_array
8 Array & Hashing Search in Rotated Sorted Array t01_array_and_hashing/p008_search_in_rotated_sorted_array
9 Array & Hashing 3Sum t01_array_and_hashing/p009_3sum
10 Array & Hashing Container With Most Water t01_array_and_hashing/p010_container_with_most_water
11 Two Pointers Valid Palindrome t02_two_pointers/p011_valid_palindrome
12 Two Pointers 3Sum t02_two_pointers/p012_3sum
13 Two Pointers Container With Most Water t02_two_pointers/p013_container_with_most_water
14 Two Pointers Trapping Rain Water t02_two_pointers/p014_trapping_rain_water
15 Two Pointers Best Time to Buy and Sell Stock t02_two_pointers/p015_best_time_to_buy_and_sell_stock
16 Two Pointers Longest Substring Without Repeating Characters t02_two_pointers/p016_longest_substring_without_repeating_characters
17 Two Pointers Palindromic Substrings t02_two_pointers/p017_palindromic_substrings
18 Two Pointers Longest Palindromic Substring t02_two_pointers/p018_longest_palindromic_substring
19 Two Pointers Find Median of Two Sorted Arrays t02_two_pointers/p019_median_of_two_sorted_arrays
20 Sliding Window Best Time to Buy and Sell Stock t03_sliding_window/p020_best_time_to_buy_and_sell_stock
21 Sliding Window Longest Substring Without Repeating Characters t03_sliding_window/p021_longest_substring_without_repeating_characters
22 Sliding Window Longest Repeating Character Replacement t03_sliding_window/p022_longest_repeating_character_replacement
23 Sliding Window Permutation in String t03_sliding_window/p023_permutation_in_string
24 Sliding Window Minimum Window Substring t03_sliding_window/p024_minimum_window_substring
25 Sliding Window Sliding Window Maximum t03_sliding_window/p025_sliding_window_maximum
26 Stack Valid Parentheses t04_stack/p026_valid_parentheses
27 Stack Min Stack t04_stack/p027_min_stack
28 Stack Generate Parentheses t04_stack/p028_generate_parentheses
29 Stack Daily Temperatures t04_stack/p029_daily_temperatures
30 Stack Evaluate Reverse Polish Notation t04_stack/p030_evaluate_reverse_polish_notation
31 Stack Largest Rectangle in Histogram t04_stack/p031_largest_rectangle_in_histogram
32 Stack Car Fleet t04_stack/p032_car_fleet
33 Stack Binary Search Tree Iterator t04_stack/p033_binary_search_tree_iterator
34 Stack Basic Calculator II t04_stack/p034_basic_calculator_ii
35 Binary Search Binary Search t05_binary_search/p035_binary_search
36 Binary Search Search 2D Matrix t05_binary_search/p036_search_a_2d_matrix
37 Binary Search Koko Eating Bananas t05_binary_search/p037_koko_eating_bananas
38 Binary Search Find Minimum in Rotated Sorted Array t05_binary_search/p038_find_minimum_in_rotated_sorted_array
39 Binary Search Search in Rotated Sorted Array t05_binary_search/p039_search_in_rotated_sorted_array
40 Binary Search Time Based Key-Value Store t05_binary_search/p040_time_based_key_value_store
41 Binary Search Median of Two Sorted Arrays t05_binary_search/p041_median_of_two_sorted_arrays
42 Linked List Reverse Linked List t06_linked_list/p042_reverse_linked_list
43 Linked List Merge Two Sorted Lists t06_linked_list/p043_merge_two_sorted_lists
44 Linked List Reorder List t06_linked_list/p044_reorder_list
45 Linked List Remove Nth Node From End of List t06_linked_list/p045_remove_nth_node_from_end_of_list
46 Linked List Copy List With Random Pointer t06_linked_list/p046_copy_list_with_random_pointer
47 Linked List Add Two Numbers t06_linked_list/p047_add_two_numbers
48 Linked List Linked List Cycle t06_linked_list/p048_linked_list_cycle
49 Linked List Intersection of Two Linked Lists t06_linked_list/p049_intersection_of_two_linked_lists
50 Linked List LRU Cache t06_linked_list/p050_lru_cache
51 Trees Maximum Depth of Binary Tree t07_trees/p051_maximum_depth_of_binary_tree
52 Trees Same Tree t07_trees/p052_same_tree
53 Trees Invert Binary Tree t07_trees/p053_invert_binary_tree
54 Trees Binary Tree Maximum Path Sum t07_trees/p054_binary_tree_maximum_path_sum
55 Trees Binary Tree Level Order Traversal t07_trees/p055_binary_tree_level_order_traversal
56 Trees Subtree of Another Tree t07_trees/p056_subtree_of_another_tree
57 Trees Construct Binary Tree from Preorder and Inorder Traversal t07_trees/p057_construct_binary_tree_from_preorder_and_inorder_traversal
58 Trees Validate Binary Search Tree t07_trees/p058_validate_binary_search_tree
59 Trees Kth Smallest Element in a BST t07_trees/p059_kth_smallest_element_in_a_bst
60 Trees Lowest Common Ancestor of a Binary Tree t07_trees/p060_lowest_common_ancestor_of_a_binary_tree
61 Tries Implement Trie (Prefix Tree) t08_tries/p061_implement_trie_prefix_tree
62 Tries Design Add and Search Words Data Structure t08_tries/p062_design_add_and_search_words_data_structure
63 Tries Word Search II t08_tries/p063_word_search_ii
64 Heap / Priority Queue Kth Largest Element in an Array t09_heap_priority_queue/p064_kth_largest_element_in_an_array
65 Heap / Priority Queue Task Scheduler t09_heap_priority_queue/p065_task_scheduler
66 Heap / Priority Queue Design Twitter t09_heap_priority_queue/p066_design_twitter
67 Heap / Priority Queue Find Median from Data Stream t09_heap_priority_queue/p067_find_median_from_data_stream
68 Heap / Priority Queue Merge K Sorted Lists t09_heap_priority_queue/p068_merge_k_sorted_lists
69 Heap / Priority Queue Top K Frequent Elements t09_heap_priority_queue/p069_top_k_frequent_elements
70 Backtracking Subsets t10_backtracking/p070_subsets
71 Backtracking Combination Sum t10_backtracking/p071_combination_sum
72 Backtracking Permutations t10_backtracking/p072_permutations
73 Backtracking Word Search t10_backtracking/p073_word_search
74 Backtracking Palindrome Partitioning t10_backtracking/p074_palindrome_partitioning
75 Backtracking N-Queens t10_backtracking/p075_n_queens
76 Graphs Number of Islands t11_graphs/p076_number_of_islands
77 Graphs Clone Graph t11_graphs/p077_clone_graph
78 Graphs Max Area of Island t11_graphs/p078_max_area_of_island
79 Graphs Pacific Atlantic Water Flow t11_graphs/p079_pacific_atlantic_water_flow
80 Graphs Surrounded Regions t11_graphs/p080_surrounded_regions
81 Graphs Rotting Oranges t11_graphs/p081_rotting_oranges
82 Graphs Course Schedule t11_graphs/p082_course_schedule
83 Graphs Course Schedule II t11_graphs/p083_course_schedule_ii
84 Graphs Alien Dictionary t11_graphs/p084_alien_dictionary
85 Graphs Graph Valid Tree t11_graphs/p085_graph_valid_tree
86 Graphs Number of Connected Components in an Undirected Graph t11_graphs/p086_number_of_connected_components_in_an_undirected_graph
87 1-D Dynamic Programming Climbing Stairs t12_1_d_dynamic_programming/p087_climbing_stairs
88 1-D Dynamic Programming House Robber t12_1_d_dynamic_programming/p088_house_robber
89 1-D Dynamic Programming House Robber II t12_1_d_dynamic_programming/p089_house_robber_ii
90 1-D Dynamic Programming Longest Palindromic Subsequence t12_1_d_dynamic_programming/p090_longest_palindromic_subsequence
91 1-D Dynamic Programming Palindromic Substrings t12_1_d_dynamic_programming/p091_palindromic_substrings
92 1-D Dynamic Programming Decode Ways t12_1_d_dynamic_programming/p092_decode_ways
93 1-D Dynamic Programming Coin Change t12_1_d_dynamic_programming/p093_coin_change
94 1-D Dynamic Programming Longest Increasing Subsequence t12_1_d_dynamic_programming/p094_longest_increasing_subsequence
95 1-D Dynamic Programming Partition Equal Subset Sum t12_1_d_dynamic_programming/p095_partition_equal_subset_sum
96 2-D Dynamic Programming Unique Paths t13_2_d_dynamic_programming/p096_unique_paths
97 2-D Dynamic Programming Longest Common Subsequence t13_2_d_dynamic_programming/p097_longest_common_subsequence
98 2-D Dynamic Programming Word Break t13_2_d_dynamic_programming/p098_word_break
99 2-D Dynamic Programming Combination Sum IV t13_2_d_dynamic_programming/p099_combination_sum_iv
100 2-D Dynamic Programming Minimum Path Sum t13_2_d_dynamic_programming/p100_minimum_path_sum
101 2-D Dynamic Programming Edit Distance t13_2_d_dynamic_programming/p101_edit_distance
102 2-D Dynamic Programming Maximal Square t13_2_d_dynamic_programming/p102_maximal_square
103 2-D Dynamic Programming Burst Balloons t13_2_d_dynamic_programming/p103_burst_balloons
104 Greedy Maximum Subarray t14_greedy/p104_maximum_subarray
105 Greedy Jump Game t14_greedy/p105_jump_game
106 Greedy Jump Game II t14_greedy/p106_jump_game_ii
107 Greedy Gas Station t14_greedy/p107_gas_station
108 Greedy Hand of Straights t14_greedy/p108_hand_of_straights
109 Greedy Merge Intervals t14_greedy/p109_merge_intervals
110 Greedy Insert Interval t14_greedy/p110_insert_interval
111 Greedy Non-overlapping Intervals t14_greedy/p111_non_overlapping_intervals
112 Greedy Meeting Rooms t14_greedy/p112_meeting_rooms
113 Greedy Meeting Rooms II t14_greedy/p113_meeting_rooms_ii
114 Intervals Merge Intervals t15_intervals/p114_merge_intervals
115 Intervals Insert Interval t15_intervals/p115_insert_interval
116 Intervals Non-overlapping Intervals t15_intervals/p116_non_overlapping_intervals
117 Intervals Meeting Rooms t15_intervals/p117_meeting_rooms
118 Intervals Meeting Rooms II t15_intervals/p118_meeting_rooms_ii
119 Math & Geometry Rotate Image t16_math_and_geometry/p119_rotate_image
120 Math & Geometry Spiral Matrix t16_math_and_geometry/p120_spiral_matrix
121 Math & Geometry Set Matrix Zeroes t16_math_and_geometry/p121_set_matrix_zeroes
122 Math & Geometry Happy Number t16_math_and_geometry/p122_happy_number
123 Math & Geometry Plus One t16_math_and_geometry/p123_plus_one
124 Math & Geometry Pow(x, n) t16_math_and_geometry/p124_powx_n
125 Math & Geometry Multiply Strings t16_math_and_geometry/p125_multiply_strings
126 Math & Geometry Rotate Array t16_math_and_geometry/p126_rotate_array
127 Bit Manipulation Single Number t17_bit_manipulation/p127_single_number
128 Bit Manipulation Number of 1 Bits t17_bit_manipulation/p128_number_of_1_bits
129 Bit Manipulation Counting Bits t17_bit_manipulation/p129_counting_bits
130 Bit Manipulation Reverse Bits t17_bit_manipulation/p130_reverse_bits
131 Bit Manipulation Missing Number t17_bit_manipulation/p131_missing_number
132 Bit Manipulation Sum of Two Integers t17_bit_manipulation/p132_sum_of_two_integers
133 Advanced Topics (Hard) Reverse Nodes in k-Group t18_advanced_topics_hard/p133_reverse_nodes_in_k_group
134 Advanced Topics (Hard) Median of Two Sorted Arrays t18_advanced_topics_hard/p134_median_of_two_sorted_arrays
135 Advanced Topics (Hard) Trapping Rain Water t18_advanced_topics_hard/p135_trapping_rain_water
136 Advanced Topics (Hard) Longest Valid Parentheses t18_advanced_topics_hard/p136_longest_valid_parentheses
137 Advanced Topics (Hard) Regular Expression Matching t18_advanced_topics_hard/p137_regular_expression_matching
138 Advanced Topics (Hard) Wildcard Matching t18_advanced_topics_hard/p138_wildcard_matching
139 Advanced Topics (Hard) Word Ladder t18_advanced_topics_hard/p139_word_ladder
140 Advanced Topics (Hard) Word Ladder II t18_advanced_topics_hard/p140_word_ladder_ii
141 Advanced Topics (Hard) Edit Distance t18_advanced_topics_hard/p141_edit_distance
142 Advanced Topics (Hard) Maximum Flow (Not on LeetCode) t18_advanced_topics_hard/p142_maximum_flow
143 Advanced Topics (Hard) Insert Interval t18_advanced_topics_hard/p143_insert_interval
144 Advanced Topics (Hard) Serialize and Deserialize Binary Tree t18_advanced_topics_hard/p144_serialize_and_deserialize_binary_tree
145 Advanced Topics (Hard) Alien Dictionary t18_advanced_topics_hard/p145_alien_dictionary
146 Advanced Topics (Hard) Palindrome Pairs t18_advanced_topics_hard/p146_palindrome_pairs
147 Advanced Topics (Hard) Maximal Rectangle t18_advanced_topics_hard/p147_maximal_rectangle
148 Advanced Topics (Hard) First Missing Positive t18_advanced_topics_hard/p148_first_missing_positive
149 Advanced Topics (Hard) Largest Rectangle in Histogram t18_advanced_topics_hard/p149_largest_rectangle_in_histogram
150 Advanced Topics (Hard) N-Queens II t18_advanced_topics_hard/p150_n_queens_ii

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages