Skip to content

simonyang0608/LeetCode

Repository files navigation

LeetCode

Fundamental

Algorithms / Datastructures # Title Method Time-Complexity Spatial-Complexity Difficulty Languages Link
Linked_List 138 Copy_List_with_Random_Pointer Recursion O(2 * N) O(k * N) Medium Python Copy_List_with_Random_Pointer_Python
C++ Copy_List_with_Random_Pointer_C++
143 Reorder_List Two-pointers O((k*N) // 2) O(1) Medium Python Reorder_List_Python
C++ Reorder_List_C++
148 Sort_List Merge-sort O(N * Log(N)) O(K * Log(N)) Medium Python Sort_List_Python
C++ Sort_List_C++
160 Intersection_of_Two_Linked_Lists In-place pointers ~ O(N) O(1) Easy Python Intersection_of_Two_Linked_Lists_Python
C++ Intersection_of_Two_Linked_Lists_C++
206 Reverse_Linked_List In-place pointers O(N) O(1) Easy Python Reverse_Linked_List_Python
C++ Reverse_Linked_List_C++
234 Palindrome_Linked_List Two-pointers O((k*N) // 2) O(1) Easy Python Palindrome_Linked_List_Python
C++ Palindrome_Linked_List_C++
430 Flatten_a_Multilevel_Doubly_Linked_List DFS ~ O(2 * N) O(N) Medium Python Flatten_a_Multilevel_Doubly_Linked_List_Python
C++ Flatten_a_Multilevel_Doubly_Linked_List_C++
445 Add_Two_Numbers_II In-place pointers O(4 * N) O(3 * N) Medium Python Add_Two_Numbers_II_Python
C++ Add_Two_Numbers_II_C++
707 Design_Linked_List In-place pointers ~ O(N) ~ O(1) Medium Python Design_Linked_List_Python
C++ Design_Linked_List_C++
725 Split_Linked_List_in_Parts In-place pointers O(2 * N) O(K) Medium Python Split_Linked_List_in_Parts_Python
C++ Split_Linked_List_in_Parts_C++
817 Linked_List_Components Hashmap O(N + K) O(K) Medium Python Linked_List_Components_Python
C++ Linked_List_Components_C++
876 Middle_of_the_Linked_List In-place pointers O(N // 2) O(N // 2) Easy Python Middle_of_the_Linked_List_Python
C++ Middle_of_the_Linked_List_C++
1019 Next_Greater_Node_In_Linked_List Stack O(N * K) ~ O(2 * N) Medium Python Next_Greater_Node_In_Linked_List_Python
C++ Next_Greater_Node_In_Linked_List_C++
1171 Remove_Zero_Sum_Consecutive_Nodes_from_Linked_List In-place pointer O(2 * N) O(2 * N) Medium Python Remove_Zero_Sum_Consecutive_Nodes_from_Linked_List_Python
C++ Remove_Zero_Sum_Consecutive_Nodes_from_Linked_List_C++
1206 Design_Skiplist Hashmap O(N * Log(N)) O(N) Hard Python Design_Skiplist_Python
C++ Design_Skiplist_C++
1669 Merge_In_Between_Linked_Lists In-place pointers O(K + N) O(K + N) Medium Python Merge_In_Between_Linked_Lists_Python
C++ Merge_In_Between_Linked_Lists_C++
1721 Swapping_Nodes_in_a_Linked_List Sliding-window O(N) ~ O(N) Medium Python Swapping_Nodes_in_a_Linked_List_Python
C++ Swapping_Nodes_in_a_Linked_List_C++
2058 Find_the_Minimum_and_Maximum_Number_of_Nodes_Between_Critical_Points Greedy O(N) O(N) Medium Python Find_the_Minimum_and_Maximum_Number_of_Nodes_Between_Critical_Points_Python
C++ Find_the_Minimum_and_Maximum_Number_of_Nodes_Between_Critical_Points_C++
2130 Maximum_Twin_Sum_of_a_Linked_List Stack O(N) O(N) Medium Python Maximum_Twin_Sum_of_a_Linked_List_Python
C++ Maximum_Twin_Sum_of_a_Linked_List_C++
2181 Merge_Nodes_in_Between_Zeros Greedy O(N) O(N) Medium Python Merge_Nodes_in_Between_Zeros_Python
C++ Merge_Nodes_in_Between_Zeros_C++
2487 Remove_Nodes_From_Linked_List Stack O(k * N) O(N) Medium Python Remove_Nodes_From_Linked_List_Python
C++ Remove_Nodes_From_Linked_List_C++
2807 Insert_Greatest_Common_Divisors_in_Linked_List In-place pointers O(N) O(k) Medium Python Insert_Greatest_Common_Divisors_in_Linked_List_Python
C++ Insert_Greatest_Common_Divisors_in_Linked_List_C++
2816 Double_a_Number_Represented_as_a_Linked_List Greedy O(N) O(N) Medium Python Double_a_Number_Represented_as_a_Linked_List_Python
C++ Double_a_Number_Represented_as_a_Linked_List_C++
61 Rotate_List Greedy ~ O(2 * N) ~ O(2 * N) Medium Python Rotate_List_Python
C++ Rotate_List_C++
86 Partition_List Greedy O(N) O(N) Medium Python Partition_List_Python
C++ Partition_List_C++
92 Reverse_Linked_List_II Stack ~ O(N) ~ O(N) Medium Python Reverse_Linked_List_II_Python
C++ Reverse_Linked_List_II_C++
109 Convert_Sorted_List_to_Binary_Search_Tree Recursion ~ O(N) O(N) Medium Python Convert_Sorted_List_to_Binary_Search_Tree_Python
C++ Convert_Sorted_List_to_Binary_Search_Tree_C++
141 Linked_List_Cycle In-place pointers O(N // 2) O(1) Easy Python Linked_List_Cycle_Python
C++ Linked_List_Cycle_C++
142 Linked_List_Cycle_II In-place pointers O((N//2) + K) O(1) Medium Python Linked_List_Cycle_II_Python
C++ Linked_List_Cycle_II_C++
147 Insertion_Sort_List In-place pointers ~ O(k *N) ~ O(1) Medium Python Insertion_Sort_List_Python
C++ Insertion_Sort_List_C++
328 Odd_Even_Linked_List In-place pointers O(N) O(1) Medium Python Odd_Even_Linked_List_Python
C++ Odd_Even_Linked_List_C++
1290 Convert_Binary_Number_in_a_Linked_List_to_Integer 1-pass update O(N) O(1) Easy Python Convert_Binary_Number_in_a_Linked_List_to_Integer_Python
C++ Convert_Binary_Number_in_a_Linked_List_to_Integer_C++
2095 Delete_the_Middle_Node_of_a_Linked_List In-place pointers O(N // 2) O(N) Medium Python Delete_the_Middle_Node_of_a_Linked_List_Python
C++ Delete_the_Middle_Node_of_a_Linked_List_C++
2326 Spiral_Matrix_IV Four-pointers O(k * (R*C)) O(R * C) Medium Python Spiral_Matrix_IV_Python
C++ Spiral_Matrix_IV_C++
19 Remove_Nth_Node_From_End_of_List In-place pointers O(N) O(2 * N) Medium Python Remove_Nth_Node_From_End_of_List_Python
C++ Remove_Nth_Node_From_End_of_List_C++
21 Merge_Two_Sorted_Lists Greedy O(N) O(N) Easy Python Merge_Two_Sorted_Lists_Python
C++ Merge_Two_Sorted_Lists_C++
23 Merge_k_Sorted_Lists Greedy O(k * (N*K)) O(2 * (N*K)) Hard Python Merge_k_Sorted_Lists_Python
C++ Merge_k_Sorted_Lists_C++
24 Swap_Nodes_in_Pairs Recursion O(N) O(N) Medium Python Swap_Nodes_in_Pairs_Python
C++ Swap_Nodes_in_Pairs_C++
25 Reverse_Nodes_in_k_Group Recursion O(2 * N) O(N) Hard Python Reverse_Nodes_in_k_Group_Python
C++ Reverse_Nodes_in_k_Group_C++
82 Remove_Duplicates_from_Sorted_List_II In-place pointers O(2 * N) O(N) Medium Python Remove_Duplicates_from_Sorted_List_II_Python
C++ Remove_Duplicates_from_Sorted_List_II_C++
83 Remove_Duplicates_from_Sorted_List In-place pointers O(N) O(1) Easy Python Remove_Duplicates_from_Sorted_List_Python
C++ Remove_Duplicates_from_Sorted_List_C++
3217 Delete_Nodes_From_Linked_List_Present_in_Array In-place pointers O(N) O(K) Medium Python Delete_Nodes_From_Linked_List_Present_in_Array_Python
C++ Delete_Nodes_From_Linked_List_Present_in_Array_C++
2 Add_Two_Numbers One-pass update O(N) O(N) Medium Python Add_Two_Numbers_Python
C++ Add_Two_Numbers_C++
Sliding_Window 76 Minimum_Window_Substring Sliding-window O(N + (k*N)) O(N) Hard Python Minimum_Window_Substring_Python
C++ Minimum_Window_Substring_C++
187 Repeated_DNA_Sequences Sliding-window ~ O(k * N) ~ O(k * N) Medium Python Repeated_DNA_Sequences_Python
C++ Repeated_DNA_Sequences_C++
209 Minimum_Size_Subarray_Sum Two-pointers ~ O(k * N) ~ O(1) Medium Python Minimum_Size_Subarray_Sum_Python
C++ Minimum_Size_Subarray_Sum_C++
239 Sliding_Window_Maximum Deque O(k * N) O(2 * N) Hard Python Sliding_Window_Maximum_Python
C++ Sliding_Window_Maximum_C++
424 Longest_Repeating_Character_Replacement Sliding-window O(N) O(N) Medium Python Longest_Repeating_Character_Replacement_Python
C++ Longest_Repeating_Character_Replacement_C++
438 Find_All_Anagrams_in_a_String Sliding-window O(N + (k*N)) O(N) Medium Python Find_All_Anagrams_in_a_String_Python
C++ Find_All_Anagrams_in_a_String_C++
567 Permutation_in_String Sliding-window O(N + (k*N)) O(N) Medium Python Permutation_in_String_Python
C++ Permutation_in_String_C++
643 Maximum_Average_Subarray_I Sliding-window O(N) O(1) Medium Python Maximum_Average_Subarray_I_Python
C++ Maximum_Average_Subarray_I_C++
978 Longest_Turbulent_Subarray Sliding-window O(N) O(1) Medium Python Longest_Turbulent_Subarray_Python
C++ Longest_Turbulent_Subarray_C++
992 Subarrays_with_K_Different_Integers Sliding-window O(2 * (k*N)) O(2 * N) Hard Python Subarrays_with_K_Different_Integers_Python
C++ Subarrays_with_K_Different_Integers_C++
1004 Max_Consecutive_Ones_III Sliding-window O(N + k) O(1) Medium Python Max_Consecutive_Ones_III_Python
C++ Max_Consecutive_Ones_III_C++
1031 Maximum_Sum_of_Two_Non-Overlapping_Subarrays Sliding-window O(2 * N) O(1) Medium Python Maximum_Sum_of_Two_Non-Overlapping_Subarrays_Python
C++ Maximum_Sum_of_Two_Non-Overlapping_Subarrays_C++
1358 Number_of_Substrings_Containing_All_Three_Characters Sliding-window ~ O(k * N) O(N) Medium Python Number_of_Substrings_Containing_All_Three_Characters_Python
C++ Number_of_Substrings_Containing_All_Three_Characters_C++
1423 Maximum_Points_You_Can_Obtain_from_Cards Sliding-window ~ O(k * N) O(1) Medium Python Maximum_Points_You_Can_Obtain_from_Cards_Python
C++ Maximum_Points_You_Can_Obtain_from_Cards_C++
1438 Longest_Continuous_Subarray_With_Absolute_Diff_Less_Than_or_Equal_to_Limit Sliding-window O(K * N) O(2 * N) Medium Python Longest_Continuous_Subarray_With_Absolute_Diff_Less_Than_or_Equal_to_Limit_Python
C++ Longest_Continuous_Subarray_With_Absolute_Diff_Less_Than_or_Equal_to_Limit_C++
1456 Maximum_Number_of_Vowels_in_a_Substring_of_Given_Length Sliding-window O(N) O(5) Medium Python Maximum_Number_of_Vowels_in_a_Substring_of_Given_Length_Python
C++ Maximum_Number_of_Vowels_in_a_Substring_of_Given_Length_C++
1493 Longest_Subarray_of_1's_After_Deleting_One_Element Sliding-window O(k * N) O(1) Medium Python Longest_Subarray_of_1's_After_Deleting_One_Element_Python
C++ Longest_Subarray_of_1's_After_Deleting_One_Element_C++
1513 Number_of_Substrings_With_Only_1s Sliding-window O(N) O(1) Medium Python Number_of_Substrings_With_Only_1s_Python
C++ Number_of_Substrings_With_Only_1s_C++
1759 Count_Number_of_Homogenous_Substrings Sliding-window O(N) O(1) Medium Python Count_Number_of_Homogenous_Substrings_Python
C++ Count_Number_of_Homogenous_Substrings_C++
2062 Count_Vowel_Substrings_of_a_String Sliding-window ~ O(k * N) ~ O(N) Easy Python Count_Vowel_Substrings_of_a_String_Python
C++ Count_Vowel_Substrings_of_a_String_C++
2090 K_Radius_Subarray_Averages Sliding-window O(N) O(N) Medium Python K_Radius_Subarray_Averages_Python
C++ K_Radius_Subarray_Averages_C++
2260 Minimum_Consecutive_Cards_to_Pick_Up Sliding-window O(K * N) O(N) Medium Python Minimum_Consecutive_Cards_to_Pick_Up_Python
C++ Minimum_Consecutive_Cards_to_Pick_Up_C++
2461 Maximum_Sum_of_Distinct_Subarrays_With_Length_K Sliding-window ~ O(K * N) O(N) Medium Python Maximum_Sum_of_Distinct_Subarrays_With_Length_K_Python
C++ Maximum_Sum_of_Distinct_Subarrays_With_Length_K_C++
2516 Take_K_of_Each_Character_From_Left_and_Right Sliding-window O((1+k) * N) O(3 * 2) Medium Python Take_K_of_Each_Character_From_Left_and_Right_Python
C++ Take_K_of_Each_Character_From_Left_and_Right_C++
2537 Count_the_Number_of_Good_Subarrays Sliding-window O(K * N) O(N) Medium Python Count_the_Number_of_Good_Subarrays_Python
C++ Count_the_Number_of_Good_Subarrays_C++
2765 Longest_Alternating_Subarray Sliding-window O(N) O(1) Easy Python Longest_Alternating_Subarray_Python
C++ Longest_Alternating_Subarray_C++
2779 Maximum_Beauty_of_an_Array_After_Applying_Operation Sliding-window O((k+Log(N)) * N) O(1) Medium Python Maximum_Beauty_of_an_Array_After_Applying_Operation_Python
C++ Maximum_Beauty_of_an_Array_After_Applying_Operation_C++
2799 Count_Complete_Subarrays_in_an_Array Sliding-window O(k * N) O(2 * N) Medium Python Count_Complete_Subarrays_in_an_Array_Python
C++ Count_Complete_Subarrays_in_an_Array_C++
3026 Maximum_Good_Subarray_Sum Sliding-window O(2 * N) O(2 * N) Medium Python Maximum_Good_Subarray_Sum_Python
C++ Maximum_Good_Subarray_Sum_C++
Bit_Manipulation 89 Gray_Code Bit-manipulation O(k * N) O(N) Medium Python Gray_Code_Python
C++ Gray_Code_C++
190 Reverse_Bits Bit-manipulation O(N) O(1) Easy Python Reverse_Bits_Python
C++ Reverse_Bits_C++
201 Bitwise_AND_of_Numbers_Range Bit-manipulation O(N) O(1) Medium Python Bitwise_AND_of_Numbers_Range_Python
C++ Bitwise_AND_of_Numbers_Range_C++
338 Counting_Bits Bit-manipulation O(N * Log(N)) O(N) Easy Python Counting_Bits_Python
C++ Counting_Bits_C++
1318 Minimum_Flips_to_Make_a_OR_b_Equal_to_c Bit-manipulation O(N) O(1) Medium Python Minimum_Flips_to_Make_a_OR_b_Equal_to_c_Python
C++ Minimum_Flips_to_Make_a_OR_b_Equal_to_c_C++
String 32 Longest_Valid_Parentheses Stack O(N) O(N) Hard Python Longest_Valid_Parentheses_Python
C++ Longest_Valid_Parentheses_C++
38 Count_and_Say String O(k * N) O(N) Medium Python Count_and_Say_Python
C++ Count_and_Say_C++
49 Group_Anagrams Hashmap ~ O(K * N) O(k * N) Medium Python Group_Anagrams_Python
C++ Group_Anagrams_C++
71 Simplify_Path Stack O(2 * N) O(2 * N) Medium Python Simplify_Path_Python
C++ Simplify_Path_C++
224 Basic_Calculator Stack O(N) O(N) Hard Python Basic_Calculator_Python
C++ Basic_Calculator_C++
227 Basic_Calculator_II Stack O(2 * N) O(N) Medium Python Basic_Calculator_II_Python
C++ Basic_Calculator_II_C++
242 Valid_Anagram 2-pass record O(2 * N) O(2 * 26) Easy Python Valid_Anagram_Python
C++ Valid_Anagram_C++
290 Word_Pattern Hashmap O(N) O(2 * N) Easy Python Word_Pattern_Python
C++ Word_Pattern_C++
299 Bulls_and_Cows Hashmap O(3 * N) O(N) Medium Python Bulls_and_Cows_Python
C++ Bulls_and_Cows_C++
392 Is_Subsequence Two-pointers O(N) O(1) Easy Python Is_Subsequence_Python
C++ Is_Subsequence_C++
394 Decode_String Stack O(k + N) O(3 * N) Medium Python Decode_String_Python
C++ Decode_String_C++
443 String_Compression In-place pointer O(k * N) O(N) Medium Python String_Compression_Python
C++ String_Compression_C++
647 Palindromic_Substrings Two-pointers O(2 * (k*N)) O(1) Medium Python Palindromic_Substrings_Python
C++ Palindromic_Substrings_C++
649 Dota2_Senate Queue O(N + k) O(N) Medium Python Dota2_Senate_Python
C++ Dota2_Senate_C++
777 Swap_Adjacent_in_LR_String Stack O(2 * N) O(2 * N) Medium Python Swap_Adjacent_in_LR_String_Python
C++ Swap_Adjacent_in_LR_String_C++
791 Custom_Sort_String Hashmap O((1 + (2*k)) * N) O(2 * N) Medium Python Custom_Sort_String_Python
C++ Custom_Sort_String_C++
848 Shifting_Letters Prefix-summary O(2 * N) O(2 * N) Medium Python Shifting_Letters_Python
C++ Shifting_Letters_C++
1071 Greatest_Common_Divisor_of_Strings Math-GCD O(k * N) O(N) Easy Python Greatest_Common_Divisor_of_Strings_Python
C++ Greatest_Common_Divisor_of_Strings_C++
1347 Minimum_Number_of_Steps_to_Make_Two_Strings_Anagram String-counting O(2 * N) O(N) Medium Python Minimum_Number_of_Steps_to_Make_Two_Strings_Anagram_Python
C++ Minimum_Number_of_Steps_to_Make_Two_Strings_Anagram_C++
1419 Minimum_Number_of_Frogs_Croaking Hashmap O(N) O(10) Medium Python Minimum_Number_of_Frogs_Croaking_Python
C++ Minimum_Number_of_Frogs_Croaking_C++
1653 Minimum_Deletions_to_Make_String_Balanced Greedy O(N) O(1) Medium Python Minimum_Deletions_to_Make_String_Balanced_Python
C++ Minimum_Deletions_to_Make_String_Balanced_C++
1657 Determine_if_Two_Strings_Are_Close String-counting O((3 + (2*Log(N))) * N) O(2 * N) Medium Python Determine_if_Two_Strings_Are_Close_Python
C++ Determine_if_Two_Strings_Are_Close_C++
1750 Minimum_Length_of_String_After_Deleting_Similar_Ends Two-pointers O(N) O(1) Medium Python Minimum_Length_of_String_After_Deleting_Similar_Ends_Python
C++ Minimum_Length_of_String_After_Deleting_Similar_Ends_C++
1768 Merge_Strings_Alternately Two-pointers O(N) O(N) Easy Python Merge_Strings_Alternately_Python
C++ Merge_Strings_Alternately_C++
1844 Replace_All_Digits_with_Characters 1-pass record O(N) O(N) Easy Python Replace_All_Digits_with_Characters_Python
C++ Replace_All_Digits_with_Characters_C++
2063 Vowels_of_All_Substrings 1-pass update O(N) O(k) Medium Python Vowels_of_All_Substrings_Python
C++ Vowels_of_All_Substrings_C++
2109 Adding_Spaces_to_a_String Two-pointers ~ O(N) O(N) Medium Python Adding_Spaces_to_a_String_Python
C++ Adding_Spaces_to_a_String_C++
2211 Count_Collisions_on_a_Road Stack O(k * N) O(N) Medium Python Count_Collisions_on_a_Road_Python
C++ Count_Collisions_on_a_Road_C++
2311 Longest_Binary_Subsequence_Less_Than_or_Equal_to_K Bit-manipulations O(N) O(1) Medium Python Longest_Binary_Subsequence_Less_Than_or_Equal_to_K_Python
C++ Longest_Binary_Subsequence_Less_Than_or_Equal_to_K_C++
2315 Count_Asterisks 1-pass record O(N) O(1) Easy Python Count_Asterisks_Python
C++ Count_Asterisks_C++
2337 Move_Pieces_to_Obtain_a_String Stack O(2 * N) O(2 * N) Medium Python Move_Pieces_to_Obtain_a_String_Python
C++ Move_Pieces_to_Obtain_a_String_C++
2380 Time_Needed_to_Rearrange_a_Binary_String Greedy O(N) O(1) Medium Python Time_Needed_to_Rearrange_a_Binary_String_Python
C++ Time_Needed_to_Rearrange_a_Binary_String_C++
2390 Removing_Stars_From_a_String Stack O(N) O(k * N) Medium Python Removing_Stars_From_a_String_Python
C++ Removing_Stars_From_a_String_C++
2486 Append_Characters_to_String_to_Make_Subsequence Two-pointers O(N) O(1) Medium Python Append_Characters_to_String_to_Make_Subsequence_Python
C++ Append_Characters_to_String_to_Make_Subsequence_C++
2707 Extra_Characters_in_a_String DP O(N * K) ~ O(k * N) Medium Python Extra_Characters_in_a_String_Python
C++ Extra_Characters_in_a_String_C++
2825 Make_String_a_Subsequence_Using_Cyclic_Increments Two-pointers O(N) O(1) Medium Python Make_String_a_Subsequence_Using_Cyclic_Increments_Python
C++ Make_String_a_Subsequence_Using_Cyclic_Increments_C++
2942 Find_Words_Containing_Character One-pass record O(N) O(K) Easy Python Find_Words_Containing_Character_Python
C++ Find_Words_Containing_Character_C++
3043 Find_the_Length_of_the_Longest_Common_Prefix Greedy O(2 * (N*K)) ~ O(2 * (N*K)) Medium Python Find_the_Length_of_the_Longest_Common_Prefix_Python
C++ Find_the_Length_of_the_Longest_Common_Prefix_C++
3137 Minimum_Number_of_Operations_to_Make_Word_K-Periodic Sliding-window O(N) O(N) Medium Python Minimum_Number_of_Operations_to_Make_Word_K-Periodic_Python
C++ Minimum_Number_of_Operations_to_Make_Word_K-Periodic_C++
3138 Minimum_Length_of_Anagram_Concatenation Vector-counting O(N * (k*N)) O(1) Medium Python Minimum_Length_of_Anagram_Concatenation_Python
C++ Minimum_Length_of_Anagram_Concatenation_C++
3163 String_Compression_III In-place pointer O(N) O(N) Medium Python String_Compression_III_Python
String_Compression_III_C++
3174 Clear_Digits Stack O(N) O(2 * N) Easy Python Clear_Digits_Python
C++ Clear_Digits_C++
3340 Check_Balanced_String Two-pointers O(N) O(1) Easy Python Check_Balanced_String_Python
C++ Check_Balanced_String_C++
3 Longest_Substring_Without_Repeating_Characters Two-pointers ~ O(k * N) ~ O(N) Medium Python Longest_Substring_Without_Repeating_Characters_Python
C++ Longest_Substring_Without_Repeating_Characters_C++
5 Longest_Palindromic_Substring Manacher's ~ O(k + N) O(2 * N) Medium Python Longest_Palindromic_Substring_Python
C++ Longest_Palindromic_Substring_C++
6 Zigzag_Conversion 1-pass traversal O(N) O(N) Medium Python Zigzag_Conversion_Python
C++ Zigzag_Conversion_C++
344 Reverse_String 1-pass swap O(N // 2) O(1) Easy Python Reverse_String_Python
C++ Reverse_String_C++
345 Reverse_Vowels_of_a_String Two-pointers ~ O(N) ~ O(N) Easy Python Reverse_Vowels_of_a_String_Python
C++ Reverse_Vowels_of_a_String_C++
557 Reverse_Words_in_a_String_III Two-pointers O(N) ~ O(N) Easy Python Reverse_Words_in_a_String_III_Python
C++ Reverse_Words_in_a_String_III_C++
657 Robot_Return_to_Origin 1-pass record O(N) O(4) Easy Python Robot_Return_to_Origin_Python
C++ Robot_Return_to_Origin_C++
696 Count_Binary_Substrings Greedy O(N) O(1) Easy Python Count_Binary_Substrings_Python
C++ Count_Binary_Substrings_C++
796 Rotate_String In-place pointers O(N) O(N) Easy Python Rotate_String_Python
C++ Rotate_String_C++
1332 Remove_Palindromic_Subsequences Two-pointers ~ O(N) O(1) Easy Python Remove_Palindromic_Subsequences_Python
C++ Remove_Palindromic_Subsequences_C++
1529 Minimum_Suffix_Flips Greedy O(N) O(1) Medium Python Minimum_Suffix_Flips_Python
C++ Minimum_Suffix_Flips_C++
1578 Minimum_Time_to_Make_Rope_Colorful Greedy O(N) O(1) Medium Python Minimum_Time_to_Make_Rope_Colorful_Python
C++ Minimum_Time_to_Make_Rope_Colorful_C++
1871 Jump_Game_VII DP O(N) O(N) Medium Python Jump_Game_VII_Python
C++ Jump_Game_VII_C++
2405 Optimal_Partition_of_String Two-pointers O(K * N) O(N) Medium Python Optimal_Partition_of_String_Python
C++ Optimal_Partition_of_String_C++
Array 1 Two_Sum Hashmap ~ O(N) ~ O(N) Easy Python Two_Sum_Python
C++ Two_Sum_C++
4 Median_of_Two_Sorted_Arrays Merge-sort O(m + n) O(m + n) Hard Python Median_of_Two_Sorted_Arrays_Python
C++ Median_of_Two_Sorted_Arrays_C++
11 Container_With_Most_Water Two-pointers O(N) O(1) Medium Python Container_With_Most_Water_Python
C++ Container_With_Most_Water_C++
15 3Sum Three-pointers O(K * (M * N)) O(N) Medium Python 3Sum_Python
C++ 3Sum_C++
18 4Sum Four-pointers O(K * (P * (M*N))) O(N) Medium Python 4Sum_Python
C++ 4Sum_C++
26 Remove_Duplicates_from_Sorted_Array Two-pointers O(k * Log(N)) O(1) Easy Python Remove_Duplicates_from_Sorted_Array_Python
C++ Remove_Duplicates_from_Sorted_Array_C++
27 Remove_Element Two-pointers ~ O(k * N) O(1) Easy Python Remove_Element_Python
C++ Remove_Element_C++
36 Valid_Sudoku Hashmap O(k * (N^4)) O(3 * N) Medium Python Valid_Sudoku_Python
C++ Valid_Sudoku_C++
48 Rotate_Image Two-pointers O(k * (N*N)) O(k) Medium Python Rotate_Image_Python
C++ Rotate_Image_C++
53 Maximum_Subarray Kadanes' O(N) O(1) Medium Python Maximum_Subarray_Python
C++ Maximum_Subarray_C++
55 Jump_Game Greedy O(N) O(1) Medium Python Jump_Game_Python
C++ Jump_Game_C++
56 Merge_Intervals Greedy O(N) O(2 * N) Medium Python Merge_Intervals_Python
C++ Merge_Intervals_C++
57 Insert_Interval Greedy O(N) O(2 * N) Medium Python Insert_Interval_Python
C++ Insert_Interval_C++
73 Set_Matrix_Zeroes Hashmap O(k * (R*C)) O(1) Medium Python Set_Matrix_Zeroes_Python
C++ Set_Matrix_Zeroes_C++
80 Remove_Duplicates_from_Sorted_Array_II Two-pointers O(N) O(1) Medium Python Remove_Duplicates_from_Sorted_Array_II_Python
C++ Remove_Duplicates_from_Sorted_Array_II_C++
84 Largest_Rectangle_in_Histogram Stack O(k * N) O(N) Hard Python Largest_Rectangle_in_Histogram_Python
C++ Largest_Rectangle_in_Histogram_C++
88 Merge_Sorted_Array Two-pointers ~ O(M + N) O(1) Easy Python Merge_Sorted_Array_Python
C++ Merge_Sorted_Array_C++
121 Best_Time_to_Buy_and_Sell_Stock Two-pointers O(N) O(1) Easy Python Best_Time_to_Buy_and_Sell_Stock_Python
C++ Best_Time_to_Buy_and_Sell_Stock_C++
122 Best_Time_to_Buy_and_Sell_Stock_II Greedy O(N) O(1) Medium Python Best_Time_to_Buy_and_Sell_Stock_II_Python
C++ Best_Time_to_Buy_and_Sell_Stock_II_C++
135 Candy Heap/Priority-queue O(2 * (N*Log(N))) O(2 * N) Hard Python Candy_Python
C++ Candy_C++
150 Evaluate_Reverse_Polish_Notation Stack O(N) O(k * N) Medium Python Evaluate_Reverse_Polish_Notation_Python
C++ Evaluate_Reverse_Polish_Notation_C++
152 Maximum_Product_Subarray DP O(N) O(1) Medium Python Maximum_Product_Subarray_Python
C++ Maximum_Product_Subarray_C++
155 Min_Stack Stack O(N) O(2 * N) Medium Python Min_Stack_Python
C++ Min_Stack_C++
167 Two_Sum_II_-_Input_Array_Is_Sorted Two-pointers O(N) O(1) Medium Python Two_Sum_II_-_Input_Array_Is_Sorted_Python
C++ Two_Sum_II_-_Input_Array_Is_Sorted_C++
169 Majority_Element Hashmap O(N) O(N) Easy Python Majority_Element_Python
C++ Majority_Element_C++
189 Rotate_Array 2-pass update O(2 * N) O(N) Medium Python Rotate_Array_Python
C++ Rotate_Array_C++
215 Kth_Largest_Element_in_an_Array Heap/Priority-queue O(2 * (N*Log(N))) O(N) Medium Python Kth_Largest_Element_in_an_Array_Python
C++ Kth_Largest_Element_in_an_Array_C++
219 Contains_Duplicate_II Hashmap O(N) O(N) Easy Python Contains_Duplicate_II_Python
C++ Contains_Duplicate_II_C++
228 Summary_Ranges Greedy O(N) O(N) Easy Python Summary_Ranges_Python
C++ Summary_Ranges_C++
238 Product_of_Array_Except_Self Prefix/Suffix-product O(k * N) O(k * N) Medium Python Product_of_Array_Except_Self_Python
C++ Product_of_Array_Except_Self_C++
260 Single_Number_III Hashmap O(N + k) O(N + 2) Medium Python Single_Number_III_Python
C++ Single_Number_III_C++
274 H-Index Binary-search O(Log(N)) O(1) Medium Python H-Index_Python
C++ H-Index_C++
275 H-Index_II Binary-search O(Log(N)) O(1) Medium Python H-Index_II_Python
C++ H-Index_II_C++
283 Move_Zeroes Two-pointers ~ O(N) O(1) Easy Python Move_Zeroes_Python
C++ Move_Zeroes_C++
289 Game_of_Life BFS ~ O(2 * N) ~ O(k * N) Medium Python Game_of_Life_Python
C++ Game_of_Life_C++
295 Find_Median_from_Data_Stream Heap/Priority-queue O(k * Log(N)) O(2 * N) Hard Python Find_Median_from_Data_Stream_Python
C++ Find_Median_from_Data_Stream_C++
307 Range_Sum_Query-Mutable Binary indexed-tree O(N * Log(N)) ~ O(2 * N) Medium Python Range_Sum_Query-Mutable_Python
C++ Range_Sum_Query-Mutable_C++
347 Top_K_Frequent_Elements Heap/Priority-queue O(N * Log(N)) ~ O(k * N) Medium Python Top_K_Frequent_Elements_Python
C++ Top_K_Frequent_Elements_C++
355 Design_Twitter Heap/Priority-queue O((k*N) * Log(N)) O(4 * N) Medium Python Design_Twitter_Python
C++ Design_Twitter_C++
399 Evaluate_Division DFS + BFS ~ O(K * N) ~ O(K * N) Medium Python Evaluate_Division_Python
C++ Evaluate_Division_C++
503 Next_Greater_Element_II Stack O(k * N) O(3 * N) Medium Python Next_Greater_Element_II_Python
C++ Next_Greater_Element_II_C++
560 Subarray_Sum_Equals_K 1-pass record O(N) O(N) Medium Python Subarray_Sum_Equals_K_Python
C++ Subarray_Sum_Equals_K_C++
581 Shortest_Unsorted_Continuous_Subarray Two-pointers O((N*Log(N)) + N) O(N) Medium Python Shortest_Unsorted_Continuous_Subarray_Python
C++ Shortest_Unsorted_Continuous_Subarray_C++
658 Find_K_Closest_Elements Two-pointers ~ O(k * N) ~ O(N) Medium Python Find_K_Closest_Elements_Python
C++ Find_K_Closest_Elements_C++
667 Beautiful_Arrangement_II Two-pointers O(N) O(N) Medium Python Beautiful_Arrangement_II_Python
C++ Beautiful_Arrangement_II_C++
724 Find_Pivot_Index Prefix-summary O(2 * N) O(N) Easy Python Find_Pivot_Index_Python
C++ Find_Pivot_Index_C++
735 Asteroid_Collision Stack O(N) O(N) Medium Python Asteroid_Collision_Python
C++ Asteroid_Collision_C++
739 Daily_Temperatures Stack O(k * N) O(3 * N) Medium Python Daily_Temperatures_Python
C++ Daily_Temperatures_C++
826 Most_Profit_Assigning_Work Greedy O(N + (k * N)) O(2 * N) Medium Python Most_Profit_Assigning_Work_Python
C++ Most_Profit_Assigning_Work_C++
845 Longest_Mountain_in_Array Greedy O(N) O(1) Medium Python Longest_Mountain_in_Array_Python
C++ Longest_Mountain_in_Array_C++
846 Hand_of_Straights Heap/Priority-queue O(N * Log(N)) ~ O(k * N) Medium Python Hand_of_Straights_Python
C++ Hand_of_Straights_C++
857 Minimum_Cost_to_Hire_K_Workers Heap/Priority-queue O(N + (K*Log(N))) O((2*N) + k) Hard Python Minimum_Cost_to_Hire_K_Workers_Python
C++ Minimum_Cost_to_Hire_K_Workers_C++
862 Shortest_Subarray_with_Sum_at_Least_K Heap/Priority-queue O((k*N) * Log(N)) O(N) Hard Python Shortest_Subarray_with_Sum_at_Least_K_Python
C++ Shortest_Subarray_with_Sum_at_Least_K_C++
874 Walking_Robot_Simulation Hashmap O(k * N) O(K) Medium Python Walking_Robot_Simulation_Python
C++ Walking_Robot_Simulation_C++
895 Maximum_Frequency_Stack Heap/Priority-queue O(k * Log(N)) O(k * N) Hard Python Maximum Frequency Stack_Python
C++ Maximum_Frequency_Stack_C++
901 Online_Stock_Span Stack O(k * N) O(2 * N) Medium Python Online_Stock_Span_Python
C++ Online_Stock_Span_C++
904 Fruit_Into_Baskets Sliding-window ~ O(k * N) O(N) Medium Python Fruit_Into_Baskets_Python
C++ Fruit_Into_Baskets_C++
907 Sum_of_Subarray_Minimums Stack O(N + k) O(N) Medium Python Sum_of_Subarray_Minimums_Python
C++ Sum_of_Subarray_Minimums_C++
912 Sort_an_Array Heap-sort ~ O(N * Log(N)) ~ O(k * N) Medium Python Sort_an_Array_Python
C++ Sort_an_Array_C++
918 Maximum_Sum_Circular_Subarray Kadanes' O(N) O(1) Medium Python Maximum_Sum_Circular_Subarray_Python
C++ Maximum_Sum_Circular_Subarray_C++
933 Number_of_Recent_Calls Queue O(k * N) O(N) Easy Python Number_of_Recent_Calls_Python
C++ Number_of_Recent_Calls_C++
945 Minimum_Increment_to_Make_Array_Unique Greedy O(N) O(N) Medium Python Minimum_Increment_to_Make_Array_Unique_Python
C++ Minimum_Increment_to_Make_Array_Unique_C++
1005 Maximize_Sum_Of_Array_After_K_Negations Heap/Priority-queue O(N * Log(N)) O(N) Easy Python Maximize_Sum_Of_Array_After_K_Negations_Python
C++ Maximize_Sum_Of_Array_After_K_Negations_C++
1046 Last_Stone_Weight Heap/Priority-queue O(N * Log(N)) O(2 * N) Easy Python Last_Stone_Weight_Python
Last_Stone_Weight_C++
1207 Unique_Number_of_Occurrences Hashmap O(k + N) O(N + k) Easy Python Unique_Number_of_Occurrences_Python
C++ Unique_Number_of_Occurrences_C++
1431 Kids_With_the_Greatest_Number_of_Candies One-pass update O(2 * N) O(N) Easy Python Kids_With_the_Greatest_Number_of_Candies_Python
C++ Kids_With_the_Greatest_Number_of_Candies_C++
1472 Design_Browser_History Stack O(k * N) O(N) Medium Python Design_Browser_History_Python
C++ Design_Browser_History_C++
1481 Least_Number_of_Unique_Integers_after_K_Removal Heap/Priority-queue O(N + (K*Log(k))) O(2 * k) Medium Python Least_Number_of_Unique_Integers_after_K_Removal_Python
C++ Least_Number_of_Unique_Integers_after_K_Removal_C++
1508 Range_Sum_of_Sorted_Subarray_Sums Two-pointers ~ O((k*N) * N) O(N) Medium Python Range_Sum_of_Sorted_Subarray_Sums_Python
C++ Range_Sum_of_Sorted_Subarray_Sums_C++
1562 Find_Latest_Group_of_Size_M Prefix-summary O(N) O(2 * N) Medium Python Find_Latest_Group_of_Size_M_Python
C++ Find_Latest_Group_of_Size_M_C++
1642 Furthest_Building_You_Can_Reach Heap/Priority-queue O(N * Log(N)) O(N) Medium Python Furthest_Building_You_Can_Reach_Python
C++ Furthest_Building_You_Can_Reach_C++
1658 Minimum_Operations_to_Reduce_X_to_Zero Sliding-window ~ O(k * N) ~ O(1) Medium Python Minimum_Operations_to_Reduce_X_to_Zero_Python
C++ Minimum_Operations_to_Reduce_X_to_Zero_C++
1679 Max_Number_of_K-Sum_Pairs Two-pointers ~ O(((3/4)+Log(N)) * N) O(1) Medium Python Max_Number_of_K-Sum_Pairs_Python
C++ Max_Number_of_K-Sum_Pairs_C++
1732 Find_the_Highest_Altitude Prefix-summary O(N) O(N) Easy Python Find_the_Highest_Altitude_Python
C++ Find_the_Highest_Altitude_C++
1838 Frequency_of_the_Most_Frequent_Element Two-pointers ~ O(N) ~ O(1) Medium Python Frequency_of_the_Most_Frequent_Element_Python
C++ Frequency_of_the_Most_Frequent_Element_C++
1861 Rotating_the_Box Two-pointers O(2 * (R*C)) O(R * C) Medium Python Rotating_the_Box_Python
C++ Rotating_the_Box_C++
1962 Remove_Stones_to_Minimize_the_Total Heap/Priority-queue ~ O(N * Log(N)) ~ O(N) Medium Python Remove_Stones_to_Minimize_the_Total_Python
C++ Remove_Stones_to_Minimize_the_Total_C++
2099 Find_Subsequence_of_Length_K_With_the_Largest_Sum Heap/Priority-queue O((2 * (N*Log(N))) + N) O(2 * N) Easy Python Find_Subsequence_of_Length_K_With_the_Largest_Sum_Python
C++ Find_Subsequence_of_Length_K_With_the_Largest_Sum_C++
2104 Sum_of_Subarray_Ranges Stack O(2 * (N + k)) O(N) Medium Python Sum_of_Subarray_Ranges_Python
C++ Sum_of_Subarray_Ranges_C++
2134 Minimum_Swaps_to_Group_All_1's_Together_II Sliding-window O(N) O(1) Medium Python Minimum_Swaps_to_Group_All_1's_Together_II_Python
C++ Minimum_Swaps_to_Group_All_1's_Together_II_C++
2195 Append_K_Integers_With_Minimal_Sum Greedy O(k * N) O(N) Medium Python Append_K_Integers_With_Minimal_Sum_Python
C++ Append_K_Integers_With_Minimal_Sum_C++
2210 Count_Hills_and_Valleys_in_an_Array Two-pointers O(k * N) O(2 * K) Easy Python Count_Hills_and_Valleys_in_an_Array_Python
C++ Count_Hills_and_Valleys_in_an_Array_C++
2215 Find_the_Difference_of_Two_Arrays Hashmap O(4 * N) O(4 * N) Easy Python Find_the_Difference_of_Two_Arrays_Python
C++ Find_the_Difference_of_Two_Arrays_C++
2233 Maximum_Product_After_K_Increments Heap/Priority-queue ~ O(3 * N) O(3 * N) Medium Python Maximum_Product_After_K_Increments_Python
C++ Maximum_Product_After_K_Increments_C++
2289 Steps_to_Make_Array_Non-decreasing Stack O(k * N) O(2 * N) Medium Python Steps_to_Make_Array_Non-decreasing_Python
C++ Steps_to_Make_Array_Non-decreasing_C++
2352 Equal_Row_and_Column_Pairs Hashmap O((2*R) + C) O(R) Medium Python Equal_Row_and_Column_Pairs_Python
C++ Equal_Row_and_Column_Pairs_C++
2357 Make_Array_Zero_by_Subtracting_Equal_Amounts Hashmap O(N) O(N) Easy Python Make_Array_Zero_by_Subtracting_Equal_Amounts_Python
C++ Make_Array_Zero_by_Subtracting_Equal_Amounts_C++
2391 Minimum_Amount_of_Time_to_Collect_Garbage Greedy O(N) O(N) Medium Python Minimum_Amount_of_Time_to_Collect_Garbage_Python
C++ Minimum_Amount_of_Time_to_Collect_Garbage_C++
1030 Matrix_Cells_in_Distance_Order 2-pass record O(k * (R*C)) O(4 * (R*C)) Easy Python Matrix_Cells_in_Distance_Order_Python
C++ Matrix_Cells_in_Distance_Order_C++
1329 Sort_the_Matrix_Diagonally Greedy ~ O(2 * (R*C)) O(R * C) Medium Python Sort_the_Matrix_Diagonally_Python
C++ Sort_the_Matrix_Diagonally_C++
1353 Maximum_Number_of_Events_That_Can_Be_Attended Heap/Priority-queue ~ O(N * Log(N)) ~ O(k * N) Medium Python Maximum_Number_of_Events_That_Can_Be_Attended_Python
C++ Maximum_Number_of_Events_That_Can_Be_Attended_C++
1894 Find_the_Student_that_Will_Replace_the_Chalk Greedy ~ O(N) O(1) Medium Python Find_the_Student_that_Will_Replace_the_Chalk_Python
C++ Find_the_Student_that_Will_Replace_the_Chalk_C++
1936 Add_Minimum_Number_of_Rungs Greedy O(N) O(1) Medium Python Add_Minimum_Number_of_Rungs_Python
C++ Add_Minimum_Number_of_Rungs_C++
2008 Maximum_Earnings_From_Taxi DP ~ O(K * N) ~ O(k * N) Medium Python Maximum_Earnings_From_Taxi_Python
C++ Maximum_Earnings_From_Taxi_C++
2148 Count_Elements_With_Strictly_Smaller_and_Greater_Elements 1-pass record O(N) O(1) Easy Python Count_Elements_With_Strictly_Smaller_and_Greater_Elements_Python
C++ Count_Elements_With_Strictly_Smaller_and_Greater_Elements_C++
2208 Minimum_Operations_to_Halve_Array_Sum Heap/Priority-queue ~ O(N * Log(N)) ~ O(N) Medium Python Minimum_Operations_to_Halve_Array_Sum_Python
C++ Minimum_Operations_to_Halve_Array_Sum_C++
2336 Smallest_Number_in_Infinite_Set Heap/Priority-queue O(N * Log(N)) O(2 * N) Medium Python Smallest_Number_in_Infinite_Set_Python
C++ Smallest_Number_in_Infinite_Set_C++
2406 Divide_Intervals_Into_Minimum_Number_of_Groups Heap/Priority-queue O((N+K) * Log(N)) O(N) Medium Python Divide_Intervals_Into_Minimum_Number_of_Groups_Python
C++ Divide_Intervals_Into_Minimum_Number_of_Groups_C++
2418 Sort_the_People Heap/Priority-queue O(N * Log(N)) O(3 * N) Easy Python Sort_the_People_Python
C++ Sort_the_People_C++
2453 Destroy_Sequential_Targets Hashmap O((2+Log(N)) * N) O(2 * N) Medium Python Destroy_Sequential_Targets_Python
C++ Destroy_Sequential_Targets_C++
2454 Next_Greater_Element_IV Stack O(K * N) O(3 * N) Hard Python Next_Greater_Element_IV_Python
C++ Next_Greater_Element_IV_C++
2462 Total_Cost_to_Hire_K_Workers Two-pointers O(k * (N*Log(N))) O(2 * N) Medium Python Total_Cost_to_Hire_K_Workers_Python
C++ Total_Cost_to_Hire_K_Workers_C++
2482 Difference_Between_Ones_and_Zeros_in_Row_and_Column Hashmap O(2 * (R*C)) O(5 * N) Medium Python Difference_Between_Ones_and_Zeros_in_Row_and_Column_Python
C++ Difference_Between_Ones_and_Zeros_in_Row_and_Column_C++
2512 Reward_Top_K_Students Heap/Priority-queue O(N * ((k*N) + Log(N))) O(3 * N) Medium Python Reward_Top_K_Students_Python
C++ Reward_Top_K_Students_C++
2530 Maximal_Score_After_Applying_K_Operations Heap/Priority-queue ~ O(N * Log(N)) ~ O(N) Medium Python Maximal_Score_After_Applying_K_Operations_Python
C++ Maximal_Score_After_Applying_K_Operations_C++
2540 Minimum_Common_Value Two-pointers ~ O(k * N) O(1) Easy Python Minimum_Common_Value_Python
C++ Minimum_Common_Value_C++
2542 Maximum_Subsequence_Score Heap/Priority-queue O((1+Log(N)) * N) O(2 * N) Medium Python Maximum_Subsequence_Score_Python
C++ Maximum_Subsequence_Score_C++
2545 Sort_the_Students_by_Their_Kth_Score Sorted-operations O((2+Log(R)) * R) O((2+C) * R) Medium Python Sort_the_Students_by_Their_Kth_Score_Python
C++ Sort_the_Students_by_Their_Kth_Score_C++
2554 Maximum_Number_of_Integers_to_Choose_From_a_Range_I DP O(N) O(2 * N) Medium Python Maximum_Number_of_Integers_to_Choose_From_a_Range_I_Python
C++ Maximum_Number_of_Integers_to_Choose_From_a_Range_I_C++
2558 Take_Gifts_From_the_Richest_Pile Heap/Priority-queue ~ O(N * Log(N)) ~ O(N) Easy Python Take_Gifts_From_the_Richest_Pile_Python
C++ Take_Gifts_From_the_Richest_Pile_C++
2587 Rearrange_Array_to_Maximize_Prefix_Score 1-pass update ~ O(N) O(1) Medium Python Rearrange_Array_to_Maximize_Prefix_Score_Python
C++ Rearrange_Array_to_Maximize_Prefix_Score_C++
2606 Find_the_Substring_With_Maximum_Cost Kadanes' O(2 * N) O(N) Medium Python Find_the_Substring_With_Maximum_Cost_Python
C++ Find_the_Substring_With_Maximum_Cost_C++
2661 First_Completely_Painted_Row_or_Column Hashmap O((R*C) + N) O(3 * N) Medium Python First_Completely_Painted_Row_or_Column_Python
C++ First_Completely_Painted_Row_or_Column_C++
2762 Continuous_Subarrays Deque O(K * N) O(N) Medium Python Continuous_Subarrays_Python
C++ Continuous_Subarrays_C++
2768 Number_of_Black_Blocks Hashmap O((4*N) + K) O((K + 5)) Medium Python Number_of_Black_Blocks_Python
C++ Number_of_Black_Blocks_C++
2780 Minimum_Index_of_a_Valid_Split Hashmap O(2 * N) O(2 * N) Medium Python Minimum_Index_of_a_Valid_Split_Python
C++ Minimum_Index_of_a_Valid_Split_C++
2789 Largest_Element_in_an_Array_after_Merge_Operations Greedy ~ O(N) O(1) Medium Python Largest_Element_in_an_Array_after_Merge_Operations_Python
C++ Largest_Element_in_an_Array_after_Merge_Operations_C++
2798 Number_of_Employees_Who_Met_the_Target 1-pass compare O(N) O(1) Easy Python Number_of_Employees_Who_Met_the_Target_Python
C++ Number_of_Employees_Who_Met_the_Target_C++
2824 Count_Pairs_Whose_Sum_is_Less_than_Target Two-pointers O(N * log(N)) O(1) Easy Python Count_Pairs_Whose_Sum_is_Less_than_Target_Python
C++ Count_Pairs_Whose_Sum_is_Less_than_Target_C++
2865 Beautiful_Towers_I Stack O((1 + (2*k)) * N) O(4 * N) Medium Python Beautiful_Towers_I_Python
C++ Beautiful_Towers_I_C++
2866 Beautiful_Towers_II Stack O((1 + (2*k)) * N) O(4 * N) Medium Python Beautiful_Towers_II_Python
C++ Beautiful_Towers_II_C++
2905 Find_Indices_With_Index_and_Value_Difference_II Two-pointers O(N) O(1) Medium Python Find_Indices_With_Index_and_Value_Difference_II_Python
C++ Find_Indices_With_Index_and_Value_Difference_II_C++
2965 Find_Missing_and_Repeated_Values 1-pass record ~ O(N) ~ O(N) Easy Python Find_Missing_and_Repeated_Values_Python
C++ Find_Missing_and_Repeated_Values_C++
3020 Find_the_Maximum_Number_of_Elements_in_Subset Greedy ~ O(N) O(N) Medium Python Find_the_Maximum_Number_of_Elements_in_Subset_Python
C++ Find_the_Maximum_Number_of_Elements_in_Subset_C++
3033 Modify_the_Matrix Greedy O(C * (R+k)) O(1) Easy Python Modify_the_Matrix_Python
C++ Modify_the_Matrix_C++
3065 Minimum_Operations_to_Exceed_Threshold_Value_I 1-pass compare ~ O(N) O(1) Easy Python Minimum_Operations_to_Exceed_Threshold_Value_I_Python
C++ Minimum_Operations_to_Exceed_Threshold_Value_I_C++
3066 Minimum_Operations_to_Exceed_Threshold_Value_II Heap/Priority-queue ~ O(N * Log(N)) ~ O(N) Medium Python Minimum_Operations_to_Exceed_Threshold_Value_II_Python
C++ Minimum_Operations_to_Exceed_Threshold_Value_II_C++
3071 Minimum_Operations_to_Write_the_Letter_Y_on_a_Grid Hashmap ~ O(N * N) O(N) Medium Python Minimum_Operations_to_Write_the_Letter_Y_on_a_Grid_Python
C++ Minimum_Operations_to_Write_the_Letter_Y_on_a_Grid_C++
3105 Longest_Strictly_Increasing_or_Strictly_Decreasing_Subarray Greedy O(2 * N) O(1) Easy Python Longest_Strictly_Increasing_or_Strictly_Decreasing_Subarray_Python
C++ Longest_Strictly_Increasing_or_Strictly_Decreasing_Subarray_C++
3128 Right_Triangles Hashmap O(2 * (R*C)) O(R + C) Medium Python Right_Triangles_Python
C++ Right_Triangles_C++
3142 Check_if_Grid_Satisfies_Conditions 1-pass record O(R * C) O(1) Easy Python Check_if_Grid_Satisfies_Conditions_Python
C++ Check_if_Grid_Satisfies_Conditions_C++
3151 Special_Array_I 1-pass update O(N) O(1) Easy Python Special_Array_I_Python
C++ Special_Array_I_C++
3158 Find_the_XOR_of_Numbers_Which_Appear_Twice Greedy O(N) O(1) Easy Python Find_the_XOR_of_Numbers_Which_Appear_Twice_Python
C++ Find_the_XOR_of_Numbers_Which_Appear_Twice_C++
3164 Find_the_Number_of_Good_Pairs_II Hashmap O(K * N) O(K) Medium Python Find_the_Number_of_Good_Pairs_II_Python
C++ Find_the_Number_of_Good_Pairs_II_C++
3192 Minimum_Operations_to_Make_Binary_Array_Elements_Equal_to_One_II Greedy O(N) O(1) Medium Python Minimum_Operations_to_Make_Binary_Array_Elements_Equal_to_One_II_Python
C++ Minimum_Operations_to_Make_Binary_Array_Elements_Equal_to_One_II_C++
3248 Snake_in_Matrix 1-pass update O(N) O(1) Easy Python Snake_in_Matrix_Python
C++ Snake_in_Matrix_C++
3286 Find_a_Safe_Walk_Through_a_Grid Dijkstras' ~ O((r*c) * Log(N)) O((R*C) + N + k) Medium Python Find_a_Safe_Walk_Through_a_Grid_Python
C++ Find_a_Safe_Walk_Through_a_Grid_C++
3289 The_Two_Sneaky_Numbers_of_Digitville Hashmap O(N) O(N) Easy Python The_Two_Sneaky_Numbers_of_Digitville_Python
C++ The_Two_Sneaky_Numbers_of_Digitville_C++
54 Spiral_Matrix Four-pointers O(N) O(N) Medium Python Spiral_Matrix_Python
C++ Spiral_Matrix_C++

Intermediate

Algorithms / Datastructures # Title Method Time-Complexity Spatial-Complexity Difficulty Languages Link
Depth_First_Search 79 Word_Search DFS O(k * (R*C)) O(k) Medium Python Word_Search_Python
C++ Word_Search_C++
129 Sum_Root_to_Leaf_Numbers DFS O(N) O(N) Medium Python Sum_Root_to_Leaf_Numbers_Python
C++ Sum_Root_to_Leaf_Numbers_C++
130 Surrounded_Regions DFS O(k * (R*C)) ~ O(k) Medium Python Surrounded_Regions_Python
C++ Surrounded_Regions_C++
200 Number_of_Islands DFS O(K * (R*C)) O(N) Medium Python Number_of_Islands_Python
C++ Number_of_Islands_C++
417 Pacific_Atlantic_Water_Flow DFS O(k * (R*C)) O(k * (R*C)) Medium Python Pacific_Atlantic_Water_Flow_Python
C++ Pacific_Atlantic_Water_Flow_C++
547 Number_of_Provinces DFS ~ O(R * C) O(R) Medium Python Number_of_Provinces_Python
C++ Number_of_Provinces_C++
695 Max_Area_of_Island DFS ~ O(k * (R*C)) ~ O(N) Medium Python Max_Area_of_Island_Python
C++ Max_Area_of_Island_C++
733 Flood_Fill DFS O(K * N) O(K * N) Easy Python Flood_Fill_Python
C++ Flood_Fill_C++
841 Keys_and_Rooms DFS O(N) O(N) Medium Python Keys_and_Rooms_Python
C++ Keys_and_Rooms_C++
947 Most_Stones_Removed_with_Same_Row_or_Column DFS O(K * N) ~ O(N) Medium Python Most_Stones_Removed_with_Same_Row_or_Column_Python
C++ Most_Stones_Removed_with_Same_Row_or_Column_C++
1034 Coloring_A_Border DFS O(K * (R*C)) O(k * (R*C)) Medium Python Coloring_A_Border_Python
C++ Coloring_A_Border_C++
1202 Smallest_String_With_Swaps DFS O((k + (2*Log(N))) * N) O(3 * N) Medium Python Smallest_String_With_Swaps_Python
C++ Smallest_String_With_Swaps_C++
1254 Number_of_Closed_Islands DFS O(K * (R*C)) O(N) Medium Python Number_of_Closed_Islands_Python
C++ Number_of_Closed_Islands_C++
1315 Sum_of_Nodes_with_Even-Valued_Grandparent DFS O(N) O(N) Medium Python Sum_of_Nodes_with_Even-Valued_Grandparent_Python
C++ Sum_of_Nodes_with_Even-Valued_Grandparent_C++
1367 Linked_List_in_Binary_Tree DFS O(k * N) ~ O(k * N) Medium Python Linked_List_in_Binary_Tree_Python
C++ Linked_List_in_Binary_Tree_C++
1376 Time_Needed_to_Inform_All_Employees DFS + BFS ~ O(k * N) ~ O(k * N) Medium Python Time_Needed_to_Inform_All_Employees_Python
C++ Time_Needed_to_Inform_All_Employees_C++
1443 Minimum_Time_to_Collect_All_Apples_in_a_Tree DFS O(K * N) O(k * N) Medium Python Minimum_Time_to_Collect_All_Apples_in_a_Tree_Python
C++ Minimum_Time_to_Collect_All_Apples_in_a_Tree_C++
1448 Count_Good_Nodes_in_Binary_Tree DFS O(N) ~ O(N) Medium Python Count_Good_Nodes_in_Binary_Tree_Python
C++ Count_Good_Nodes_in_Binary_Tree_C++
1466 Reorder_Routes_to_Make_All_Paths_Lead_to_the_City_Zero DFS O(k * N) O(k * N) Medium Python Reorder_Routes_to_Make_All_Paths_Lead_to_the_City_Zero_Python
C++ Reorder_Routes_to_Make_All_Paths_Lead_to_the_City_Zero_C++
1519 Number_of_Nodes_in_the_Sub-Tree_With_the_Same_Label DFS O(k * (N*N)) O(K * N) Medium Python Number_of_Nodes_in_the_Sub-Tree_With_the_Same_Label_Python
C++ Number_of_Nodes_in_the_Sub-Tree_With_the_Same_Label_C++
1530 Number_of_Good_Leaf_Nodes_Pairs DFS O(k * (N*N)) O(K * N) Medium Python Number_of_Good_Leaf_Nodes_Pairs_Python
C++ Number_of_Good_Leaf_Nodes_Pairs_C++
1559 Detect_Cycles_in_2D_Grid DFS ~ O(k * (N*N)) ~ O(k * (N*N)) Medium Python Detect_Cycles_in_2D_Grid_Python
C++ Detect_Cycles_in_2D_Grid_C++
1722 Minimize_Hamming_Distance_After_Swap_Operations DFS O(K * N) O(k * N) Medium Python Minimize_Hamming_Distance_After_Swap_Operations_Python
C++ Minimize_Hamming_Distance_After_Swap_Operations_C++
2368 Reachable_Nodes_With_Restrictions DFS O(k * N) ~ O(k * N) Medium Python Reachable_Nodes_With_Restrictions_Python
C++ Reachable_Nodes_With_Restrictions_C++
2477 Minimum_Fuel_Cost_to_Report_to_the_Capital DFS ~ O(k * N) ~ O(k * N) Medium Python Minimum_Fuel_Cost_to_Report_to_the_Capital_Python
C++ Minimum_Fuel_Cost_to_Report_to_the_Capital_C++
2658 Maximum_Number_of_Fish_in_a_Grid DFS O(k * (R*C)) O(k) Medium Python Maximum_Number_of_Fish_in_a_Grid_Python
C++ Maximum_Number_of_Fish_in_a_Grid_C++
3249 Count_the_Number_of_Good_Nodes DFS O(K * N) O(k * N) Medium Python Count_the_Number_of_Good_Nodes_Python
C++ Count_the_Number_of_Good_Nodes_C++
Breadth_First_Search 116 Populating_Next_Right_Pointers_in_Each_Node BFS O(K * N) O(2 * N) Medium Python Populating_Next_Right_Pointers_in_Each_Node_Python
C++ Populating_Next_Right_Pointers_in_Each_Node_C++
117 Populating_Next_Right_Pointers_in_Each_Node_II BFS O(K * N) O(2 * N) Medium Python Populating_Next_Right_Pointers_in_Each_Node_II_Python
C++ Populating_Next_Right_Pointers_in_Each_Node_II_C++
127 Word_Ladder BFS O(K * N) O(k * N) Medium Python Word_Ladder_Python
C++ Word_Ladder_C++
199 Binary_Tree_Right_Side_View BFS ~ O(N) ~ O(N) Medium Python Binary_Tree_Right_Side_View_Python
C++ Binary_Tree_Right_Side_View_C++
433 Minimum_Genetic_Mutation BFS O(k * N) O(k * N) Medium Python Minimum_Genetic_Mutation_Python
C++ Minimum_Genetic_Mutation_C++
463 Island_Perimeter BFS O(N * N) O(1) Easy Python Island_Perimeter_Python
C++ Island_Perimeter_C++
637 Average_of_Levels_in_Binary_Tree BFS O(N) O(N + H) Easy Python Average_of_Levels_in_Binary_Tree_Python
C++ Average_of_Levels_in_Binary_Tree_C++
752 Open_the_Lock BFS ~ O(k * (N*4)) O(K + N) Medium Python Open_the_Lock_Python
C++ Open_the_Lock_C++
802 Find_Eventual_Safe_States BFS O((K+Log(N)) * N) O(K * N) Medium Python Find_Eventual_Safe_States_Python
C++ Find_Eventual_Safe_States_C++
909 Snakes_and_Ladders BFS O(k * (N*N)) O(2 * N) Medium Python Snakes_and_Ladders_Python
C++ Snakes_and_Ladders_C++
967 Numbers_With_Same_Consecutive_Differences BFS O(N * N) O(k * N) Medium Python Numbers_With_Same_Consecutive_Differences_Python
C++ Numbers_With_Same_Consecutive_Differences_C++
994 Rotting_Oranges BFS O((R*C) + K) O(K + 4) Medium Python Rotting_Oranges_Python
C++ Rotting_Oranges_C++
1162 As_Far_from_Land_as_Possible BFS O(k * (R*C)) O(K * N) Medium Python As_Far_from_Land_as_Possible_Python
C++ As_Far_from_Land_as_Possible_C++
1306 Jump_Game_III BFS O(N) ~ O(2 * N) Medium Python Jump_Game_III_Python
C++ Jump_Game_III_C++
1361 Validate_Binary_Tree_Nodes BFS O((2*N) + K) O(N + K) Medium Python Validate_Binary_Tree_Nodes_Python
C++ Validate_Binary_Tree_Nodes_C++
1765 Map_of_Highest_Peak BFS O(k * (R*C)) O(k * (R*C)) Medium Python Map_of_Highest_Peak_Python
C++ Map_of_Highest_Peak_C++
1926 Nearest_Exit_from_Entrance_in_Maze BFS O(k * N) O(N + k) Medium Python Nearest_Exit_from_Entrance_in_Maze_Python
C++ Nearest_Exit_from_Entrance_in_Maze_C++
2146 K_Highest_Ranked_Items_Within_a_Price_Range BFS O(k * (N*Log(N)) + N) O((R * C) + (2*N)) Medium Python K_Highest_Ranked_Items_Within_a_Price_Range_Python
C++ K_Highest_Ranked_Items_Within_a_Price_Range_C++
Math 149 Max_Points_on_a_Line Hashmap O(N*N) O(N) Hard Python Max_Points_on_a_Line_Python
C++ Max_Points_on_a_Line_C++
343 Integer_Break Math O(K * N) O(1) Medium Python Integer_Break_Python
C++ Integer_Break_C++
367 Valid_Perfect_Square Binary-search O(Log(N)) O(1) Easy Python Valid_Perfect_Square_Python
C++ Valid_Perfect_Square_C++
398 Random_Pick_Index 1-pass record O(N) O(N) Medium Python Random_Pick_Index_Python
C++ Random_Pick_Index_C++
2165 Smallest_Value_of_the_Rearranged_Number Sorted operations O(k * N) O(N) Medium Python Smallest_Value_of_the_Rearranged_Number_Python
C++ Smallest_Value_of_the_Rearranged_Number_C++
2413 Smallest_Even_Multiple Math-GCD O(1) O(1) Easy Python Smallest_Even_Multiple_Python
C++ Smallest_Even_Multiple_C++
2582 Pass_the_Pillow Greedy O(1) O(1) Easy Python Pass_the_Pillow_Python
C++ Pass_the_Pillow_C++
3345 Smallest_Divisible_Digit_Product_I Greedy ~ O(N) O(1) Easy Python Smallest_Divisible_Digit_Product_I_Python
C++ Smallest_Divisible_Digit_Product_I_C++
Binary_Tree 94 Binary_Tree_Inorder_Traversal DFS O(N) ~ O(k * N) Easy Python Binary_Tree_Inorder_Traversal_Python
C++ Binary_Tree_Inorder_Traversal_C++
98 Validate_Binary_Search_Tree DFS O(N) O(N) Medium Python Validate_Binary_Search_Tree_Python
C++ Validate_Binary_Search_Tree_C++
100 Same_Tree BFS O(K + N) O(K + N) Easy Python Same_Tree_Python
C++ Same_Tree_C++
101 Symmetric_Tree DFS ~ O(N) ~ O(k * N) Easy Python Symmetric_Tree_Python
C++ Symmetric_Tree_C++
102 Binary_Tree_Level_Order_Traversal BFS O(N) ~ O(k * N) Medium Python Binary_Tree_Level_Order_Traversal_Python
C++ Binary_Tree_Level_Order_Traversal_C++
104 Maximum Depth of Binary Tree DFS ~ O(N) ~ O(N) Easy Python Maximum Depth of Binary Tree_Python
C++ Maximum Depth of Binary Tree_C++
107 Binary_Tree_Level_Order_Traversal_II BFS O(N) O(2 * N) Medium Python Binary_Tree_Level_Order_Traversal_II_Python
C++ Binary_Tree_Level_Order_Traversal_II_C++
110 Balanced_Binary_Tree DFS O(N) O(N) Easy Python Balanced_Binary_Tree_Python
C++ Balanced_Binary_Tree_C++
111 Minimum_Depth_of_Binary_Tree DFS O(N) O(N) Easy Python Minimum_Depth_of_Binary_Tree_Python
C++ Minimum_Depth_of_Binary_Tree_C++
112 Path_Sum DFS O(N) O(N) Easy Python Path_Sum_Python
C++ Path_Sum_C++
113 Path_Sum_II DFS O(N) ~ O(k * N) Medium Python Path_Sum_II_Python
C++ Path_Sum_II_C++
114 Flatten_Binary_Tree_to_Linked_List DFS O(2 * N) ~ O(k * N) Medium Python Flatten_Binary_Tree_to_Linked_List_Python
C++ Flatten_Binary_Tree_to_Linked_List_C++
124 Binary_Tree_Maximum_Path_Sum DFS O(N) O(N) Hard Python Binary_Tree_Maximum_Path_Sum_Python
C++ Binary_Tree_Maximum_Path_Sum_C++
144 Binary_Tree_Preorder_Traversal DFS O(N) ~ O(k * N) Easy Python Binary_Tree_Preorder_Traversal_Python
C++ Binary_Tree_Preorder_Traversal_C++
145 Binary_Tree_Postorder_Traversal DFS O(N) ~ O(k * N) Easy Python Binary_Tree_Postorder_Traversal_Python
C++ Binary_Tree_Postorder_Traversal_C++
222 Count_Complete_Tree_Nodes Queue O(N) O(N) Easy Python Count_Complete_Tree_Nodes_Python
C++ Count_Complete_Tree_Nodes_C++
226 Invert_Binary_Tree DFS O(N) ~ O(k * N) Easy Python Invert_Binary_Tree_Python
C++ Invert_Binary_Tree_C++
236 Lowest_Common_Ancestor_of_a_Binary_Tree DFS O(N) O(N) Medium Python Lowest_Common_Ancestor_of_a_Binary_Tree_Python
C++ Lowest_Common_Ancestor_of_a_Binary_Tree_C++
257 Binary_Tree_Paths DFS O(N) O(N) Easy Python Binary_Tree_Paths_Python
C++ Binary_Tree_Paths_C++
337 House_Robber_III DFS O(N) ~ O(k * N) Medium Python House_Robber_III_Python
C++ House_Robber_III_C++
404 Sum_of_Left_Leaves BFS O(N) O(N) Easy Python Sum_of_Left_Leaves_Python
C++ Sum_of_Left_Leaves_C++
437 Path_Sum_III DFS O(N) O(N) Medium Python Path_Sum_III_Python
C++ Path_Sum_III_C++
508 Most_Frequent_Subtree_Sum DFS O(N + K) O(K + k) Medium Python Most_Frequent_Subtree_Sum_Python
C++ Most_Frequent_Subtree_Sum_C++
513 Find_Bottom_Left_Tree_Value BFS O(N) O(N) Medium Python Find_Bottom_Left_Tree_Value_Python
C++ Find_Bottom_Left_Tree_Value_C++
515 Find_Largest_Value_in_Each_Tree_Row BFS O(N) O(N) Medium Python Find_Largest_Value_in_Each_Tree_Row_Python
C++ Find_Largest_Value_in_Each_Tree_Row_C++
543 Diameter_of_Binary_Tree DFS O(N) O(N) Easy Python Diameter_of_Binary_Tree_Python
C++ Diameter_of_Binary_Tree_C++
654 Maximum_Binary_Tree Deque O(k * N) O(N) Medium Python Maximum_Binary_Tree_Python
C++ Maximum_Binary_Tree_C++
700 Search_in_a_Binary_Search_Tree Recursion O(N) O(N) Easy Python Search_in_a_Binary_Search_Tree_Python
C++ Search_in_a_Binary_Search_Tree_C++
872 Leaf-Similar_Trees DFS O(2 * N) O(2 * N) Easy Python Leaf-Similar_Trees_Python
C++ Leaf-Similar_Trees_C++
998 Maximum_Binary_Tree_II Recursion ~ O(N) ~ O(N) Medium Python Maximum_Binary_Tree_II_Python
C++ Maximum_Binary_Tree_II_C++
1080 Insufficient_Nodes_in_Root_to_Leaf_Paths DFS O(N) ~ O(k * N) Medium Python Insufficient_Nodes_in_Root_to_Leaf_Paths_Python
C++ Insufficient_Nodes_in_Root_to_Leaf_Paths_C++
1161 Maximum_Level_Sum_of_a_Binary_Tree DFS O(k * N) O(N) Medium Python Maximum_Level_Sum_of_a_Binary_Tree_Python
C++ Maximum_Level_Sum_of_a_Binary_Tree_C++
1325 Delete_Leaves_With_a_Given_Value DFS O(N) ~ O(k * N) Medium Python Delete_Leaves_With_a_Given_Value_Python
C++ Delete_Leaves_With_a_Given_Value_C++
1372 Longest_ZigZag_Path_in_a_Binary_Tree DFS O(N) ~ O(k * N) Medium Python Longest_ZigZag_Path_in_a_Binary_Tree_Python
C++ Longest_ZigZag_Path_in_a_Binary_Tree_C++
1382 Balance_a_Binary_Search_Tree DFS ~ O(2 * N) ~ O(k * N) Medium Python Balance_a_Binary_Search_Tree_Python
C++ Balance_a_Binary_Search_Tree_C++
1609 Even_Odd_Tree BFS O(N) O(N) Medium Python Even_Odd_Tree_Python
C++ Even_Odd_Tree_C++
2331 Evaluate_Boolean_Binary_Tree DFS O(N) ~ O(k * N) Easy Python Evaluate_Boolean_Binary_Tree_Python
C++ Evaluate_Boolean_Binary_Tree_C++
2385 Amount_of_Time_for_Binary_Tree_to_Be_Infected DFS O(N) ~ O(k * N) Medium Python Amount_of_Time_for_Binary_Tree_to_Be_Infected_Python
C++ Amount_of_Time_for_Binary_Tree_to_Be_Infected_C++
2458 Height_of_Binary_Tree_After_Subtree_Removal_Queries DFS O((2*N) + K) O((2*N) + K) Hard Python Height_of_Binary_Tree_After_Subtree_Removal_Queries_Python
C++ Height_of_Binary_Tree_After_Subtree_Removal_Queries_C++
2673 Make_Costs_of_Paths_Equal_in_a_Binary_Tree Recursion O(N) O(log(N)) Medium Python Make_Costs_of_Paths_Equal_in_a_Binary_Tree_Python
C++ Make_Costs_of_Paths_Equal_in_a_Binary_Tree_C++
3319 K-th_Largest_Perfect_Subtree_Size_in_Binary_Tree DFS O(N) ~ O(k * N) Medium Python K-th_Largest_Perfect_Subtree_Size_in_Binary_Tree_Python
C++ K-th_Largest_Perfect_Subtree_Size_in_Binary_Tree_C++
Binary_Search_Tree 99 Recover_Binary_Search_Tree Stack O(N) O(N) Medium Python Recover_Binary_Search_Tree_Python
C++ Recover_Binary_Search_Tree_C++
108 Convert_Sorted_Array_to_Binary_Search_Tree Recursion O(Log(N)) ~ O(k * Log(N)) Easy Python Convert_Sorted_Array_to_Binary_Search_Tree_Python
C++ Convert_Sorted_Array_to_Binary_Search_Tree_C++
173 Binary_Search_Tree_Iterator Stack O(N) O(N) Medium Python Binary_Search_Tree_Iterator_Python
C++ Binary_Search_Tree_Iterator_C++
230 Kth_Smallest_Element_in_a_BST Stack ~ O(k * N) ~ O(k * N) Medium Python Kth_Smallest_Element_in_a_BST_Python
C++ Kth_Smallest_Element_in_a_BST_C++
235 Lowest_Common_Ancestor_of_a_Binary_Search_Tree Binary-search O(Log(N)) O(1) Medium Python Lowest_Common_Ancestor_of_a_Binary_Search_Tree_Python
C++ Lowest_Common_Ancestor_of_a_Binary_Search_Tree_C++
450 Delete_Node_in_a_BST Recursion ~ O(k * Log(N)) ~ O(k * Log(N)) Medium Python Delete_Node_in_a_BST_Python
C++ Delete_Node_in_a_BST_C++
530 Minimum_Absolute_Difference_in_BST DFS O(2 * N) O(N) Easy Python Minimum_Absolute_Difference_in_BST_Python
C++ Minimum_Absolute_Difference_in_BST_C++
538 Convert_BST_to_Greater_Tree DFS O(N) O(N) Medium Python Convert_BST_to_Greater_Tree_Python
C++ Convert_BST_to_Greater_Tree_C++
669 Trim_a_Binary_Search_Tree DFS O(N) O(N) Medium Python Trim_a_Binary_Search_Tree_Python
C++ Trim_a_Binary_Search_Tree_C++
701 Insert_into_a_Binary_Search_Tree Recursion O(Log(N)) O(3 * Log(N)) Medium Python Insert_into_a_Binary_Search_Tree_Python
C++ Insert_into_a_Binary_Search_Tree_C++
Binary_Search 33 Search_in_Rotated_Sorted_Array Binary-search O(Log(N)) O(1) Medium Python Search_in_Rotated_Sorted_Array_Python
C++ Search_in_Rotated_Sorted_Array_C++
34 Find_First_and_Last_Position_of_Element_in_Sorted_Array Binary-search O(Log(N) + k) O(1) Medium Python Find_First_and_Last_Position_of_Element_in_Sorted_Array_Python
C++ Find_First_and_Last_Position_of_Element_in_Sorted_Array_C++
35 Search_Insert_Position Binary-search O(Log(N)) O(1) Easy Python Search_Insert_Position_Python
C++ Search_Insert_Position_C++
74 Search_a_2D_Matrix Binary-search O(Log(R * C)) O(1) Medium Python Search_a_2D_Matrix_Python
C++ Search_a_2D_Matrix_C++
153 Find_Minimum_in_Rotated_Sorted_Array Binary-search O(Log(N)) O(1) Medium Python Find_Minimum_in_Rotated_Sorted_Array_Python
C++ Find_Minimum_in_Rotated_Sorted_Array_C++
162 Find_Peak_Element Binary-search O(Log(N)) O(1) Medium Python Find_Peak_Element_Python
C++ Find_Peak_Element_C++
278 First_Bad_Version Binary-search O(Log(N)) O(1) Easy Python First_Bad_Version_Python
C++ First_Bad_Version_C++
300 Longest_Increasing_Subsequence Binary-search O(N * Log(N)) O(N) Medium Python Longest_Increasing_Subsequence_Python
C++ Longest_Increasing_Subsequence_C++
374 Guess_Number_Higher_or_Lower Binary-search O(Log(N)) O(1) Easy Python Guess_Number_Higher_or_Lower_Python
C++ Guess_Number_Higher_or_Lower_C++
436 Find_Right_Interval Binary-search ~ O(N * Log(N)) O(4 * N) Medium Python Find_Right_Interval_Python
C++ Find_Right_Interval_C++
441 Arranging_Coins Binary-search O(Log(N)) O(1) Easy Python Arranging_Coins_Python
C++ Arranging_Coins_C++
475 Heaters Binary-search O(N * Log(N)) O(1) Medium Python Heaters_Python
C++ Heaters_C++
528 Random_Pick_with_Weight Binary-search O(Log(N)) O(N) Medium Python Random_Pick_with_Weight_Python
C++ Random_Pick_with_Weight_C++
719 Find_K-th_Smallest_Pair_Distance Binary-search O((k*N) * Log(N)) O(1) Hard Python Find_K-th_Smallest_Pair_Distance_Python
C++ Find_K-th_Smallest_Pair_Distance_C++
744 Find_Smallest_Letter_Greater_Than_Target Binary-search O(Log(N)) O(1) Easy Python Find_Smallest_Letter_Greater_Than_Target_Python
C++ Find_Smallest_Letter_Greater_Than_Target_C++
778 Swim_in_Rising_Water Binary-search ~ O((R*C) * Log(N)) O(1) Hard Python Swim_in_Rising_Water_Python
C++ Swim_in_Rising_Water_C++
852 Peak_Index_in_a_Mountain_Array Binary-search O(Log(N)) O(1) Medium Python Peak_Index_in_a_Mountain_Array_Python
C++ Peak_Index_in_a_Mountain_Array_C++
875 Koko_Eating_Bananas Binary-search O(N * Log(N)) O(1) Medium Python Koko_Eating_Bananas_Python
C++ Koko_Eating_Bananas_C++
911 Online_Election Binary-search O((1+Log(N)) * N) O((2*N) + k) Medium Python Online_Election_Python
C++ Online_Election_C++
1283 Find_the_Smallest_Divisor_Given_a_Threshold Binary-search O(N * Log(N)) O(1) Medium Python Find_the_Smallest_Divisor_Given_a_Threshold_Python
C++ Find_the_Smallest_Divisor_Given_a_Threshold_C++
1292 Maximum_Side_Length_of_a_Square_with_Sum_Less_than_or_Equal_to_Threshold Binary-search O((1+Log(N)) * (R*C)) O(1) Medium Python Maximum_Side_Length_of_a_Square_with_Sum_Less_than_or_Equal_to_Threshold_Python
C++ Maximum_Side_Length_of_a_Square_with_Sum_Less_than_or_Equal_to_Threshold_C++
1300 Sum_of_Mutated_Array_Closest_to_Target Binary-search O(N * Log(N)) O(1) Medium Python Sum_of_Mutated_Array_Closest_to_Target_Python
C++ Sum_of_Mutated_Array_Closest_to_Target_C++
1631 Path_With_Minimum_Effort Binary-search ~ O((R*C) * Log(N)) O(1) Medium Python Path_With_Minimum_Effort_Python
C++ Path_With_Minimum_Effort_C++
1648 Sell_Diminishing-Valued_Colored_Balls Binary-search O((1 + (2*Log(N))) * N) O(1) Medium Python Sell_Diminishing-Valued_Colored_Balls_Python
C++ Sell_Diminishing-Valued_Colored_Balls_C++
1760 Minimum_Limit_of_Balls_in_a_Bag Binary-search O(Log(N)) O(1) Medium Python Minimum_Limit_of_Balls_in_a_Bag_Python
C++ Minimum_Limit_of_Balls_in_a_Bag_C++
1818 Minimum_Absolute_Sum_Difference Binary-search O((1 + (2*Log(N))) * N) O(N) Medium Python Minimum_Absolute_Sum_Difference_Python
C++ Minimum_Absolute_Sum_Difference_C++
1855 Maximum_Distance_Between_a_Pair_of_Values Binary-search O(N * Log(N)) O(1) Medium Python Maximum_Distance_Between_a_Pair_of_Values_Python
C++ Maximum_Distance_Between_a_Pair_of_Values_C++
1901 Find_a_Peak_Element_II Binary-search O(N * Log(N)) O(1) Medium Python Find_a_Peak_Element_II_Python
C++ Find_a_Peak_Element_II_C++
2055 Plates_Between_Candles Binary-search O(N + (K * (2*Log(M)))) O(N + K) Medium Python Plates_Between_Candles_Python
C++ Plates_Between_Candles_C++
2226 Maximum_Candies_Allocated_to_K_Children Binary-search O(N * Log(N)) O(1) Medium Python Maximum_Candies_Allocated_to_K_Children_Python
C++ Maximum_Candies_Allocated_to_K_Children_C++
2271 Maximum_White_Tiles_Covered_by_a_Carpet Binary-search O(N + (K*Log(N))) O(N) Medium Python Maximum_White_Tiles_Covered_by_a_Carpet_Python
C++ Maximum_White_Tiles_Covered_by_a_Carpet_C++
2300 Successful_Pairs_of_Spells_and_Potions Binary-search O(K * Log(N)) O(N) Medium Python Successful_Pairs_of_Spells_and_Potions_Python
C++ Successful_Pairs_of_Spells_and_Potions_C++
2333 Minimum_Sum_of_Squared_Difference Binary-search O(N * (4 + (2*Log(N)))) O(1) Medium Python Minimum_Sum_of_Squared_Difference_Python
C++ Minimum_Sum_of_Squared_Difference_C++
2398 Maximum_Number_of_Robots_Within_Budget Binary-search O(N * (k+Log(N))) O(N) Hard Python Maximum_Number_of_Robots_Within_Budget_Python
C++ Maximum_Number_of_Robots_Within_Budget_C++
2560 House_Robber_IV Binary-search O(N * Log(N)) O(N) Medium Python House_Robber_IV_Python
C++ House_Robber_IV_C++
2602 Minimum_Operations_to_Make_All_Array_Elements_Equal Binary-search O(N * Log(N)) O(2 * N) Medium Python Minimum_Operations_to_Make_All_Array_Elements_Equal_Python
C++ Minimum_Operations_to_Make_All_Array_Elements_Equal_C++
2812 Find_the_Safest_Path_in_a_Grid Binary-search O((2+Log(N)) * (N*N)) O(N * N) Medium Python Find_the_Safest_Path_in_a_Grid_Python
C++ Find_the_Safest_Path_in_a_Grid_C++
2981 Find_Longest_Special_Substring_That_Occurs_Thrice_I Binary-search O((N + (K*N)) * Log(N)) O(N) Medium Python Find_Longest_Special_Substring_That_Occurs_Thrice_I_Python
C++ Find_Longest_Special_Substring_That_Occurs_Thrice_I_C++
3134 Find_the_Median_of_the_Uniqueness_Array Binary-search O(K * (N*Log(N))) O(N) Hard Python Find_the_Median_of_the_Uniqueness_Array_Python
C++ Find_the_Median_of_the_Uniqueness_Array_C++
3281 Maximize_Score_of_Numbers_in_Ranges Binary-search O(N * Log(N)) O(1) Medium Python Maximize_Score_of_Numbers_in_Ranges_Python
C++ Maximize_Score_of_Numbers_in_Ranges_C++
Greedy 45 Jump_Game_II Greedy O(N) O(1) Medium Python Jump_Game_II_Python
C++ Jump_Game_II_C++
128 Longest_Consecutive_Sequence Greedy O(2 * N) O(N) Medium Python Longest_Consecutive_Sequence_Python
C++ Longest_Consecutive_Sequence_C++
134 Gas_Station Greedy O(N) O(1) Medium Python Gas_Station_Python
C++ Gas_Station_C++
137 Single_Number_II Greedy O(N) O(1) Medium Python Single_Number_II_Python
C++ Single_Number_II_C++
334 Increasing_Triplet_Subsequence Greedy O(N) O(1) Medium Python Increasing_Triplet_Subsequence_Python
C++ Increasing_Triplet_Subsequence_C++
435 Non-overlapping_Intervals Greedy O((1+Log(N)) * N) O(1) Medium Python Non-overlapping_Intervals_Python
C++ Non-overlapping_Intervals_C++
452 Minimum_Number_of_Arrows_to_Burst_Balloons Greedy O(N) O(1) Medium Python Minimum_Number_of_Arrows_to_Burst_Balloons_Python
C++ Minimum_Number_of_Arrows_to_Burst_Balloons_C++
502 IPO Greedy O(k * (N * Log(N))) O(2 * N) Hard Python IPO_Python
C++ IPO_C++
605 Can_Place_Flowers Greedy O(N) O(1) Easy Python Can_Place_Flowers_Python
C++ Can_Place_Flowers_C++
621 Task_Scheduler Greedy O(2 * N) O(N) Medium Python Task_Scheduler_Python
C++ Task_Scheduler_C++
624 Maximum_Distance_in_Arrays Greedy O(2 * N) O(1) Medium Python Maximum_Distance_in_Arrays_Python
C++ Maximum_Distance_in_Arrays_C++
630 Course_Schedule_III Heap/Priority-queue O(N * Log(N)) O(N) Hard Python Course_Schedule_III_Python
C++ Course_Schedule_III_C++
767 Reorganize_String Greedy O(N * (k+Log(N))) O(k + N) Medium Python Reorganize_String_Python
C++ Reorganize_String_C++
781 Rabbits_in_Forest Greedy O(N + k) O(k) Medium Python Rabbits_in_Forest_Python
C++ Rabbits_in_Forest_C++
1024 Video_Stitching Greedy O(N * (1+Log(N))) O(1) Medium Python Video_Stitching_Python
C++ Video_Stitching_C++
1144 Decrease_Elements_To_Make_Array_Zigzag Greedy O(2 * N) O(N) Medium Python Decrease_Elements_To_Make_Array_Zigzag_Python
C++ Decrease_Elements_To_Make_Array_Zigzag_C++
1386 Cinema_Seat_Allocation Greedy O(N * N) O(k * N) Medium Python Cinema_Seat_Allocation_Python
C++ Cinema_Seat_Allocation_C++
1402 Reducing_Dishes Greedy O((K+Log(N)) * N) O(1) Hard Python Reducing_Dishes_Python
C++ Reducing_Dishes_C++
1488 Avoid_Flood_in_The_City Greedy O(K * Log(N)) O(3 * N) Medium Python Avoid_Flood_in_The_City_Python
C++ Avoid_Flood_in_The_City_C++
1503 Last_Moment_Before_All_Ants_Fall_Out_of_a_Plank Greedy O((2*N) * Log(N)) O(1) Medium Python Last_Moment_Before_All_Ants_Fall_Out_of_a_Plank_Python
C++ Last_Moment_Before_All_Ants_Fall_Out_of_a_Plank_C++
1798 Maximum_Number_of_Consecutive_Values_You_Can_Make Greedy O((1+Log(N)) * N) O(1) Medium Python Maximum_Number_of_Consecutive_Values_You_Can_Make_Python
C++ Maximum_Number_of_Consecutive_Values_You_Can_Make_C++
2126 Destroying_Asteroids Greedy O((1+Log(N)) * N) O(N) Medium Python Destroying_Asteroids_Python
C++ Destroying_Asteroids_C++
2141 Maximum_Running_Time_of_N_Computers Greedy O((2+Log(N)) * N) O(1) Hard Python Maximum_Running_Time_of_N_Computers_Python
C++ Maximum_Running_Time_of_N_Computers_C++
2202 Maximize_the_Topmost_Element_After_K_Moves Greedy O(N) O(1) Medium Python Maximize_the_Topmost_Element_After_K_Moves_Python
C++ Maximize_the_Topmost_Element_After_K_Moves_C++
2259 Remove_Digit_From_Number_to_Maximize_Result Greedy O(N + (N*Log(N))) O(N) Easy Python Remove_Digit_From_Number_to_Maximize_Result_Python
C++ Remove_Digit_From_Number_to_Maximize_Result_C++
2285 Maximum_Total_Importance_of_Roads Greedy ~ O(k * N) O(N) Medium Python Maximum_Total_Importance_of_Roads_Python
C++ Maximum_Total_Importance_of_Roads_C++
2294 Partition_Array_Such_That_Maximum_Difference_Is_K Greedy O((1+Log(N)) * N) O(1) Medium Python Partition_Array_Such_That_Maximum_Difference_Is_K_Python
C++ Partition_Array_Such_That_Maximum_Difference_Is_K_C++
2497 Maximum_Star_Sum_of_a_Graph Greedy O(k * N) O(N) Medium Python Maximum_Star_Sum_of_a_Graph_Python
C++ Maximum_Star_Sum_of_a_Graph_C++
2498 Frog_Jump_II Greedy O(2 * Log(N)) O(1) Medium Python Frog_Jump_II_Python
C++ Frog_Jump_II_C++
2567 Minimum_Score_by_Changing_Two_Elements Greedy O(N * Log(N)) O(1) Medium Python Minimum_Score_by_Changing_Two_Elements_Python
C++ Minimum_Score_by_Changing_Two_Elements_C++
2870 Minimum_Number_of_Operations_to_Make_Array_Empty Greedy O(2 * N) O(N) Medium Python Minimum_Number_of_Operations_to_Make_Array_Empty_Python
C++ Minimum_Number_of_Operations_to_Make_Array_Empty_C++
3107 Minimum_Operations_to_Make_Median_of_Array_Equal_to_K Greedy O((1+Log(N)) * N) O(1) Medium Python Minimum_Operations_to_Make_Median_of_Array_Equal_to_K_Python
C++ Minimum_Operations_to_Make_Median_of_Array_Equal_to_K_C++
3201 Find_the_Maximum_Length_of_Valid_Subsequence_I Greedy O(3 * N) O(1) Medium Python Find_the_Maximum_Length_of_Valid_Subsequence_I_Python
C++ Find_the_Maximum_Length_of_Valid_Subsequence_I_C++
3228 Maximum_Number_of_Operations_to_Move_Ones_to_the_End Greedy O(N) O(1) Medium Python Maximum_Number_of_Operations_to_Move_Ones_to_the_End_Python
C++ Maximum_Number_of_Operations_to_Move_Ones_to_the_End_C++
3397 Maximum_Number_of_Distinct_Elements_After_Operations Greedy O((1+Log(N)) * N) O(1) Medium Python Maximum_Number_of_Distinct_Elements_After_Operations_Python
C++ Maximum_Number_of_Distinct_Elements_After_Operations_C++
3487 Maximum_Unique_Subarray_Sum_After_Deletion Greedy O(N) O(N) Easy Python Maximum_Unique_Subarray_Sum_After_Deletion_Python
C++ Maximum_Unique_Subarray_Sum_After_Deletion_C++
3507 Minimum_Pair_Removal_to_Sort_Array_I Greedy O(N * (2*N)) O(1) Easy Python Minimum_Pair_Removal_to_Sort_Array_I_Python
C++ Minimum_Pair_Removal_to_Sort_Array_I_C++
Graph 133 Clone_Graph DFS O(k * N) O(k * N) Medium Python Clone_Graph_Python
C++ Clone_Graph_C++
207 Course_Schedule BFS O(k * (N*N)) O(K * N) Medium Python Course_Schedule_Python
C++ Course_Schedule_C++
210 Course_Schedule_II BFS O(k * (N*N)) O(K * N) Medium Python Course_Schedule_II_Python
C++ Course_Schedule_II_C++
310 Minimum_Height_Trees Greedy O(K * N) O(K * N) Medium Python Minimum_Height_Trees_Python
C++ Minimum_Height_Trees_C++
684 Redundant_Connection Disjoint-set O(k + N) O(2 * N) Medium Python Redundant_Connection_Python
C++ Redundant_Connection_C++
743 Network_Delay_Time Dijkstras' O(N + (K*Log(K))) O((4 * N) + (2 * K)) Medium Python Network_Delay_Time_Python
C++ Network_Delay_Time_C++
785 Is_Graph_Bipartite? BFS O(k * N) O(k * N) Medium Python Is_Graph_Bipartite?_Python
C++ Is_Graph_Bipartite?_C++
787 Cheapest_Flights_Within_K_Stops Dijkstras' ~O(E * Log(N)) O((3 * N) + (2 * K)) Medium Python Cheapest_Flights_Within_K_Stops_Python
C++ Cheapest_Flights_Within_K_Stops_C++
797 All_Paths_From_Source_to_Target DFS O(N) O(K * N) Medium Python All_Paths_From_Source_to_Target_Python
C++ All_Paths_From_Source_to_Target_C++
851 Loud_and_Rich BFS O(K * N) O(K * N) Medium Python Loud_and_Rich_Python
C++ Loud_and_Rich_C++
886 Possible_Bipartition BFS O((1+k) * N) O(3 * N) Medium Python Possible_Bipartition_Python
C++ Possible_Bipartition_C++
1042 Flower_Planting_With_No_Adjacent Greedy O((1 + (k+4)) * N) O((1+k) * N) Medium Python Flower_Planting_With_No_Adjacent_Python
C++ Flower_Planting_With_No_Adjacent_C++
1129 Shortest_Path_with_Alternating_Colors BFS O(K * N) O(K * N) Medium Python Shortest_Path_with_Alternating_Colors_Python
C++ Shortest_Path_with_Alternating_Colors_C++
1319 Number_of_Operations_to_Make_Network_Connected Graph O(K + (k*N)) O((2*K) + N) Medium Python Number_of_Operations_to_Make_Network_Connected_Python
C++ Number_of_Operations_to_Make_Network_Connected_C++
1334 Find_the_City_With_the_Smallest_Number_of_Neighbors_at_a_Threshold_Distance Dijkstras' ~ O((N + (K*Log(K))) * N) O(2 * K) Medium Python Find_the_City_With_the_Smallest_Number_of_Neighbors_at_a_Threshold_Distance_Python
C++ Find_the_City_With_the_Smallest_Number_of_Neighbors_at_a_Threshold_Distance_C++
1368 Minimum_Cost_to_Make_at_Least_One_Valid_Path_in_a_Grid Dijkstras' O((r*c) * Log(N)) O((R* C) + (r*c)) Hard Python Minimum_Cost_to_Make_at_Least_One_Valid_Path_in_a_Grid_Python
C++ Minimum_Cost_to_Make_at_Least_One_Valid_Path_in_a_Grid_C++
1377 Frog_Position_After_T_Seconds BFS O(K + (k*N)) O(k * N) Hard Python Frog_Position_After_T_Seconds_Python
C++ Frog_Position_After_T_Seconds_C++
1514 Path_with_Maximum_Probability Dijkstras' O((N * Log(N)) + E) O(K * N) Medium Python Path_with_Maximum_Probability_Python
C++ Path_with_Maximum_Probability_C++
1584 Min_Cost_to_Connect_All_Points Kruskals' O((N*(Log(N))) + E) O(K * N) Medium Python Min_Cost_to_Connect_All_Points_Python
C++ Min_Cost_to_Connect_All_Points_C++
1557 Minimum_Number_of_Vertices_to_Reach_All_Nodes Greedy O(2 * N) O(2 * N) Medium Python Minimum_Number_of_Vertices_to_Reach_All_Nodes_Python
C++ Minimum_Number_of_Vertices_to_Reach_All_Nodes_C++
1791 Find_Center_of_Star_Graph 1-pass record O(N) O(N) Easy Python Find_Center_of_Star_Graph_Python
C++ Find_Center_of_Star_Graph_C++
1857 Largest_Color_Value_in_a_Directed_Graph BFS O((k*N) + (26 * E)) O((28+k) * N) Hard Python Largest_Color_Value_in_a_Directed_Graph_Python
C++ Largest_Color_Value_in_a_Directed_Graph_C++
1928 Minimum_Cost_to_Reach_Destination_in_Time Dijkstras' ~O(N * Log(N)) O((2*K) + (3 *N)) Hard Python Minimum_Cost_to_Reach_Destination_in_Time_Python
C++ Minimum_Cost_to_Reach_Destination_in_Time_C++
1971 Find_if_Path_Exists_in_Graph DFS O(N + E) O((k+1) * N) Easy Python Find_if_Path_Exists_in_Graph_Python
C++ Find_if_Path_Exists_in_Graph_C++
1976 Number_of_Ways_to_Arrive_at_Destination Dijkstras' O((N * Log(N)) + E) O(K * N) Medium Python Number_of_Ways_to_Arrive_at_Destination_Python
C++ Number_of_Ways_to_Arrive_at_Destination_C++
2050 Parallel_Courses_III BFS ~ O(K * (N*N)) O(K * N) Hard Python Parallel_Courses_III_Python
C++ Parallel_Courses_III_C++
2097 Valid_Arrangement_of_Pairs Stack O(k * N) O(k * N) Hard Python Valid_Arrangement_of_Pairs_Python
C++ Valid_Arrangement_of_Pairs_C++
2115 Find_All_Possible_Recipes_from_Given_Supplies BFS O(K * N) O(K * N) Medium Python Find_All_Possible_Recipes_from_Given_Supplies_Python
C++ Find_All_Possible_Recipes_from_Given_Supplies_C++
2359 Find_Closest_Node_to_Given_Two_Nodes BFS O(k * N) O(k * N) Medium Python Find_Closest_Node_to_Given_Two_Nodes_Python
C++ Find_Closest_Node_to_Given_Two_Nodes_C++
2360 Longest_Cycle_in_a_Graph DFS O(k * N) O(k * N) Hard Python Longest_Cycle_in_a_Graph_Python
C++ Longest_Cycle_in_a_Graph_C++
2374 Node_With_Highest_Edge_Score Greedy O(2 * N) O(N) Medium Python Node_With_Highest_Edge_Score_Python
C++ Node_With_Highest_Edge_Score_C++
2392 Build_a_Matrix_With_Conditions BFS O(K * N) O(K * N) Hard Python Build_a_Matrix_With_Conditions_Python
C++ Build_a_Matrix_With_Conditions_C++
2493 Divide_Nodes_Into_the_Maximum_Number_of_Groups BFS O(K * N) O(K * N) Hard Python Divide_Nodes_Into_the_Maximum_Number_of_Groups_Python
C++ Divide_Nodes_Into_the_Maximum_Number_of_Groups_C++
2577 Minimum_Time_to_Visit_a_Cell_In_a_Grid Dijkstras' O((R* C) * Log((R*C)) ~ O(2 * (R*C)) Hard Python Minimum_Time_to_Visit_a_Cell_In_a_Grid_Python
C++ Minimum_Time_to_Visit_a_Cell_In_a_Grid_C++
2608 Shortest_Cycle_in_a_Graph BFS O(K * N) O(K * N) Hard Python Shortest_Cycle_in_a_Graph_Python
C++ Shortest_Cycle_in_a_Graph_C++
2685 Count_the_Number_of_Complete_Components DFS O(K * N) O(K * N) Medium Python Count_the_Number_of_Complete_Components_Python
C++ Count_the_Number_of_Complete_Components_C++
2858 Minimum_Edge_Reversals_So_Every_Node_Is_Reachable BFS O(K * N) O(k * N) Hard Python Minimum_Edge_Reversals_So_Every_Node_Is_Reachable_Python
C++ Minimum_Edge_Reversals_So_Every_Node_Is_Reachable_C++
3015 Count_the_Number_of_Houses_at_a_Certain_Distance_I Minimun path-sum O(K * N) O(N) Medium Python Count_the_Number_of_Houses_at_a_Certain_Distance_I_Python
C++ Count_the_Number_of_Houses_at_a_Certain_Distance_I_C++
3112 Minimum_Time_to_Visit_Disappearing_Nodes Dijkstras' O(K + ((k*N) * Log(N))) O((2*K) + (3 *N)) Medium Python Minimum_Time_to_Visit_Disappearing_Nodes_Python
C++ Minimum_Time_to_Visit_Disappearing_Nodes_C++
3341 Find_Minimum_Time_to_Reach_Last_Room_I Dijkstras' ~ O((k * (R*C)) * Log(N)) ~ O(((k+1) * (R*C))) Medium Python Find_Minimum_Time_to_Reach_Last_Room_I_Python
C++ Find_Minimum_Time_to_Reach_Last_Room_I_C++
3342 Find_Minimum_Time_to_Reach_Last_Room_II Dijkstras' O((R* C) * Log((R*C)) ~ O(2 * (R*C)) Medium Python Find_Minimum_Time_to_Reach_Last_Room_II_Python
C++ Find_Minimum_Time_to_Reach_Last_Room_II_C++
3493 Properties_Graph Disjoint-set O((K*N) * k) O(k * N) Medium Python Properties_Graph_Python
C++ Properties_Graph_C++
3528 Unit_Conversion_I DFS O(K + N) O((2*K) + N) Medium Python Unit_Conversion_I_Python
C++ Unit_Conversion_I_C++
3532 Path_Existence_Queries_in_a_Graph_I Disjoint-set O(2 * N) O(2 * N) Medium Python Path_Existence_Queries_in_a_Graph_I_Python
C++ Path_Existence_Queries_in_a_Graph_I_C++
Trie 208 Implement_Trie(Prefix Tree) Trie O(K * N) O(K * N) Medium Python Implement_Trie(Prefix Tree)_Python
C++ Implement_Trie(Prefix Tree)_C++

Advanced

Algorithms / Datastructures # Title Method Time-Complexity Spatial-Complexity Difficulty Languages Link
Backtracking 17 Letter_Combinations_of_a_Phone_Number Backtracking ~ O(K * N) ~ O(K * N) Medium Python Letter_Combinations_of_a_Phone_Number_Python
C++ Letter_Combinations_of_a_Phone_Number_C++
22 Generate_Parentheses Backtracking O(N) O(K * N) Medium Python Generate_Parentheses_Python
C++ Generate_Parentheses_C++
39 Combination_Sum Backtracking O(2 ^ N) O(2 ^ N) Medium Python Combination_Sum_Python
C++ Combination_Sum_C++
1239 Maximum_Length_of_a_Concatenated_String_with_Unique_Characters Backtracking ~ O(K * (M * N)) ~ O(K * N) Medium Python Maximum_Length_of_a_Concatenated_String_with_Unique_Characters_Python
C++ Maximum_Length_of_a_Concatenated_String_with_Unique_Characters_C++
1774 Closest_Dessert_Cost Backtracking O(k * (N*N)) O(k * N) Medium Python Closest_Dessert_Cost_Python
C++ Closest_Dessert_Cost_C++
2708 Maximum_Strength_of_a_Group Backtracking ~ O(K * N) ~ O(K * N) Medium Python Maximum_Strength_of_a_Group_Python
C++ Maximum_Strength_of_a_Group_C++
Dynamic-programming 42 Trapping_Rain_Water DP O(3 * N) O(2 * N) Hard Python Trapping_Rain_Water_Python
C++ Trapping_Rain_Water_C++
63 Unique_Paths_II DP O(R * C) O(R * C) Medium Python Unique_Paths_II_Python
C++ Unique_Paths_II_C++
64 Minimum_Path_Sum DP O(R * C) O(R * C) Medium Python Minimum_Path_Sum_Python
C++ Minimum_Path_Sum_C++
70 Climbing_Stairs DP O(N) O(N) Easy Python Climbing_Stairs_Python
C++ Climbing_Stairs_C++
72 Edit_Distance DP ~ O(M * N) O(M * N) Medium Python Edit_Distance_Python
C++ Edit_Distance_C++
91 Decode_Ways DP O(N) O(N) Medium Python Decode_Ways_Python
C++ Decode_Ways_C++
120 Triangle DP O((N-1) * (N-1)) O(N) Medium Python Triangle_Python
C++ Triangle_C++
123 Best_Time_to_Buy_and_Sell_Stock_III DP O(2 * N) O(2 * 3) Hard Python Best_Time_to_Buy_and_Sell_Stock_III_Python
C++ Best_Time_to_Buy_and_Sell_Stock_III_C++
139 Word_Break DP ~ O((k * N) + K) O(N + K) Medium Python Word_Break_Python
C++ Word_Break_C++
188 Best_Time_to_Buy_and_Sell_Stock_IV DP O(k * N) O(2 * k) Hard Python Best_Time_to_Buy_and_Sell_Stock_IV_Python
C++ Best_Time_to_Buy_and_Sell_Stock_IV_C++
198 House_Robber DP O(N) O(N) Medium Python House_Robber_Python
C++ House_Robber_C++
213 House_Robber_II DP O(2 * N) O(2 * N) Medium Python House_Robber_II_Python
C++ House_Robber_II_C++
221 Maximal_Square DP O(R * C) O(R * C) Medium Python Maximal_Square_Python
C++ Maximal_Square_C++
322 Coin_Change DP O(K * N) O(N) Medium Python Coin_Change_Python
C++ Coin_Change_C++
403 Frog_Jump DP O(K * N) O(K + N) Hard Python Frog_Jump_Python
C++ Frog_Jump_C++
474 Ones_and_Zeroes DP O(k * (m*n)) O(m * n) Medium Python Ones_and_Zeroes_Python
C++ Ones_and_Zeroes_C++
518 Coin_Change_II DP O(K * N) O(N) Medium Python Coin_Change_II_Python
C++ Coin_Change_II_C++
542 01_Matrix DP O(2 * (R*C)) O(R * C) Medium Python 01_Matrix_Python
C++ 01_Matrix_C++
583 Delete_Operation_for_Two_Strings DP ~ O(R * C) O(R * C) Medium Python Delete_Operation_for_Two_Strings_Python
C++ Delete_Operation_for_Two_Strings_C++
673 Number_of_Longest_Increasing_Subsequence DP O(N + (N*N)) O(2 * N) Medium Python Number_of_Longest_Increasing_Subsequence_Python
C++ Number_of_Longest_Increasing_Subsequence_C++
714 Best_Time_to_Buy_and_Sell_Stock_with_Transaction_Fee DP O(N) O(2 * N) Medium Python Best_Time_to_Buy_and_Sell_Stock_with_Transaction_Fee_Python
C++ Best_Time_to_Buy_and_Sell_Stock_with_Transaction_Fee_C++
873 Length_of_Longest_Fibonacci_Subsequence DP O(N * N) O(3 * N) Medium Python Length_of_Longest_Fibonacci_Subsequence_Python
C++ Length_of_Longest_Fibonacci_Subsequence_C++
915 Partition_Array_into_Disjoint_Intervals DP O(3 * N) O(k * N) Medium Python Partition_Array_into_Disjoint_Intervals_Python
C++ Partition_Array_into_Disjoint_Intervals_C++
931 Minimum_Falling_Path_Sum DP O(R * C) O(R * C) Medium Python Minimum_Falling_Path_Sum_Python
C++ Minimum_Falling_Path_Sum_C++
983 Minimum_Cost_For_Tickets DP O(N) O(N) Medium Python Minimum_Cost_For_Tickets_Python
C++ Minimum_Cost_For_Tickets_C++
1043 Partition_Array_for_Maximum_Sum DP O(k * N) O(N) Medium Python Partition_Array_for_Maximum_Sum_Python
C++ Partition_Array_for_Maximum_Sum_C++
1105 Filling_Bookcase_Shelves DP O(K * N) O(N) Medium Python Filling_Bookcase_Shelves_Python
C++ Filling_Bookcase_Shelves_C++
1137 N-th_Tribonacci_Number DP O(N) O(N) Easy Python N-th_Tribonacci_Number_Python
C++ N-th_Tribonacci_Number_C++
1143 Longest_Common_Subsequence DP O(M * N) O(M * N) Medium Python Longest_Common_Subsequence_Python
C++ Longest_Common_Subsequence_C++
1186 Maximum_Subarray_Sum_with_One_Deletion DP O(3 * N) O(2 * N) Medium Python Maximum_Subarray_Sum_with_One_Deletion_Python
C++ Maximum_Subarray_Sum_with_One_Deletion_C++
1218 Longest_Arithmetic_Subsequence_of_Given_Difference DP O(N) O(N) Medium Python Longest_Arithmetic_Subsequence_of_Given_Difference_Python
C++ Longest_Arithmetic_Subsequence_of_Given_Difference_C++
1289 Minimum_Falling_Path_Sum_II DP ~ O((R*C) * Log(r *c)) O(R * C) Hard Python Minimum_Falling_Path_Sum_II_Python
C++ Minimum_Falling_Path_Sum_II_C++
1504 Count_Submatrices_With_All_Ones DP O((1+K) * (R*C)) O(1) Medium Python Count_Submatrices_With_All_Ones_Python
C++ Count_Submatrices_With_All_Ones_C++
1626 Best_Team_With_No_Conflicts DP O((N+Log(N)) * N) O(3 * N) Medium Python Best_Team_With_No_Conflicts_Python
C++ Best_Team_With_No_Conflicts_C++
1696 Jump_Game_VI DP O(k * N) O(k * N) Medium Python Jump_Game_VI_Python
C++ Jump_Game_VI_C++
2012 Sum_of_Beauty_in_the_Array DP O(3 * N) O(k * N) Medium Python Sum_of_Beauty_in_the_Array_Python
C++ Sum_of_Beauty_in_the_Array_C++
2100 Find_Good_Days_to_Rob_the_Bank DP O(3 * N) O(k * N) Medium Python Find_Good_Days_to_Rob_the_Bank_Python
C++ Find_Good_Days_to_Rob_the_Bank_C++
2140 Solving_Questions_With_Brainpower DP O(N) O(N) Medium Python Solving_Questions_With_Brainpower_Python
C++ Solving_Questions_With_Brainpower_C++
2320 Count_Number_of_Ways_to_Place_Houses DP O(N) O(N) Medium Python Count_Number_of_Ways_to_Place_Houses_Python
C++ Count_Number_of_Ways_to_Place_Houses_C++
2420 Find_All_Good_Indices DP O(3 * N) O(k * N) Medium Python Find_All_Good_Indices_Python
C++ Find_All_Good_Indices_C++
2786 Visit_Array_Positions_to_Maximize_Score DP O(N) O(1) Medium Python Visit_Array_Positions_to_Maximize_Score_Python
C++ Visit_Array_Positions_to_Maximize_Score_C++
2874 Maximum_Value_of_an_Ordered_Triplet_II DP O(3 * N) O(k * N) Medium Python Maximum_Value_of_an_Ordered_Triplet_II_Python
C++ Maximum_Value_of_an_Ordered_Triplet_II_C++
2909 Minimum_Sum_of_Mountain_Triplets_II DP O(3 * N) O(k * N) Medium Python Minimum_Sum_of_Mountain_Triplets_II_Python
C++ Minimum_Sum_of_Mountain_Triplets_II_C++
2915 Length_of_the_Longest_Subsequence_That_Sums_to_Target DP O(K * N) O(K) Medium Python Length_of_the_Longest_Subsequence_That_Sums_to_Target_Python
C++ Length_of_the_Longest_Subsequence_That_Sums_to_Target_C++
2945 Find_Maximum_Non-decreasing_Array_Length DP O(N * Log(N)) O(3 * N) Hard Python Find_Maximum_Non-decreasing_Array_Length_Python
C++ Find_Maximum_Non-decreasing_Array_Length_C++
3152 Special_Array_II DP O(2 * N) O(2 * N) Medium Python Special_Array_II_Python
C++ Special_Array_II_C++

About

LeetCode Problems' Solutions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors