From f106d20d781528509d09a847d00e32810f7869d3 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 1 Jun 2023 13:49:56 +0300 Subject: [PATCH] Added tasks 1070-1148 --- README.md | 1573 +++++++++-------- .../readme.md | 98 + .../readme.md | 56 + .../readme.md | 84 + .../readme.md | 87 + .../readme.md | 75 + .../s1075_project_employees_i/readme.md | 90 + .../s1078_occurrences_after_bigram/readme.md | 52 + .../s1079_letter_tile_possibilities/readme.md | 67 + .../readme.md | 82 + .../readme.md | 55 + .../s1105_filling_bookcase_shelves/readme.md | 69 + .../readme.md | 138 ++ .../s1108_defanging_an_ip_address/readme.md | 36 + .../s1109_corporate_flight_bookings/readme.md | 74 + .../readme.md | 91 + .../readme.md | 73 + .../g1101_1200/s1114_print_in_order/readme.md | 74 + .../s1115_print_foobar_alternately/readme.md | 78 + .../s1116_print_zero_even_odd/readme.md | 113 ++ .../g1101_1200/s1117_building_h2o/readme.md | 95 + .../s1122_relative_sort_array/readme.md | 58 + .../readme.md | 89 + .../readme.md | 63 + .../s1125_smallest_sufficient_team/readme.md | 110 ++ .../readme.md | 47 + .../readme.md | 112 ++ .../readme.md | 79 + .../readme.md | 60 + .../s1137_n_th_tribonacci_number/readme.md | 57 + .../s1138_alphabet_board_path/readme.md | 85 + .../s1139_largest_1_bordered_square/readme.md | 74 + .../g1101_1200/s1140_stone_game_ii/readme.md | 73 + .../readme.md | 71 + .../readme.md | 92 + .../s1145_binary_tree_coloring_game/readme.md | 77 + .../g1101_1200/s1146_snapshot_array/readme.md | 80 + .../readme.md | 80 + .../s1148_article_views_i/readme.md | 61 + 39 files changed, 3763 insertions(+), 765 deletions(-) create mode 100644 src/main/kotlin/g1001_1100/s1070_product_sales_analysis_iii/readme.md create mode 100644 src/main/kotlin/g1001_1100/s1071_greatest_common_divisor_of_strings/readme.md create mode 100644 src/main/kotlin/g1001_1100/s1072_flip_columns_for_maximum_number_of_equal_rows/readme.md create mode 100644 src/main/kotlin/g1001_1100/s1073_adding_two_negabinary_numbers/readme.md create mode 100644 src/main/kotlin/g1001_1100/s1074_number_of_submatrices_that_sum_to_target/readme.md create mode 100644 src/main/kotlin/g1001_1100/s1075_project_employees_i/readme.md create mode 100644 src/main/kotlin/g1001_1100/s1078_occurrences_after_bigram/readme.md create mode 100644 src/main/kotlin/g1001_1100/s1079_letter_tile_possibilities/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1103_distribute_candies_to_people/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1104_path_in_zigzag_labelled_binary_tree/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1105_filling_bookcase_shelves/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1106_parsing_a_boolean_expression/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1108_defanging_an_ip_address/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1109_corporate_flight_bookings/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1110_delete_nodes_and_return_forest/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1111_maximum_nesting_depth_of_two_valid_parentheses_strings/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1114_print_in_order/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1115_print_foobar_alternately/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1116_print_zero_even_odd/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1117_building_h2o/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1122_relative_sort_array/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1123_lowest_common_ancestor_of_deepest_leaves/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1124_longest_well_performing_interval/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1125_smallest_sufficient_team/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1128_number_of_equivalent_domino_pairs/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1129_shortest_path_with_alternating_colors/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1130_minimum_cost_tree_from_leaf_values/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1131_maximum_of_absolute_value_expression/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1137_n_th_tribonacci_number/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1138_alphabet_board_path/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1139_largest_1_bordered_square/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1140_stone_game_ii/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1141_user_activity_for_the_past_30_days_i/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1144_decrease_elements_to_make_array_zigzag/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1145_binary_tree_coloring_game/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1146_snapshot_array/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1147_longest_chunked_palindrome_decomposition/readme.md create mode 100644 src/main/kotlin/g1101_1200/s1148_article_views_i/readme.md diff --git a/README.md b/README.md index 5038e292..92a896ef 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ [![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) > ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews) -* [Level 1](#level-1) -* [Level 2](#level-2) -* [Udemy](#udemy) * [Data Structure I](#data-structure-i) * [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) @@ -16,1713 +13,1721 @@ * [Programming Skills II](#programming-skills-ii) * [Graph Theory I](#graph-theory-i) * [SQL I](#sql-i) +* [Level 1](#level-1) +* [Level 2](#level-2) +* [Udemy](#udemy) -### Level 1 +### Data Structure I -#### Day 1 Prefix Sum +#### Day 1 Array | | | | | | |-|-|-|-|-|- -| 0724 |[Find Pivot Index](src/main/kotlin/g0701_0800/s0724_find_pivot_index)| Easy | Array, Prefix_Sum | 255 | 88.92 +| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49 +| 0053 |[Maximum Subarray](src/main/kotlin/g0001_0100/s0053_maximum_subarray)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer | 662 | 82.48 -#### Day 2 String +#### Day 2 Array | | | | | | |-|-|-|-|-|- -| 0205 |[Isomorphic Strings](src/main/kotlin/g0201_0300/s0205_isomorphic_strings)| Easy | String, Hash_Table | 278 | 79.96 -| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74 +| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 234 | 92.75 +| 0088 |[Merge Sorted Array](src/main/kotlin/g0001_0100/s0088_merge_sorted_array)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 311 | 33.40 -#### Day 3 Linked List +#### Day 3 Array | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 -| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 +| 0350 |[Intersection of Two Arrays II](src/main/kotlin/g0301_0400/s0350_intersection_of_two_arrays_ii)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 321 | 73.37 +| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 -#### Day 4 Linked List +#### Day 4 Array | | | | | | |-|-|-|-|-|- -| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52 -| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List | 192 | 63.39 +| 0566 |[Reshape the Matrix](src/main/kotlin/g0501_0600/s0566_reshape_the_matrix)| Easy | Array, Matrix, Simulation | 239 | 99.05 +| 0118 |[Pascal's Triangle](src/main/kotlin/g0101_0200/s0118_pascals_triangle)| Easy | Top_Interview_Questions, Array, Dynamic_Programming | 277 | 33.22 -#### Day 5 Greedy +#### Day 5 Array | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 -| 0409 |[Longest Palindrome](src/main/kotlin/g0401_0500/s0409_longest_palindrome)| Easy | String, Hash_Table, Greedy | 259 | 60.71 +| 0036 |[Valid Sudoku](src/main/kotlin/g0001_0100/s0036_valid_sudoku)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 346 | 65.03 +| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 -#### Day 6 Tree +#### Day 6 String | | | | | | |-|-|-|-|-|- -| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02 -| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 332 | 67.53 +| 0387 |[First Unique Character in a String](src/main/kotlin/g0301_0400/s0387_first_unique_character_in_a_string)| Easy | Top_Interview_Questions, String, Hash_Table, Counting, Queue | 369 | 82.68 +| 0383 |[Ransom Note](src/main/kotlin/g0301_0400/s0383_ransom_note)| Easy | String, Hash_Table, Counting | 333 | 79.58 +| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | Top_Interview_Questions, String, Hash_Table, Sorting | 251 | 87.65 -#### Day 7 Binary Search +#### Day 7 Linked List | | | | | | |-|-|-|-|-|- -| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 -| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86 +| 0141 |[Linked List Cycle](src/main/kotlin/g0101_0200/s0141_linked_list_cycle)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 223 | 91.85 +| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 +| 0203 |[Remove Linked List Elements](src/main/kotlin/g0201_0300/s0203_remove_linked_list_elements)| Easy | Linked_List, Recursion | 233 | 91.22 -#### Day 8 Binary Search Tree +#### Day 8 Linked List | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 330 | 41.38 -| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/kotlin/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 404 | 75.59 +| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 +| 0083 |[Remove Duplicates from Sorted List](src/main/kotlin/g0001_0100/s0083_remove_duplicates_from_sorted_list)| Easy | Linked_List | 274 | 77.82 -#### Day 9 Graph/BFS/DFS +#### Day 9 Stack Queue | | | | | | |-|-|-|-|-|- -| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76 -| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 +| 0020 |[Valid Parentheses](src/main/kotlin/g0001_0100/s0020_valid_parentheses)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack | 226 | 72.53 +| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86 -#### Day 10 Dynamic Programming +#### Day 10 Tree | | | | | | |-|-|-|-|-|- -| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72 -| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization | 127 | 97.06 +| 0144 |[Binary Tree Preorder Traversal](src/main/kotlin/g0101_0200/s0144_binary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 277 | 37.90 +| 0094 |[Binary Tree Inorder Traversal](src/main/kotlin/g0001_0100/s0094_binary_tree_inorder_traversal)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack | 269 | 38.80 +| 0145 |[Binary Tree Postorder Traversal](src/main/kotlin/g0101_0200/s0145_binary_tree_postorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 211 | 80.00 -#### Day 11 Dynamic Programming +#### Day 11 Tree | | | | | | |-|-|-|-|-|- -| 0746 |[Min Cost Climbing Stairs](src/main/kotlin/g0701_0800/s0746_min_cost_climbing_stairs)| Easy | Array, Dynamic_Programming | 171 | 96.76 -| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics | 209 | 49.18 +| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 332 | 67.53 +| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 236 | 83.39 +| 0101 |[Symmetric Tree](src/main/kotlin/g0101_0200/s0101_symmetric_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 190 | 91.36 -#### Day 12 Sliding Window/Two Pointer +#### Day 12 Tree | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window | 561 | 54.68 -| 0424 |[Longest Repeating Character Replacement](src/main/kotlin/g0401_0500/s0424_longest_repeating_character_replacement)| Medium | String, Hash_Table, Sliding_Window | 288 | 84.38 +| 0226 |[Invert Binary Tree](src/main/kotlin/g0201_0300/s0226_invert_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 233 | 54.90 +| 0112 |[Path Sum](src/main/kotlin/g0101_0200/s0112_path_sum)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 322 | 36.41 -#### Day 13 Hashmap +#### Day 13 Tree | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 234 | 92.75 -| 0299 |[Bulls and Cows](src/main/kotlin/g0201_0300/s0299_bulls_and_cows)| Medium | String, Hash_Table, Counting | 254 | 84.82 +| 0700 |[Search in a Binary Search Tree](src/main/kotlin/g0601_0700/s0700_search_in_a_binary_search_tree)| Easy | Tree, Binary_Tree, Binary_Search_Tree | 251 | 88.31 +| 0701 |[Insert into a Binary Search Tree](src/main/kotlin/g0701_0800/s0701_insert_into_a_binary_search_tree)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 311 | 79.03 -#### Day 14 Stack +#### Day 14 Tree | | | | | | |-|-|-|-|-|- -| 0844 |[Backspace String Compare](src/main/kotlin/g0801_0900/s0844_backspace_string_compare)| Easy | String, Two_Pointers, Stack, Simulation | 126 | 98.31 -| 0394 |[Decode String](src/main/kotlin/g0301_0400/s0394_decode_string)| Medium | Top_100_Liked_Questions, String, Stack, Recursion | 224 | 64.86 +| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 330 | 41.38 +| 0653 |[Two Sum IV - Input is a BST](src/main/kotlin/g0601_0700/s0653_two_sum_iv_input_is_a_bst)| Easy | Hash_Table, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Two_Pointers, Binary_Search_Tree | 231 | 96.08 +| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/kotlin/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 404 | 75.59 -#### Day 15 Heap +### Data Structure II + +#### Day 1 Array | | | | | | |-|-|-|-|-|- -| 1046 |[Last Stone Weight](src/main/kotlin/g1001_1100/s1046_last_stone_weight)| Easy | Array, Heap_Priority_Queue | 123 | 100.00 -| 0692 |[Top K Frequent Words](src/main/kotlin/g0601_0700/s0692_top_k_frequent_words)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Trie, Bucket_Sort | 239 | 81.10 - -### Level 2 +| 0136 |[Single Number](src/main/kotlin/g0101_0200/s0136_single_number)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation | 344 | 83.63 +| 0169 |[Majority Element](src/main/kotlin/g0101_0200/s0169_majority_element)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer | 460 | 51.25 +| 0015 |[3Sum](src/main/kotlin/g0001_0100/s0015_3sum)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 761 | 90.55 -#### Day 1 Implementation/Simulation +#### Day 2 Array | | | | | | |-|-|-|-|-|- -| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08 -| 0054 |[Spiral Matrix](src/main/kotlin/g0001_0100/s0054_spiral_matrix)| Medium | Top_Interview_Questions, Array, Matrix, Simulation | 224 | 62.50 +| 0075 |[Sort Colors](src/main/kotlin/g0001_0100/s0075_sort_colors)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 198 | 85.66 +| 0056 |[Merge Intervals](src/main/kotlin/g0001_0100/s0056_merge_intervals)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting | 320 | 94.22 +| 0706 |[Design HashMap](src/main/kotlin/g0701_0800/s0706_design_hashmap)| Easy | Array, Hash_Table, Design, Linked_List, Hash_Function | 405 | 92.11 -#### Day 2 String +#### Day 3 Array | | | | | | |-|-|-|-|-|- -| 0014 |[Longest Common Prefix](src/main/kotlin/g0001_0100/s0014_longest_common_prefix)| Easy | Top_Interview_Questions, String | 209 | 88.86 -| 0043 |[Multiply Strings](src/main/kotlin/g0001_0100/s0043_multiply_strings)| Medium | String, Math, Simulation | 390 | 56.25 +| 0119 |[Pascal's Triangle II](src/main/kotlin/g0101_0200/s0119_pascals_triangle_ii)| Easy | Array, Dynamic_Programming | 157 | 97.27 +| 0048 |[Rotate Image](src/main/kotlin/g0001_0100/s0048_rotate_image)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix | 287 | 46.50 +| 0059 |[Spiral Matrix II](src/main/kotlin/g0001_0100/s0059_spiral_matrix_ii)| Medium | Array, Matrix, Simulation | 153 | 100.00 -#### Day 3 Linked List +#### Day 4 Array | | | | | | |-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/kotlin/g0001_0100/s0019_remove_nth_node_from_end_of_list)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List | 180 | 91.58 -| 0234 |[Palindrome Linked List](src/main/kotlin/g0201_0300/s0234_palindrome_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion | 641 | 79.53 +| 0240 |[Search a 2D Matrix II](src/main/kotlin/g0201_0300/s0240_search_a_2d_matrix_ii)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer | 460 | 66.08 +| 0435 |[Non-overlapping Intervals](src/main/kotlin/g0401_0500/s0435_non_overlapping_intervals)| Medium | Array, Dynamic_Programming, Sorting, Greedy | 1040 | 85.07 -#### Day 4 Linked List +#### Day 5 Array | | | | | | |-|-|-|-|-|- -| 0328 |[Odd Even Linked List](src/main/kotlin/g0301_0400/s0328_odd_even_linked_list)| Medium | Top_Interview_Questions, Linked_List | 216 | 86.96 -| 0148 |[Sort List](src/main/kotlin/g0101_0200/s0148_sort_list)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort | 820 | 61.70 +| 0334 |[Increasing Triplet Subsequence](src/main/kotlin/g0301_0400/s0334_increasing_triplet_subsequence)| Medium | Top_Interview_Questions, Array, Greedy | 672 | 60.61 +| 0238 |[Product of Array Except Self](src/main/kotlin/g0201_0300/s0238_product_of_array_except_self)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum | 669 | 48.96 +| 0560 |[Subarray Sum Equals K](src/main/kotlin/g0501_0600/s0560_subarray_sum_equals_k)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum | 692 | 53.27 -#### Day 5 Greedy +#### Day 6 String | | | | | | |-|-|-|-|-|- -| 0621 |[Task Scheduler](src/main/kotlin/g0601_0700/s0621_task_scheduler)| Medium | Array, Hash_Table, Sorting, Greedy, Heap_Priority_Queue, Counting | 266 | 98.36 +| 0415 |[Add Strings](src/main/kotlin/g0401_0500/s0415_add_strings)| Easy | String, Math, Simulation | 296 | 76.00 +| 0409 |[Longest Palindrome](src/main/kotlin/g0401_0500/s0409_longest_palindrome)| Easy | String, Hash_Table, Greedy | 259 | 60.71 -#### Day 6 Tree +#### Day 7 String | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/kotlin/g0201_0300/s0226_invert_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 233 | 54.90 -| 0110 |[Balanced Binary Tree](src/main/kotlin/g0101_0200/s0110_balanced_binary_tree)| Easy | Depth_First_Search, Tree, Binary_Tree | 310 | 63.63 +| 0290 |[Word Pattern](src/main/kotlin/g0201_0300/s0290_word_pattern)| Easy | String, Hash_Table | 177 | 89.55 +| 0763 |[Partition Labels](src/main/kotlin/g0701_0800/s0763_partition_labels)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers | 235 | 84.75 -#### Day 7 Tree +#### Day 8 String | | | | | | |-|-|-|-|-|- -| 0543 |[Diameter of Binary Tree](src/main/kotlin/g0501_0600/s0543_diameter_of_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree | 307 | 43.93 -| 0437 |[Path Sum III](src/main/kotlin/g0401_0500/s0437_path_sum_iii)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree | 403 | 54.12 +| 0049 |[Group Anagrams](src/main/kotlin/g0001_0100/s0049_group_anagrams)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting | 506 | 86.55 +| 0043 |[Multiply Strings](src/main/kotlin/g0001_0100/s0043_multiply_strings)| Medium | String, Math, Simulation | 390 | 56.25 -#### Day 8 Binary Search +#### Day 9 String | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 -| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 +| 0187 |[Repeated DNA Sequences](src/main/kotlin/g0101_0200/s0187_repeated_dna_sequences)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 319 | 79.03 +| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 -#### Day 9 Binary Search Tree +#### Day 10 Linked List | | | | | | |-|-|-|-|-|- -| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/kotlin/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 334 | 35.39 -| 0230 |[Kth Smallest Element in a BST](src/main/kotlin/g0201_0300/s0230_kth_smallest_element_in_a_bst)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 393 | 33.33 -| 0173 |[Binary Search Tree Iterator](src/main/kotlin/g0101_0200/s0173_binary_search_tree_iterator)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 563 | 46.91 +| 0002 |[Add Two Numbers](src/main/kotlin/g0001_0100/s0002_add_two_numbers)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion | 417 | 50.44 +| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List | 192 | 63.39 -#### Day 10 Graph/BFS/DFS +#### Day 11 Linked List | | | | | | |-|-|-|-|-|- -| 0994 |[Rotting Oranges](src/main/kotlin/g0901_1000/s0994_rotting_oranges)| Medium | Array, Breadth_First_Search, Matrix | 164 | 82.95 -| 0417 |[Pacific Atlantic Water Flow](src/main/kotlin/g0401_0500/s0417_pacific_atlantic_water_flow)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 319 | 100.00 +| 0160 |[Intersection of Two Linked Lists](src/main/kotlin/g0101_0200/s0160_intersection_of_two_linked_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 262 | 83.50 +| 0082 |[Remove Duplicates from Sorted List II](src/main/kotlin/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii)| Medium | Two_Pointers, Linked_List | 241 | 91.04 -#### Day 11 Graph/BFS/DFS +#### Day 12 Linked List | | | | | | |-|-|-|-|-|- -| 0210 |[Course Schedule II](src/main/kotlin/g0201_0300/s0210_course_schedule_ii)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 266 | 96.32 -| 0815 |[Bus Routes](src/main/kotlin/g0801_0900/s0815_bus_routes)| Hard | Array, Hash_Table, Breadth_First_Search | 429 | 100.00 +| 0024 |[Swap Nodes in Pairs](src/main/kotlin/g0001_0100/s0024_swap_nodes_in_pairs)| Medium | Top_100_Liked_Questions, Linked_List, Recursion | 149 | 99.39 +| 0707 |[Design Linked List](src/main/kotlin/g0701_0800/s0707_design_linked_list)| Medium | Design, Linked_List | 243 | 100.00 -#### Day 12 Dynamic Programming +#### Day 13 Linked List | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 -| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search | 332 | 50.68 +| 0025 |[Reverse Nodes in k-Group](src/main/kotlin/g0001_0100/s0025_reverse_nodes_in_k_group)| Hard | Top_100_Liked_Questions, Linked_List, Recursion | 194 | 87.72 +| 0143 |[Reorder List](src/main/kotlin/g0101_0200/s0143_reorder_list)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 395 | 82.26 -#### Day 13 Dynamic Programming +#### Day 14 Stack Queue | | | | | | |-|-|-|-|-|- -| 0416 |[Partition Equal Subset Sum](src/main/kotlin/g0401_0500/s0416_partition_equal_subset_sum)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming | 204 | 98.82 -| 0152 |[Maximum Product Subarray](src/main/kotlin/g0101_0200/s0152_maximum_product_subarray)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 253 | 88.42 +| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 -#### Day 14 Sliding Window/Two Pointer +#### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 258 | 91.09 -| 0016 |[3Sum Closest](src/main/kotlin/g0001_0100/s0016_3sum_closest)| Medium | Array, Sorting, Two_Pointers | 413 | 95.05 -| 0076 |[Minimum Window Substring](src/main/kotlin/g0001_0100/s0076_minimum_window_substring)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 346 | 85.20 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/kotlin/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 334 | 35.39 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/kotlin/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer | 370 | 58.31 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/kotlin/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 316 | 34.25 -#### Day 15 Tree +#### Day 16 Tree | | | | | | |-|-|-|-|-|- -| 0100 |[Same Tree](src/main/kotlin/g0001_0100/s0100_same_tree)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 208 | 72.24 -| 0101 |[Symmetric Tree](src/main/kotlin/g0101_0200/s0101_symmetric_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 190 | 91.36 | 0199 |[Binary Tree Right Side View](src/main/kotlin/g0101_0200/s0199_binary_tree_right_side_view)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 194 | 92.89 +| 0113 |[Path Sum II](src/main/kotlin/g0101_0200/s0113_path_sum_ii)| Medium | Depth_First_Search, Tree, Binary_Tree, Backtracking | 364 | 78.67 +| 0450 |[Delete Node in a BST](src/main/kotlin/g0401_0500/s0450_delete_node_in_a_bst)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 257 | 84.62 -#### Day 16 Design +#### Day 17 Tree | | | | | | |-|-|-|-|-|- -| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86 -| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 -| 0208 |[Implement Trie (Prefix Tree)](src/main/kotlin/g0201_0300/s0208_implement_trie_prefix_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie | 689 | 61.00 +| 0230 |[Kth Smallest Element in a BST](src/main/kotlin/g0201_0300/s0230_kth_smallest_element_in_a_bst)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 393 | 33.33 +| 0173 |[Binary Search Tree Iterator](src/main/kotlin/g0101_0200/s0173_binary_search_tree_iterator)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 563 | 46.91 -#### Day 17 Interval +#### Day 18 Tree | | | | | | |-|-|-|-|-|- -| 0057 |[Insert Interval](src/main/kotlin/g0001_0100/s0057_insert_interval)| Medium | Array | 257 | 99.52 -| 0056 |[Merge Intervals](src/main/kotlin/g0001_0100/s0056_merge_intervals)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting | 320 | 94.22 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/kotlin/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree | 386 | 45.21 +| 0297 |[Serialize and Deserialize Binary Tree](src/main/kotlin/g0201_0300/s0297_serialize_and_deserialize_binary_tree)| Hard | Top_Interview_Questions, String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 475 | 78.85 -#### Day 18 Stack +#### Day 19 Graph | | | | | | |-|-|-|-|-|- -| 0735 |[Asteroid Collision](src/main/kotlin/g0701_0800/s0735_asteroid_collision)| Medium | Array, Stack | 243 | 100.00 -| 0227 |[Basic Calculator II](src/main/kotlin/g0201_0300/s0227_basic_calculator_ii)| Medium | Top_Interview_Questions, String, Math, Stack | 383 | 62.50 +| 0997 |[Find the Town Judge](src/main/kotlin/g0901_1000/s0997_find_the_town_judge)| Easy | Array, Hash_Table, Graph | 475 | 58.62 +| 0841 |[Keys and Rooms](src/main/kotlin/g0801_0900/s0841_keys_and_rooms)| Medium | Depth_First_Search, Breadth_First_Search, Graph | 189 | 69.23 -#### Day 19 Union Find +#### Day 20 Heap Priority Queue | | | | | | |-|-|-|-|-|- -| 0547 |[Number of Provinces](src/main/kotlin/g0501_0600/s0547_number_of_provinces)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 229 | 79.73 -| 0947 |[Most Stones Removed with Same Row or Column](src/main/kotlin/g0901_1000/s0947_most_stones_removed_with_same_row_or_column)| Medium | Depth_First_Search, Graph, Union_Find | 200 | 100.00 +| 0215 |[Kth Largest Element in an Array](src/main/kotlin/g0201_0300/s0215_kth_largest_element_in_an_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect | 839 | 34.43 +| 0347 |[Top K Frequent Elements](src/main/kotlin/g0301_0400/s0347_top_k_frequent_elements)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort | 268 | 99.74 -#### Day 20 Brute Force/Backtracking +#### Day 21 Heap Priority Queue | | | | | | |-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/kotlin/g0001_0100/s0039_combination_sum)| Medium | Top_100_Liked_Questions, Array, Backtracking | 317 | 86.85 -| 0046 |[Permutations](src/main/kotlin/g0001_0100/s0046_permutations)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking | 186 | 100.00 +| 0451 |[Sort Characters By Frequency](src/main/kotlin/g0401_0500/s0451_sort_characters_by_frequency)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Bucket_Sort | 288 | 81.72 +| 0973 |[K Closest Points to Origin](src/main/kotlin/g0901_1000/s0973_k_closest_points_to_origin)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 800 | 37.89 -### Udemy +### Algorithm I -#### Udemy Integers +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- -| 0412 |[Fizz Buzz](src/main/kotlin/g0401_0500/s0412_fizz_buzz)| Easy | Top_Interview_Questions, String, Math, Simulation | 307 | 71.81 -| 0136 |[Single Number](src/main/kotlin/g0101_0200/s0136_single_number)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation | 344 | 83.63 -| 0007 |[Reverse Integer](src/main/kotlin/g0001_0100/s0007_reverse_integer)| Medium | Top_Interview_Questions, Math | 245 | 60.32 -| 0009 |[Palindrome Number](src/main/kotlin/g0001_0100/s0009_palindrome_number)| Easy | Math | 238 | 96.24 -| 0172 |[Factorial Trailing Zeroes](src/main/kotlin/g0101_0200/s0172_factorial_trailing_zeroes)| Medium | Top_Interview_Questions, Math | 220 | 67.65 -| 0050 |[Pow(x, n)](src/main/kotlin/g0001_0100/s0050_powx_n)| Medium | Top_Interview_Questions, Math, Recursion | 264 | 52.98 +| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 +| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86 +| 0035 |[Search Insert Position](src/main/kotlin/g0001_0100/s0035_search_insert_position)| Easy | Top_100_Liked_Questions, Array, Binary_Search | 267 | 50.32 -#### Udemy Strings +#### Day 2 Two Pointers | | | | | | |-|-|-|-|-|- -| 0344 |[Reverse String](src/main/kotlin/g0301_0400/s0344_reverse_string)| Easy | Top_Interview_Questions, String, Two_Pointers, Recursion | 445 | 69.75 -| 0014 |[Longest Common Prefix](src/main/kotlin/g0001_0100/s0014_longest_common_prefix)| Easy | Top_Interview_Questions, String | 209 | 88.86 -| 0187 |[Repeated DNA Sequences](src/main/kotlin/g0101_0200/s0187_repeated_dna_sequences)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 319 | 79.03 -| 0003 |[Longest Substring Without Repeating Characters](src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 258 | 91.09 -| 0020 |[Valid Parentheses](src/main/kotlin/g0001_0100/s0020_valid_parentheses)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack | 226 | 72.53 -| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 -| 0394 |[Decode String](src/main/kotlin/g0301_0400/s0394_decode_string)| Medium | Top_100_Liked_Questions, String, Stack, Recursion | 224 | 64.86 -| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | Top_Interview_Questions, String, Hash_Table, Sorting | 251 | 87.65 -| 0049 |[Group Anagrams](src/main/kotlin/g0001_0100/s0049_group_anagrams)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting | 506 | 86.55 -| 0151 |[Reverse Words in a String](src/main/kotlin/g0101_0200/s0151_reverse_words_in_a_string)| Medium | String, Two_Pointers | 206 | 98.90 -| 0273 |[Integer to English Words](src/main/kotlin/g0201_0300/s0273_integer_to_english_words)| Hard | String, Math, Recursion | 273 | 82.93 - -#### Udemy Binary Search - -| | | | | | -|-|-|-|-|-|- -| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 -| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/kotlin/g0101_0200/s0153_find_minimum_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Array, Binary_Search | 262 | 60.96 +| 0977 |[Squares of a Sorted Array](src/main/kotlin/g0901_1000/s0977_squares_of_a_sorted_array)| Easy | Array, Sorting, Two_Pointers | 375 | 18.43 +| 0189 |[Rotate Array](src/main/kotlin/g0101_0200/s0189_rotate_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers | 483 | 86.95 -#### Udemy Arrays +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 | 0283 |[Move Zeroes](src/main/kotlin/g0201_0300/s0283_move_zeroes)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers | 516 | 79.07 -| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 234 | 92.75 -| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49 -| 0058 |[Length of Last Word](src/main/kotlin/g0001_0100/s0058_length_of_last_word)| Easy | String | 243 | 63.33 -| 0605 |[Can Place Flowers](src/main/kotlin/g0601_0700/s0605_can_place_flowers)| Easy | Array, Greedy | 209 | 85.71 -| 0122 |[Best Time to Buy and Sell Stock II](src/main/kotlin/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 197 | 95.10 -| 0080 |[Remove Duplicates from Sorted Array II](src/main/kotlin/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii)| Medium | Array, Two_Pointers | 357 | 44.78 -| 0189 |[Rotate Array](src/main/kotlin/g0101_0200/s0189_rotate_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers | 483 | 86.95 -| 0055 |[Jump Game](src/main/kotlin/g0001_0100/s0055_jump_game)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 670 | 66.67 -| 0075 |[Sort Colors](src/main/kotlin/g0001_0100/s0075_sort_colors)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 198 | 85.66 -| 0066 |[Plus One](src/main/kotlin/g0001_0100/s0066_plus_one)| Easy | Top_Interview_Questions, Array, Math | 303 | 35.18 -| 0238 |[Product of Array Except Self](src/main/kotlin/g0201_0300/s0238_product_of_array_except_self)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum | 669 | 48.96 -| 0448 |[Find All Numbers Disappeared in an Array](src/main/kotlin/g0401_0500/s0448_find_all_numbers_disappeared_in_an_array)| Easy | Array, Hash_Table | 394 | 100.00 -| 0442 |[Find All Duplicates in an Array](src/main/kotlin/g0401_0500/s0442_find_all_duplicates_in_an_array)| Medium | Array, Hash_Table | 480 | 73.81 -| 0041 |[First Missing Positive](src/main/kotlin/g0001_0100/s0041_first_missing_positive)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 345 | 100.00 -| 0697 |[Degree of an Array](src/main/kotlin/g0601_0700/s0697_degree_of_an_array)| Easy | Array, Hash_Table | 289 | 84.62 -| 0532 |[K-diff Pairs in an Array](src/main/kotlin/g0501_0600/s0532_k_diff_pairs_in_an_array)| Medium | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 230 | 84.62 -| 0713 |[Subarray Product Less Than K](src/main/kotlin/g0701_0800/s0713_subarray_product_less_than_k)| Medium | Array, Sliding_Window | 336 | 92.11 -| 1007 |[Minimum Domino Rotations For Equal Row](src/main/kotlin/g1001_1100/s1007_minimum_domino_rotations_for_equal_row)| Medium | Array, Greedy | 421 | 50.00 -| 0456 |[132 Pattern](src/main/kotlin/g0401_0500/s0456_132_pattern)| Medium | Array, Binary_Search, Stack, Ordered_Set, Monotonic_Stack | 434 | 100.00 -| 0239 |[Sliding Window Maximum](src/main/kotlin/g0201_0300/s0239_sliding_window_maximum)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue | 1059 | 86.14 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/kotlin/g0101_0200/s0167_two_sum_ii_input_array_is_sorted)| Medium | Array, Binary_Search, Two_Pointers | 403 | 68.74 -#### Udemy Two Pointers +#### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74 -| 0125 |[Valid Palindrome](src/main/kotlin/g0101_0200/s0125_valid_palindrome)| Easy | Top_Interview_Questions, String, Two_Pointers | 353 | 52.06 -| 0977 |[Squares of a Sorted Array](src/main/kotlin/g0901_1000/s0977_squares_of_a_sorted_array)| Easy | Array, Sorting, Two_Pointers | 375 | 18.43 -| 0026 |[Remove Duplicates from Sorted Array](src/main/kotlin/g0001_0100/s0026_remove_duplicates_from_sorted_array)| Easy | Top_Interview_Questions, Array, Two_Pointers | 361 | 77.19 -| 0042 |[Trapping Rain Water](src/main/kotlin/g0001_0100/s0042_trapping_rain_water)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack | 196 | 100.00 -| 0015 |[3Sum](src/main/kotlin/g0001_0100/s0015_3sum)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 761 | 90.55 +| 0344 |[Reverse String](src/main/kotlin/g0301_0400/s0344_reverse_string)| Easy | Top_Interview_Questions, String, Two_Pointers, Recursion | 445 | 69.75 +| 0557 |[Reverse Words in a String III](src/main/kotlin/g0501_0600/s0557_reverse_words_in_a_string_iii)| Easy | String, Two_Pointers | 215 | 98.10 -#### Udemy Famous Algorithm +#### Day 5 Two Pointers | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/kotlin/g0001_0100/s0053_maximum_subarray)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer | 662 | 82.48 -| 0169 |[Majority Element](src/main/kotlin/g0101_0200/s0169_majority_element)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer | 460 | 51.25 +| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52 +| 0019 |[Remove Nth Node From End of List](src/main/kotlin/g0001_0100/s0019_remove_nth_node_from_end_of_list)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List | 180 | 91.58 -#### Udemy Sorting Algorithms +#### Day 6 Sliding Window | | | | | | |-|-|-|-|-|- -| 0912 |[Sort an Array](src/main/kotlin/g0901_1000/s0912_sort_an_array)| Medium | Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Merge_Sort, Bucket_Sort, Counting_Sort, Radix_Sort | 606 | 98.48 +| 0003 |[Longest Substring Without Repeating Characters](src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 258 | 91.09 +| 0567 |[Permutation in String](src/main/kotlin/g0501_0600/s0567_permutation_in_string)| Medium | String, Hash_Table, Two_Pointers, Sliding_Window | 169 | 100.00 -#### Udemy 2D Arrays/Matrix +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0304 |[Range Sum Query 2D - Immutable](src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable)| Medium | Array, Matrix, Design, Prefix_Sum | 1373 | 85.71 -| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 -| 0054 |[Spiral Matrix](src/main/kotlin/g0001_0100/s0054_spiral_matrix)| Medium | Top_Interview_Questions, Array, Matrix, Simulation | 224 | 62.50 -| 0048 |[Rotate Image](src/main/kotlin/g0001_0100/s0048_rotate_image)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix | 287 | 46.50 -| 0073 |[Set Matrix Zeroes](src/main/kotlin/g0001_0100/s0073_set_matrix_zeroes)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix | 255 | 100.00 -| 0056 |[Merge Intervals](src/main/kotlin/g0001_0100/s0056_merge_intervals)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting | 320 | 94.22 +| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76 +| 0695 |[Max Area of Island](src/main/kotlin/g0601_0700/s0695_max_area_of_island)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 324 | 24.06 -#### Udemy Linked List +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0114 |[Flatten Binary Tree to Linked List](src/main/kotlin/g0101_0200/s0114_flatten_binary_tree_to_linked_list)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List | 191 | 93.10 -| 0445 |[Add Two Numbers II](src/main/kotlin/g0401_0500/s0445_add_two_numbers_ii)| Medium | Math, Stack, Linked_List | 240 | 82.61 -| 0328 |[Odd Even Linked List](src/main/kotlin/g0301_0400/s0328_odd_even_linked_list)| Medium | Top_Interview_Questions, Linked_List | 216 | 86.96 -| 0061 |[Rotate List](src/main/kotlin/g0001_0100/s0061_rotate_list)| Medium | Two_Pointers, Linked_List | 193 | 92.16 -| 0024 |[Swap Nodes in Pairs](src/main/kotlin/g0001_0100/s0024_swap_nodes_in_pairs)| Medium | Top_100_Liked_Questions, Linked_List, Recursion | 149 | 99.39 -| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52 -| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List | 192 | 63.39 -| 0141 |[Linked List Cycle](src/main/kotlin/g0101_0200/s0141_linked_list_cycle)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 223 | 91.85 -| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 -| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 -| 0160 |[Intersection of Two Linked Lists](src/main/kotlin/g0101_0200/s0160_intersection_of_two_linked_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 262 | 83.50 -| 0234 |[Palindrome Linked List](src/main/kotlin/g0201_0300/s0234_palindrome_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion | 641 | 79.53 -| 0138 |[Copy List with Random Pointer](src/main/kotlin/g0101_0200/s0138_copy_list_with_random_pointer)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List | 274 | 80.58 -| 0025 |[Reverse Nodes in k-Group](src/main/kotlin/g0001_0100/s0025_reverse_nodes_in_k_group)| Hard | Top_100_Liked_Questions, Linked_List, Recursion | 194 | 87.72 -| 0146 |[LRU Cache](src/main/kotlin/g0101_0200/s0146_lru_cache)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List | 1116 | 97.93 -| 0707 |[Design Linked List](src/main/kotlin/g0701_0800/s0707_design_linked_list)| Medium | Design, Linked_List | 243 | 100.00 +| 0617 |[Merge Two Binary Trees](src/main/kotlin/g0601_0700/s0617_merge_two_binary_trees)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 243 | 72.83 +| 0116 |[Populating Next Right Pointers in Each Node](src/main/kotlin/g0101_0200/s0116_populating_next_right_pointers_in_each_node)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 355 | 69.02 -#### Udemy Tree Stack Queue +#### Day 9 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0144 |[Binary Tree Preorder Traversal](src/main/kotlin/g0101_0200/s0144_binary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 277 | 37.90 -| 0094 |[Binary Tree Inorder Traversal](src/main/kotlin/g0001_0100/s0094_binary_tree_inorder_traversal)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack | 269 | 38.80 -| 0145 |[Binary Tree Postorder Traversal](src/main/kotlin/g0101_0200/s0145_binary_tree_postorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 211 | 80.00 -| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 332 | 67.53 -| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/kotlin/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 316 | 34.25 -| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/kotlin/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 334 | 35.39 -| 1008 |[Construct Binary Search Tree from Preorder Traversal](src/main/kotlin/g1001_1100/s1008_construct_binary_search_tree_from_preorder_traversal)| Medium | Array, Tree, Binary_Tree, Stack, Monotonic_Stack, Binary_Search_Tree | 145 | 100.00 -| 0543 |[Diameter of Binary Tree](src/main/kotlin/g0501_0600/s0543_diameter_of_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree | 307 | 43.93 -| 0938 |[Range Sum of BST](src/main/kotlin/g0901_1000/s0938_range_sum_of_bst)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 356 | 55.36 -| 0100 |[Same Tree](src/main/kotlin/g0001_0100/s0100_same_tree)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 208 | 72.24 -| 0226 |[Invert Binary Tree](src/main/kotlin/g0201_0300/s0226_invert_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 233 | 54.90 -| 0111 |[Minimum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0111_minimum_depth_of_binary_tree)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 525 | 90.51 -| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 236 | 83.39 -| 0110 |[Balanced Binary Tree](src/main/kotlin/g0101_0200/s0110_balanced_binary_tree)| Easy | Depth_First_Search, Tree, Binary_Tree | 310 | 63.63 -| 0701 |[Insert into a Binary Search Tree](src/main/kotlin/g0701_0800/s0701_insert_into_a_binary_search_tree)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 311 | 79.03 -| 0297 |[Serialize and Deserialize Binary Tree](src/main/kotlin/g0201_0300/s0297_serialize_and_deserialize_binary_tree)| Hard | Top_Interview_Questions, String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 475 | 78.85 -| 0124 |[Binary Tree Maximum Path Sum](src/main/kotlin/g0101_0200/s0124_binary_tree_maximum_path_sum)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 331 | 74.42 -| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 330 | 41.38 -| 0337 |[House Robber III](src/main/kotlin/g0301_0400/s0337_house_robber_iii)| Medium | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 282 | 84.62 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/kotlin/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree | 386 | 45.21 -| 0968 |[Binary Tree Cameras](src/main/kotlin/g0901_1000/s0968_binary_tree_cameras)| Hard | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 176 | 100.00 +| 0542 |[01 Matrix](src/main/kotlin/g0501_0600/s0542_01_matrix)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 441 | 94.06 +| 0994 |[Rotting Oranges](src/main/kotlin/g0901_1000/s0994_rotting_oranges)| Medium | Array, Breadth_First_Search, Matrix | 164 | 82.95 -#### Udemy Trie and Heap +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/kotlin/g0201_0300/s0208_implement_trie_prefix_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie | 689 | 61.00 -| 0745 |[Prefix and Suffix Search](src/main/kotlin/g0701_0800/s0745_prefix_and_suffix_search)| Hard | String, Design, Trie | 1638 | 100.00 +| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 +| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 -#### Udemy Graph +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 -| 0133 |[Clone Graph](src/main/kotlin/g0101_0200/s0133_clone_graph)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 351 | 60.91 -| 0417 |[Pacific Atlantic Water Flow](src/main/kotlin/g0401_0500/s0417_pacific_atlantic_water_flow)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 319 | 100.00 +| 0077 |[Combinations](src/main/kotlin/g0001_0100/s0077_combinations)| Medium | Backtracking | 244 | 100.00 +| 0046 |[Permutations](src/main/kotlin/g0001_0100/s0046_permutations)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking | 186 | 100.00 +| 0784 |[Letter Case Permutation](src/main/kotlin/g0701_0800/s0784_letter_case_permutation)| Medium | String, Bit_Manipulation, Backtracking | 219 | 84.62 -#### Udemy Dynamic Programming +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0120 |[Triangle](src/main/kotlin/g0101_0200/s0120_triangle)| Medium | Array, Dynamic_Programming | 194 | 97.87 -| 0118 |[Pascal's Triangle](src/main/kotlin/g0101_0200/s0118_pascals_triangle)| Easy | Top_Interview_Questions, Array, Dynamic_Programming | 277 | 33.22 -| 0119 |[Pascal's Triangle II](src/main/kotlin/g0101_0200/s0119_pascals_triangle_ii)| Easy | Array, Dynamic_Programming | 157 | 97.27 -| 0139 |[Word Break](src/main/kotlin/g0101_0200/s0139_word_break)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization | 197 | 87.17 -| 0152 |[Maximum Product Subarray](src/main/kotlin/g0101_0200/s0152_maximum_product_subarray)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 253 | 88.42 -| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 -| 0213 |[House Robber II](src/main/kotlin/g0201_0300/s0213_house_robber_ii)| Medium | Array, Dynamic_Programming | 257 | 59.62 -| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72 | 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization | 127 | 97.06 -| 0064 |[Minimum Path Sum](src/main/kotlin/g0001_0100/s0064_minimum_path_sum)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix | 222 | 95.70 -| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 -| 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming | 307 | 38.36 -| 0072 |[Edit Distance](src/main/kotlin/g0001_0100/s0072_edit_distance)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming | 320 | 63.53 -| 0044 |[Wildcard Matching](src/main/kotlin/g0001_0100/s0044_wildcard_matching)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Greedy, Recursion | 401 | 86.11 -| 0010 |[Regular Expression Matching](src/main/kotlin/g0001_0100/s0010_regular_expression_matching)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion | 292 | 58.58 +| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 +| 0120 |[Triangle](src/main/kotlin/g0101_0200/s0120_triangle)| Medium | Array, Dynamic_Programming | 194 | 97.87 -#### Udemy Backtracking/Recursion +#### Day 13 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0022 |[Generate Parentheses](src/main/kotlin/g0001_0100/s0022_generate_parentheses)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking | 210 | 78.51 -| 0039 |[Combination Sum](src/main/kotlin/g0001_0100/s0039_combination_sum)| Medium | Top_100_Liked_Questions, Array, Backtracking | 317 | 86.85 -| 0216 |[Combination Sum III](src/main/kotlin/g0201_0300/s0216_combination_sum_iii)| Medium | Array, Backtracking | 175 | 90.91 -| 0078 |[Subsets](src/main/kotlin/g0001_0100/s0078_subsets)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking | 191 | 97.44 -| 0017 |[Letter Combinations of a Phone Number](src/main/kotlin/g0001_0100/s0017_letter_combinations_of_a_phone_number)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking | 262 | 73.59 -| 0046 |[Permutations](src/main/kotlin/g0001_0100/s0046_permutations)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking | 186 | 100.00 +| 0231 |[Power of Two](src/main/kotlin/g0201_0300/s0231_power_of_two)| Easy | Math, Bit_Manipulation, Recursion | 161 | 86.81 +| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44 -#### Udemy Bit Manipulation +#### Day 14 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44 -| 0389 |[Find the Difference](src/main/kotlin/g0301_0400/s0389_find_the_difference)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 256 | 64.81 | 0190 |[Reverse Bits](src/main/kotlin/g0101_0200/s0190_reverse_bits)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 198 | 81.82 -| 0461 |[Hamming Distance](src/main/kotlin/g0401_0500/s0461_hamming_distance)| Easy | Bit_Manipulation | 150 | 96.15 -| 1009 |[Complement of Base 10 Integer](src/main/kotlin/g1001_1100/s1009_complement_of_base_10_integer)| Easy | Bit_Manipulation | 126 | 72.73 -| 0338 |[Counting Bits](src/main/kotlin/g0301_0400/s0338_counting_bits)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation | 186 | 99.26 -| 0371 |[Sum of Two Integers](src/main/kotlin/g0301_0400/s0371_sum_of_two_integers)| Medium | Top_Interview_Questions, Math, Bit_Manipulation | 129 | 95.45 -| 0029 |[Divide Two Integers](src/main/kotlin/g0001_0100/s0029_divide_two_integers)| Medium | Top_Interview_Questions, Math, Bit_Manipulation | 281 | 31.67 +| 0136 |[Single Number](src/main/kotlin/g0101_0200/s0136_single_number)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation | 344 | 83.63 -#### Udemy Design +### Algorithm II + +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/kotlin/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 228 | 83.38 +| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 +| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 -### Data Structure I +#### Day 2 Binary Search -#### Day 1 Array +| | | | | | +|-|-|-|-|-|- +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/kotlin/g0101_0200/s0153_find_minimum_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Array, Binary_Search | 262 | 60.96 +| 0162 |[Find Peak Element](src/main/kotlin/g0101_0200/s0162_find_peak_element)| Medium | Top_Interview_Questions, Array, Binary_Search | 297 | 53.85 + +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49 -| 0053 |[Maximum Subarray](src/main/kotlin/g0001_0100/s0053_maximum_subarray)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer | 662 | 82.48 +| 0082 |[Remove Duplicates from Sorted List II](src/main/kotlin/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii)| Medium | Two_Pointers, Linked_List | 241 | 91.04 +| 0015 |[3Sum](src/main/kotlin/g0001_0100/s0015_3sum)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 761 | 90.55 -#### Day 2 Array +#### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 234 | 92.75 -| 0088 |[Merge Sorted Array](src/main/kotlin/g0001_0100/s0088_merge_sorted_array)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 311 | 33.40 +| 0844 |[Backspace String Compare](src/main/kotlin/g0801_0900/s0844_backspace_string_compare)| Easy | String, Two_Pointers, Stack, Simulation | 126 | 98.31 +| 0986 |[Interval List Intersections](src/main/kotlin/g0901_1000/s0986_interval_list_intersections)| Medium | Array, Two_Pointers | 318 | 60.98 +| 0011 |[Container With Most Water](src/main/kotlin/g0001_0100/s0011_container_with_most_water)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers | 474 | 89.18 -#### Day 3 Array +#### Day 5 Sliding Window | | | | | | |-|-|-|-|-|- -| 0350 |[Intersection of Two Arrays II](src/main/kotlin/g0301_0400/s0350_intersection_of_two_arrays_ii)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 321 | 73.37 -| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 +| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window | 561 | 54.68 +| 0713 |[Subarray Product Less Than K](src/main/kotlin/g0701_0800/s0713_subarray_product_less_than_k)| Medium | Array, Sliding_Window | 336 | 92.11 +| 0209 |[Minimum Size Subarray Sum](src/main/kotlin/g0201_0300/s0209_minimum_size_subarray_sum)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 315 | 96.73 -#### Day 4 Array +#### Day 6 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0566 |[Reshape the Matrix](src/main/kotlin/g0501_0600/s0566_reshape_the_matrix)| Easy | Array, Matrix, Simulation | 239 | 99.05 -| 0118 |[Pascal's Triangle](src/main/kotlin/g0101_0200/s0118_pascals_triangle)| Easy | Top_Interview_Questions, Array, Dynamic_Programming | 277 | 33.22 +| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 +| 0547 |[Number of Provinces](src/main/kotlin/g0501_0600/s0547_number_of_provinces)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 229 | 79.73 -#### Day 5 Array +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0036 |[Valid Sudoku](src/main/kotlin/g0001_0100/s0036_valid_sudoku)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 346 | 65.03 -| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 +| 0117 |[Populating Next Right Pointers in Each Node II](src/main/kotlin/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 199 | 94.67 +| 0572 |[Subtree of Another Tree](src/main/kotlin/g0501_0600/s0572_subtree_of_another_tree)| Easy | Depth_First_Search, Tree, Binary_Tree, Hash_Function, String_Matching | 214 | 92.39 -#### Day 6 String +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0387 |[First Unique Character in a String](src/main/kotlin/g0301_0400/s0387_first_unique_character_in_a_string)| Easy | Top_Interview_Questions, String, Hash_Table, Counting, Queue | 369 | 82.68 -| 0383 |[Ransom Note](src/main/kotlin/g0301_0400/s0383_ransom_note)| Easy | String, Hash_Table, Counting | 333 | 79.58 -| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | Top_Interview_Questions, String, Hash_Table, Sorting | 251 | 87.65 +| 0130 |[Surrounded Regions](src/main/kotlin/g0101_0200/s0130_surrounded_regions)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 355 | 84.42 +| 0797 |[All Paths From Source to Target](src/main/kotlin/g0701_0800/s0797_all_paths_from_source_to_target)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 232 | 100.00 -#### Day 7 Linked List +#### Day 9 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/kotlin/g0101_0200/s0141_linked_list_cycle)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 223 | 91.85 -| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 -| 0203 |[Remove Linked List Elements](src/main/kotlin/g0201_0300/s0203_remove_linked_list_elements)| Easy | Linked_List, Recursion | 233 | 91.22 +| 0078 |[Subsets](src/main/kotlin/g0001_0100/s0078_subsets)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking | 191 | 97.44 +| 0090 |[Subsets II](src/main/kotlin/g0001_0100/s0090_subsets_ii)| Medium | Array, Bit_Manipulation, Backtracking | 366 | 58.09 -#### Day 8 Linked List +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 -| 0083 |[Remove Duplicates from Sorted List](src/main/kotlin/g0001_0100/s0083_remove_duplicates_from_sorted_list)| Easy | Linked_List | 274 | 77.82 +| 0047 |[Permutations II](src/main/kotlin/g0001_0100/s0047_permutations_ii)| Medium | Array, Backtracking | 406 | 76.36 +| 0039 |[Combination Sum](src/main/kotlin/g0001_0100/s0039_combination_sum)| Medium | Top_100_Liked_Questions, Array, Backtracking | 317 | 86.85 +| 0040 |[Combination Sum II](src/main/kotlin/g0001_0100/s0040_combination_sum_ii)| Medium | Array, Backtracking | 348 | 80.92 -#### Day 9 Stack Queue +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/kotlin/g0001_0100/s0020_valid_parentheses)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack | 226 | 72.53 -| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86 +| 0017 |[Letter Combinations of a Phone Number](src/main/kotlin/g0001_0100/s0017_letter_combinations_of_a_phone_number)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking | 262 | 73.59 +| 0022 |[Generate Parentheses](src/main/kotlin/g0001_0100/s0022_generate_parentheses)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking | 210 | 78.51 +| 0079 |[Word Search](src/main/kotlin/g0001_0100/s0079_word_search)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking | 463 | 68.49 -#### Day 10 Tree +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0144 |[Binary Tree Preorder Traversal](src/main/kotlin/g0101_0200/s0144_binary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 277 | 37.90 -| 0094 |[Binary Tree Inorder Traversal](src/main/kotlin/g0001_0100/s0094_binary_tree_inorder_traversal)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack | 269 | 38.80 -| 0145 |[Binary Tree Postorder Traversal](src/main/kotlin/g0101_0200/s0145_binary_tree_postorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 211 | 80.00 +| 0213 |[House Robber II](src/main/kotlin/g0201_0300/s0213_house_robber_ii)| Medium | Array, Dynamic_Programming | 257 | 59.62 +| 0055 |[Jump Game](src/main/kotlin/g0001_0100/s0055_jump_game)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 670 | 66.67 -#### Day 11 Tree +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 332 | 67.53 -| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 236 | 83.39 -| 0101 |[Symmetric Tree](src/main/kotlin/g0101_0200/s0101_symmetric_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 190 | 91.36 +| 0045 |[Jump Game II](src/main/kotlin/g0001_0100/s0045_jump_game_ii)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy | 227 | 98.14 +| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics | 209 | 49.18 -#### Day 12 Tree +#### Day 14 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/kotlin/g0201_0300/s0226_invert_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 233 | 54.90 -| 0112 |[Path Sum](src/main/kotlin/g0101_0200/s0112_path_sum)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 322 | 36.41 +| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 +| 0413 |[Arithmetic Slices](src/main/kotlin/g0401_0500/s0413_arithmetic_slices)| Medium | Array, Dynamic_Programming | 156 | 100.00 -#### Day 13 Tree +#### Day 15 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0700 |[Search in a Binary Search Tree](src/main/kotlin/g0601_0700/s0700_search_in_a_binary_search_tree)| Easy | Tree, Binary_Tree, Binary_Search_Tree | 251 | 88.31 -| 0701 |[Insert into a Binary Search Tree](src/main/kotlin/g0701_0800/s0701_insert_into_a_binary_search_tree)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 311 | 79.03 +| 0091 |[Decode Ways](src/main/kotlin/g0001_0100/s0091_decode_ways)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 237 | 76.88 +| 0139 |[Word Break](src/main/kotlin/g0101_0200/s0139_word_break)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization | 197 | 87.17 -#### Day 14 Tree +#### Day 16 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 330 | 41.38 -| 0653 |[Two Sum IV - Input is a BST](src/main/kotlin/g0601_0700/s0653_two_sum_iv_input_is_a_bst)| Easy | Hash_Table, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Two_Pointers, Binary_Search_Tree | 231 | 96.08 -| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/kotlin/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 404 | 75.59 +| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 +| 0673 |[Number of Longest Increasing Subsequence](src/main/kotlin/g0601_0700/s0673_number_of_longest_increasing_subsequence)| Medium | Array, Dynamic_Programming, Segment_Tree, Binary_Indexed_Tree | 226 | 91.67 -### Data Structure II +#### Day 17 Dynamic Programming -#### Day 1 Array +| | | | | | +|-|-|-|-|-|- +| 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming | 307 | 38.36 +| 0583 |[Delete Operation for Two Strings](src/main/kotlin/g0501_0600/s0583_delete_operation_for_two_strings)| Medium | String, Dynamic_Programming | 197 | 100.00 + +#### Day 18 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/kotlin/g0101_0200/s0136_single_number)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation | 344 | 83.63 -| 0169 |[Majority Element](src/main/kotlin/g0101_0200/s0169_majority_element)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer | 460 | 51.25 -| 0015 |[3Sum](src/main/kotlin/g0001_0100/s0015_3sum)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 761 | 90.55 +| 0072 |[Edit Distance](src/main/kotlin/g0001_0100/s0072_edit_distance)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming | 320 | 63.53 +| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search | 332 | 50.68 +| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math | 218 | 63.89 -#### Day 2 Array +#### Day 19 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0075 |[Sort Colors](src/main/kotlin/g0001_0100/s0075_sort_colors)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 198 | 85.66 -| 0056 |[Merge Intervals](src/main/kotlin/g0001_0100/s0056_merge_intervals)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting | 320 | 94.22 -| 0706 |[Design HashMap](src/main/kotlin/g0701_0800/s0706_design_hashmap)| Easy | Array, Hash_Table, Design, Linked_List, Hash_Function | 405 | 92.11 +| 0201 |[Bitwise AND of Numbers Range](src/main/kotlin/g0201_0300/s0201_bitwise_and_of_numbers_range)| Medium | Bit_Manipulation | 368 | 80.00 -#### Day 3 Array +#### Day 20 Others | | | | | | |-|-|-|-|-|- -| 0119 |[Pascal's Triangle II](src/main/kotlin/g0101_0200/s0119_pascals_triangle_ii)| Easy | Array, Dynamic_Programming | 157 | 97.27 -| 0048 |[Rotate Image](src/main/kotlin/g0001_0100/s0048_rotate_image)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix | 287 | 46.50 -| 0059 |[Spiral Matrix II](src/main/kotlin/g0001_0100/s0059_spiral_matrix_ii)| Medium | Array, Matrix, Simulation | 153 | 100.00 +| 0384 |[Shuffle an Array](src/main/kotlin/g0301_0400/s0384_shuffle_an_array)| Medium | Top_Interview_Questions, Array, Math, Randomized | 940 | 72.09 -#### Day 4 Array +#### Day 21 Others | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/kotlin/g0201_0300/s0240_search_a_2d_matrix_ii)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer | 460 | 66.08 -| 0435 |[Non-overlapping Intervals](src/main/kotlin/g0401_0500/s0435_non_overlapping_intervals)| Medium | Array, Dynamic_Programming, Sorting, Greedy | 1040 | 85.07 +| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08 +| 0149 |[Max Points on a Line](src/main/kotlin/g0101_0200/s0149_max_points_on_a_line)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 307 | 83.33 -#### Day 5 Array +### Binary Search I + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0334 |[Increasing Triplet Subsequence](src/main/kotlin/g0301_0400/s0334_increasing_triplet_subsequence)| Medium | Top_Interview_Questions, Array, Greedy | 672 | 60.61 -| 0238 |[Product of Array Except Self](src/main/kotlin/g0201_0300/s0238_product_of_array_except_self)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum | 669 | 48.96 -| 0560 |[Subarray Sum Equals K](src/main/kotlin/g0501_0600/s0560_subarray_sum_equals_k)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum | 692 | 53.27 +| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 +| 0374 |[Guess Number Higher or Lower](src/main/kotlin/g0301_0400/s0374_guess_number_higher_or_lower)| Easy | Binary_Search, Interactive | 134 | 94.19 -#### Day 6 String +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0415 |[Add Strings](src/main/kotlin/g0401_0500/s0415_add_strings)| Easy | String, Math, Simulation | 296 | 76.00 -| 0409 |[Longest Palindrome](src/main/kotlin/g0401_0500/s0409_longest_palindrome)| Easy | String, Hash_Table, Greedy | 259 | 60.71 +| 0035 |[Search Insert Position](src/main/kotlin/g0001_0100/s0035_search_insert_position)| Easy | Top_100_Liked_Questions, Array, Binary_Search | 267 | 50.32 +| 0852 |[Peak Index in a Mountain Array](src/main/kotlin/g0801_0900/s0852_peak_index_in_a_mountain_array)| Easy | Array, Binary_Search | 433 | 94.29 -#### Day 7 String +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0290 |[Word Pattern](src/main/kotlin/g0201_0300/s0290_word_pattern)| Easy | String, Hash_Table | 177 | 89.55 -| 0763 |[Partition Labels](src/main/kotlin/g0701_0800/s0763_partition_labels)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers | 235 | 84.75 +| 0367 |[Valid Perfect Square](src/main/kotlin/g0301_0400/s0367_valid_perfect_square)| Easy | Math, Binary_Search | 137 | 94.55 -#### Day 8 String +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/kotlin/g0001_0100/s0049_group_anagrams)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting | 506 | 86.55 -| 0043 |[Multiply Strings](src/main/kotlin/g0001_0100/s0043_multiply_strings)| Medium | String, Math, Simulation | 390 | 56.25 +| 0069 |[Sqrt(x)](src/main/kotlin/g0001_0100/s0069_sqrtx)| Easy | Top_Interview_Questions, Math, Binary_Search | 153 | 95.75 +| 0744 |[Find Smallest Letter Greater Than Target](src/main/kotlin/g0701_0800/s0744_find_smallest_letter_greater_than_target)| Easy | Array, Binary_Search | 162 | 100.00 -#### Day 9 String +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0187 |[Repeated DNA Sequences](src/main/kotlin/g0101_0200/s0187_repeated_dna_sequences)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 319 | 79.03 -| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 +| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/kotlin/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 228 | 83.38 -#### Day 10 Linked List +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/kotlin/g0001_0100/s0002_add_two_numbers)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion | 417 | 50.44 -| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List | 192 | 63.39 +| 0441 |[Arranging Coins](src/main/kotlin/g0401_0500/s0441_arranging_coins)| Easy | Math, Binary_Search | 150 | 84.21 -#### Day 11 Linked List +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0160 |[Intersection of Two Linked Lists](src/main/kotlin/g0101_0200/s0160_intersection_of_two_linked_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 262 | 83.50 -| 0082 |[Remove Duplicates from Sorted List II](src/main/kotlin/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii)| Medium | Two_Pointers, Linked_List | 241 | 91.04 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/kotlin/g0101_0200/s0167_two_sum_ii_input_array_is_sorted)| Medium | Array, Binary_Search, Two_Pointers | 403 | 68.74 -#### Day 12 Linked List +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0024 |[Swap Nodes in Pairs](src/main/kotlin/g0001_0100/s0024_swap_nodes_in_pairs)| Medium | Top_100_Liked_Questions, Linked_List, Recursion | 149 | 99.39 -| 0707 |[Design Linked List](src/main/kotlin/g0701_0800/s0707_design_linked_list)| Medium | Design, Linked_List | 243 | 100.00 +| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 -#### Day 13 Linked List +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0025 |[Reverse Nodes in k-Group](src/main/kotlin/g0001_0100/s0025_reverse_nodes_in_k_group)| Hard | Top_100_Liked_Questions, Linked_List, Recursion | 194 | 87.72 -| 0143 |[Reorder List](src/main/kotlin/g0101_0200/s0143_reorder_list)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 395 | 82.26 -#### Day 14 Stack Queue +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 +| 0350 |[Intersection of Two Arrays II](src/main/kotlin/g0301_0400/s0350_intersection_of_two_arrays_ii)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 321 | 73.37 +| 0633 |[Sum of Square Numbers](src/main/kotlin/g0601_0700/s0633_sum_of_square_numbers)| Medium | Math, Binary_Search, Two_Pointers | 126 | 100.00 -#### Day 15 Tree +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/kotlin/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 334 | 35.39 -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/kotlin/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer | 370 | 58.31 -| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/kotlin/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 316 | 34.25 +| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 -#### Day 16 Tree +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0199 |[Binary Tree Right Side View](src/main/kotlin/g0101_0200/s0199_binary_tree_right_side_view)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 194 | 92.89 -| 0113 |[Path Sum II](src/main/kotlin/g0101_0200/s0113_path_sum_ii)| Medium | Depth_First_Search, Tree, Binary_Tree, Backtracking | 364 | 78.67 -| 0450 |[Delete Node in a BST](src/main/kotlin/g0401_0500/s0450_delete_node_in_a_bst)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 257 | 84.62 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/kotlin/g0101_0200/s0153_find_minimum_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Array, Binary_Search | 262 | 60.96 -#### Day 17 Tree +### Binary Search II + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/kotlin/g0201_0300/s0230_kth_smallest_element_in_a_bst)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 393 | 33.33 -| 0173 |[Binary Search Tree Iterator](src/main/kotlin/g0101_0200/s0173_binary_search_tree_iterator)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 563 | 46.91 +| 0209 |[Minimum Size Subarray Sum](src/main/kotlin/g0201_0300/s0209_minimum_size_subarray_sum)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 315 | 96.73 +| 0611 |[Valid Triangle Number](src/main/kotlin/g0601_0700/s0611_valid_triangle_number)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 203 | 100.00 -#### Day 18 Tree +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/kotlin/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree | 386 | 45.21 -| 0297 |[Serialize and Deserialize Binary Tree](src/main/kotlin/g0201_0300/s0297_serialize_and_deserialize_binary_tree)| Hard | Top_Interview_Questions, String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 475 | 78.85 +| 0658 |[Find K Closest Elements](src/main/kotlin/g0601_0700/s0658_find_k_closest_elements)| Medium | Array, Sorting, Binary_Search, Two_Pointers, Heap_Priority_Queue | 375 | 95.16 -#### Day 19 Graph +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0997 |[Find the Town Judge](src/main/kotlin/g0901_1000/s0997_find_the_town_judge)| Easy | Array, Hash_Table, Graph | 475 | 58.62 -| 0841 |[Keys and Rooms](src/main/kotlin/g0801_0900/s0841_keys_and_rooms)| Medium | Depth_First_Search, Breadth_First_Search, Graph | 189 | 69.23 +| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 -#### Day 20 Heap Priority Queue +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/kotlin/g0201_0300/s0215_kth_largest_element_in_an_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect | 839 | 34.43 -| 0347 |[Top K Frequent Elements](src/main/kotlin/g0301_0400/s0347_top_k_frequent_elements)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort | 268 | 99.74 +| 0875 |[Koko Eating Bananas](src/main/kotlin/g0801_0900/s0875_koko_eating_bananas)| Medium | Array, Binary_Search | 267 | 93.85 -#### Day 21 Heap Priority Queue +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0451 |[Sort Characters By Frequency](src/main/kotlin/g0401_0500/s0451_sort_characters_by_frequency)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Bucket_Sort | 288 | 81.72 -| 0973 |[K Closest Points to Origin](src/main/kotlin/g0901_1000/s0973_k_closest_points_to_origin)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 800 | 37.89 +| 0287 |[Find the Duplicate Number](src/main/kotlin/g0201_0300/s0287_find_the_duplicate_number)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation | 656 | 66.21 -### Algorithm I +#### Day 6 -#### Day 1 Binary Search +| | | | | | +|-|-|-|-|-|- + +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 -| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86 -| 0035 |[Search Insert Position](src/main/kotlin/g0001_0100/s0035_search_insert_position)| Easy | Top_100_Liked_Questions, Array, Binary_Search | 267 | 50.32 -#### Day 2 Two Pointers +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0977 |[Squares of a Sorted Array](src/main/kotlin/g0901_1000/s0977_squares_of_a_sorted_array)| Easy | Array, Sorting, Two_Pointers | 375 | 18.43 -| 0189 |[Rotate Array](src/main/kotlin/g0101_0200/s0189_rotate_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers | 483 | 86.95 +| 0240 |[Search a 2D Matrix II](src/main/kotlin/g0201_0300/s0240_search_a_2d_matrix_ii)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer | 460 | 66.08 +| 0275 |[H-Index II](src/main/kotlin/g0201_0300/s0275_h_index_ii)| Medium | Array, Binary_Search | 398 | 81.82 -#### Day 3 Two Pointers +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/kotlin/g0201_0300/s0283_move_zeroes)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers | 516 | 79.07 -| 0167 |[Two Sum II - Input Array Is Sorted](src/main/kotlin/g0101_0200/s0167_two_sum_ii_input_array_is_sorted)| Medium | Array, Binary_Search, Two_Pointers | 403 | 68.74 +| 0540 |[Single Element in a Sorted Array](src/main/kotlin/g0501_0600/s0540_single_element_in_a_sorted_array)| Medium | Array, Binary_Search | 274 | 86.67 -#### Day 4 Two Pointers +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0344 |[Reverse String](src/main/kotlin/g0301_0400/s0344_reverse_string)| Easy | Top_Interview_Questions, String, Two_Pointers, Recursion | 445 | 69.75 -| 0557 |[Reverse Words in a String III](src/main/kotlin/g0501_0600/s0557_reverse_words_in_a_string_iii)| Easy | String, Two_Pointers | 215 | 98.10 +| 0222 |[Count Complete Tree Nodes](src/main/kotlin/g0201_0300/s0222_count_complete_tree_nodes)| ||| -#### Day 5 Two Pointers +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52 -| 0019 |[Remove Nth Node From End of List](src/main/kotlin/g0001_0100/s0019_remove_nth_node_from_end_of_list)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List | 180 | 91.58 +| 0826 |[Most Profit Assigning Work](src/main/kotlin/g0801_0900/s0826_most_profit_assigning_work)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 366 | 100.00 +| 0436 |[Find Right Interval](src/main/kotlin/g0401_0500/s0436_find_right_interval)| Medium | Array, Sorting, Binary_Search | 333 | 100.00 -#### Day 6 Sliding Window +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 258 | 91.09 -| 0567 |[Permutation in String](src/main/kotlin/g0501_0600/s0567_permutation_in_string)| Medium | String, Hash_Table, Two_Pointers, Sliding_Window | 169 | 100.00 +| 0081 |[Search in Rotated Sorted Array II](src/main/kotlin/g0001_0100/s0081_search_in_rotated_sorted_array_ii)| Medium | Array, Binary_Search | 352 | 42.31 +| 0162 |[Find Peak Element](src/main/kotlin/g0101_0200/s0162_find_peak_element)| Medium | Top_Interview_Questions, Array, Binary_Search | 297 | 53.85 -#### Day 7 Breadth First Search Depth First Search +#### Day 13 | | | | | | |-|-|-|-|-|- -| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76 -| 0695 |[Max Area of Island](src/main/kotlin/g0601_0700/s0695_max_area_of_island)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 324 | 24.06 +| 0154 |[Find Minimum in Rotated Sorted Array II](src/main/kotlin/g0101_0200/s0154_find_minimum_in_rotated_sorted_array_ii)| Hard | Array, Binary_Search | 275 | 84.00 +| 0528 |[Random Pick with Weight](src/main/kotlin/g0501_0600/s0528_random_pick_with_weight)| Medium | Math, Binary_Search, Prefix_Sum, Randomized | 393 | 91.38 -#### Day 8 Breadth First Search Depth First Search +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0617 |[Merge Two Binary Trees](src/main/kotlin/g0601_0700/s0617_merge_two_binary_trees)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 243 | 72.83 -| 0116 |[Populating Next Right Pointers in Each Node](src/main/kotlin/g0101_0200/s0116_populating_next_right_pointers_in_each_node)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 355 | 69.02 -#### Day 9 Breadth First Search Depth First Search +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0542 |[01 Matrix](src/main/kotlin/g0501_0600/s0542_01_matrix)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 441 | 94.06 -| 0994 |[Rotting Oranges](src/main/kotlin/g0901_1000/s0994_rotting_oranges)| Medium | Array, Breadth_First_Search, Matrix | 164 | 82.95 -#### Day 10 Recursion Backtracking +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 -| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 +| 0981 |[Time Based Key-Value Store](src/main/kotlin/g0901_1000/s0981_time_based_key_value_store)| Medium | String, Hash_Table, Binary_Search, Design | 1555 | 10.00 -#### Day 11 Recursion Backtracking +#### Day 17 | | | | | | |-|-|-|-|-|- -| 0077 |[Combinations](src/main/kotlin/g0001_0100/s0077_combinations)| Medium | Backtracking | 244 | 100.00 -| 0046 |[Permutations](src/main/kotlin/g0001_0100/s0046_permutations)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking | 186 | 100.00 -| 0784 |[Letter Case Permutation](src/main/kotlin/g0701_0800/s0784_letter_case_permutation)| Medium | String, Bit_Manipulation, Backtracking | 219 | 84.62 -#### Day 12 Dynamic Programming +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization | 127 | 97.06 -| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 -| 0120 |[Triangle](src/main/kotlin/g0101_0200/s0120_triangle)| Medium | Array, Dynamic_Programming | 194 | 97.87 +| 1146 |[Snapshot Array](src/main/kotlin/g1101_1200/s1146_snapshot_array)| Medium | Array, Hash_Table, Binary_Search, Design | 1064 | 57.14 -#### Day 13 Bit Manipulation +#### Day 19 | | | | | | |-|-|-|-|-|- -| 0231 |[Power of Two](src/main/kotlin/g0201_0300/s0231_power_of_two)| Easy | Math, Bit_Manipulation, Recursion | 161 | 86.81 -| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44 -#### Day 14 Bit Manipulation +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0190 |[Reverse Bits](src/main/kotlin/g0101_0200/s0190_reverse_bits)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 198 | 81.82 -| 0136 |[Single Number](src/main/kotlin/g0101_0200/s0136_single_number)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation | 344 | 83.63 +| 0911 |[Online Election](src/main/kotlin/g0901_1000/s0911_online_election)| Medium | Array, Hash_Table, Binary_Search, Design | 766 | 83.33 -### Algorithm II +### Dynamic Programming I -#### Day 1 Binary Search +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/kotlin/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 228 | 83.38 -| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 -| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 +| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72 +| 1137 |[N-th Tribonacci Number](src/main/kotlin/g1101_1200/s1137_n_th_tribonacci_number)| Easy | Dynamic_Programming, Math, Memoization | 122 | 69.35 -#### Day 2 Binary Search +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/kotlin/g0101_0200/s0153_find_minimum_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Array, Binary_Search | 262 | 60.96 -| 0162 |[Find Peak Element](src/main/kotlin/g0101_0200/s0162_find_peak_element)| Medium | Top_Interview_Questions, Array, Binary_Search | 297 | 53.85 +| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization | 127 | 97.06 +| 0746 |[Min Cost Climbing Stairs](src/main/kotlin/g0701_0800/s0746_min_cost_climbing_stairs)| Easy | Array, Dynamic_Programming | 171 | 96.76 -#### Day 3 Two Pointers +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0082 |[Remove Duplicates from Sorted List II](src/main/kotlin/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii)| Medium | Two_Pointers, Linked_List | 241 | 91.04 -| 0015 |[3Sum](src/main/kotlin/g0001_0100/s0015_3sum)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 761 | 90.55 +| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 +| 0213 |[House Robber II](src/main/kotlin/g0201_0300/s0213_house_robber_ii)| Medium | Array, Dynamic_Programming | 257 | 59.62 +| 0740 |[Delete and Earn](src/main/kotlin/g0701_0800/s0740_delete_and_earn)| Medium | Array, Hash_Table, Dynamic_Programming | 192 | 100.00 -#### Day 4 Two Pointers +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0844 |[Backspace String Compare](src/main/kotlin/g0801_0900/s0844_backspace_string_compare)| Easy | String, Two_Pointers, Stack, Simulation | 126 | 98.31 -| 0986 |[Interval List Intersections](src/main/kotlin/g0901_1000/s0986_interval_list_intersections)| Medium | Array, Two_Pointers | 318 | 60.98 -| 0011 |[Container With Most Water](src/main/kotlin/g0001_0100/s0011_container_with_most_water)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers | 474 | 89.18 +| 0055 |[Jump Game](src/main/kotlin/g0001_0100/s0055_jump_game)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 670 | 66.67 +| 0045 |[Jump Game II](src/main/kotlin/g0001_0100/s0045_jump_game_ii)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy | 227 | 98.14 -#### Day 5 Sliding Window +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window | 561 | 54.68 -| 0713 |[Subarray Product Less Than K](src/main/kotlin/g0701_0800/s0713_subarray_product_less_than_k)| Medium | Array, Sliding_Window | 336 | 92.11 -| 0209 |[Minimum Size Subarray Sum](src/main/kotlin/g0201_0300/s0209_minimum_size_subarray_sum)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 315 | 96.73 +| 0053 |[Maximum Subarray](src/main/kotlin/g0001_0100/s0053_maximum_subarray)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer | 662 | 82.48 +| 0918 |[Maximum Sum Circular Subarray](src/main/kotlin/g0901_1000/s0918_maximum_sum_circular_subarray)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 339 | 86.96 -#### Day 6 Breadth First Search Depth First Search +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 -| 0547 |[Number of Provinces](src/main/kotlin/g0501_0600/s0547_number_of_provinces)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 229 | 79.73 +| 0152 |[Maximum Product Subarray](src/main/kotlin/g0101_0200/s0152_maximum_product_subarray)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 253 | 88.42 -#### Day 7 Breadth First Search Depth First Search +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0117 |[Populating Next Right Pointers in Each Node II](src/main/kotlin/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 199 | 94.67 -| 0572 |[Subtree of Another Tree](src/main/kotlin/g0501_0600/s0572_subtree_of_another_tree)| Easy | Depth_First_Search, Tree, Binary_Tree, Hash_Function, String_Matching | 214 | 92.39 +| 1014 |[Best Sightseeing Pair](src/main/kotlin/g1001_1100/s1014_best_sightseeing_pair)| Medium | Array, Dynamic_Programming | 336 | 66.67 +| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/kotlin/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 197 | 95.10 -#### Day 8 Breadth First Search Depth First Search +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0130 |[Surrounded Regions](src/main/kotlin/g0101_0200/s0130_surrounded_regions)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 355 | 84.42 -| 0797 |[All Paths From Source to Target](src/main/kotlin/g0701_0800/s0797_all_paths_from_source_to_target)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 232 | 100.00 +| 0309 |[Best Time to Buy and Sell Stock with Cooldown](src/main/kotlin/g0301_0400/s0309_best_time_to_buy_and_sell_stock_with_cooldown)| Medium | Array, Dynamic_Programming | 272 | 73.33 +| 0714 |[Best Time to Buy and Sell Stock with Transaction Fee](src/main/kotlin/g0701_0800/s0714_best_time_to_buy_and_sell_stock_with_transaction_fee)| Medium | Array, Dynamic_Programming, Greedy | 417 | 90.91 -#### Day 9 Recursion Backtracking +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0078 |[Subsets](src/main/kotlin/g0001_0100/s0078_subsets)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking | 191 | 97.44 -| 0090 |[Subsets II](src/main/kotlin/g0001_0100/s0090_subsets_ii)| Medium | Array, Bit_Manipulation, Backtracking | 366 | 58.09 +| 0139 |[Word Break](src/main/kotlin/g0101_0200/s0139_word_break)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization | 197 | 87.17 +| 0042 |[Trapping Rain Water](src/main/kotlin/g0001_0100/s0042_trapping_rain_water)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack | 196 | 100.00 -#### Day 10 Recursion Backtracking +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0047 |[Permutations II](src/main/kotlin/g0001_0100/s0047_permutations_ii)| Medium | Array, Backtracking | 406 | 76.36 -| 0039 |[Combination Sum](src/main/kotlin/g0001_0100/s0039_combination_sum)| Medium | Top_100_Liked_Questions, Array, Backtracking | 317 | 86.85 -| 0040 |[Combination Sum II](src/main/kotlin/g0001_0100/s0040_combination_sum_ii)| Medium | Array, Backtracking | 348 | 80.92 +| 0413 |[Arithmetic Slices](src/main/kotlin/g0401_0500/s0413_arithmetic_slices)| Medium | Array, Dynamic_Programming | 156 | 100.00 +| 0091 |[Decode Ways](src/main/kotlin/g0001_0100/s0091_decode_ways)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 237 | 76.88 -#### Day 11 Recursion Backtracking +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/kotlin/g0001_0100/s0017_letter_combinations_of_a_phone_number)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking | 262 | 73.59 -| 0022 |[Generate Parentheses](src/main/kotlin/g0001_0100/s0022_generate_parentheses)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking | 210 | 78.51 -| 0079 |[Word Search](src/main/kotlin/g0001_0100/s0079_word_search)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking | 463 | 68.49 +| 0264 |[Ugly Number II](src/main/kotlin/g0201_0300/s0264_ugly_number_ii)| Medium | Hash_Table, Dynamic_Programming, Math, Heap_Priority_Queue | 182 | 95.45 +| 0096 |[Unique Binary Search Trees](src/main/kotlin/g0001_0100/s0096_unique_binary_search_trees)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree | 147 | 88.52 -#### Day 12 Dynamic Programming +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0213 |[House Robber II](src/main/kotlin/g0201_0300/s0213_house_robber_ii)| Medium | Array, Dynamic_Programming | 257 | 59.62 -| 0055 |[Jump Game](src/main/kotlin/g0001_0100/s0055_jump_game)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 670 | 66.67 +| 0118 |[Pascal's Triangle](src/main/kotlin/g0101_0200/s0118_pascals_triangle)| Easy | Top_Interview_Questions, Array, Dynamic_Programming | 277 | 33.22 +| 0119 |[Pascal's Triangle II](src/main/kotlin/g0101_0200/s0119_pascals_triangle_ii)| Easy | Array, Dynamic_Programming | 157 | 97.27 -#### Day 13 Dynamic Programming +#### Day 13 | | | | | | |-|-|-|-|-|- -| 0045 |[Jump Game II](src/main/kotlin/g0001_0100/s0045_jump_game_ii)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy | 227 | 98.14 -| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics | 209 | 49.18 +| 0931 |[Minimum Falling Path Sum](src/main/kotlin/g0901_1000/s0931_minimum_falling_path_sum)| Medium | Array, Dynamic_Programming, Matrix | 201 | 84.21 +| 0120 |[Triangle](src/main/kotlin/g0101_0200/s0120_triangle)| Medium | Array, Dynamic_Programming | 194 | 97.87 -#### Day 14 Dynamic Programming +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 -| 0413 |[Arithmetic Slices](src/main/kotlin/g0401_0500/s0413_arithmetic_slices)| Medium | Array, Dynamic_Programming | 156 | 100.00 +| 0304 |[Range Sum Query 2D - Immutable](src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable)| Medium | Array, Matrix, Design, Prefix_Sum | 1373 | 85.71 -#### Day 15 Dynamic Programming +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0091 |[Decode Ways](src/main/kotlin/g0001_0100/s0091_decode_ways)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 237 | 76.88 -| 0139 |[Word Break](src/main/kotlin/g0101_0200/s0139_word_break)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization | 197 | 87.17 +| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics | 209 | 49.18 +| 0063 |[Unique Paths II](src/main/kotlin/g0001_0100/s0063_unique_paths_ii)| Medium | Array, Dynamic_Programming, Matrix | 187 | 84.62 -#### Day 16 Dynamic Programming +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 -| 0673 |[Number of Longest Increasing Subsequence](src/main/kotlin/g0601_0700/s0673_number_of_longest_increasing_subsequence)| Medium | Array, Dynamic_Programming, Segment_Tree, Binary_Indexed_Tree | 226 | 91.67 +| 0064 |[Minimum Path Sum](src/main/kotlin/g0001_0100/s0064_minimum_path_sum)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix | 222 | 95.70 +| 0221 |[Maximal Square](src/main/kotlin/g0201_0300/s0221_maximal_square)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix | 614 | 44.00 -#### Day 17 Dynamic Programming +#### Day 17 | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming | 307 | 38.36 -| 0583 |[Delete Operation for Two Strings](src/main/kotlin/g0501_0600/s0583_delete_operation_for_two_strings)| Medium | String, Dynamic_Programming | 197 | 100.00 +| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 +| 0516 |[Longest Palindromic Subsequence](src/main/kotlin/g0501_0600/s0516_longest_palindromic_subsequence)| Medium | String, Dynamic_Programming | 243 | 87.50 -#### Day 18 Dynamic Programming +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/kotlin/g0001_0100/s0072_edit_distance)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming | 320 | 63.53 -| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search | 332 | 50.68 -| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math | 218 | 63.89 +| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 +| 0376 |[Wiggle Subsequence](src/main/kotlin/g0301_0400/s0376_wiggle_subsequence)| Medium | Array, Dynamic_Programming, Greedy | 162 | 88.89 -#### Day 19 Bit Manipulation +#### Day 19 | | | | | | |-|-|-|-|-|- -| 0201 |[Bitwise AND of Numbers Range](src/main/kotlin/g0201_0300/s0201_bitwise_and_of_numbers_range)| Medium | Bit_Manipulation | 368 | 80.00 +| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74 +| 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming | 307 | 38.36 +| 0072 |[Edit Distance](src/main/kotlin/g0001_0100/s0072_edit_distance)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming | 320 | 63.53 -#### Day 20 Others +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0384 |[Shuffle an Array](src/main/kotlin/g0301_0400/s0384_shuffle_an_array)| Medium | Top_Interview_Questions, Array, Math, Randomized | 940 | 72.09 +| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search | 332 | 50.68 +| 0518 |[Coin Change II](src/main/kotlin/g0501_0600/s0518_coin_change_2)| Medium | Array, Dynamic_Programming | 139 | 100.00 -#### Day 21 Others +#### Day 21 | | | | | | |-|-|-|-|-|- -| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08 -| 0149 |[Max Points on a Line](src/main/kotlin/g0101_0200/s0149_max_points_on_a_line)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 307 | 83.33 +| 0377 |[Combination Sum IV](src/main/kotlin/g0301_0400/s0377_combination_sum_iv)| Medium | Array, Dynamic_Programming | 217 | 72.41 +| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math | 218 | 63.89 +| 0279 |[Perfect Squares](src/main/kotlin/g0201_0300/s0279_perfect_squares)| Medium | Top_Interview_Questions, Dynamic_Programming, Math, Breadth_First_Search | 176 | 98.80 -### Binary Search I +### Programming Skills I -#### Day 1 +#### Day 1 Basic Data Type | | | | | | |-|-|-|-|-|- -| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 -| 0374 |[Guess Number Higher or Lower](src/main/kotlin/g0301_0400/s0374_guess_number_higher_or_lower)| Easy | Binary_Search, Interactive | 134 | 94.19 -#### Day 2 +#### Day 2 Operator | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/kotlin/g0001_0100/s0035_search_insert_position)| Easy | Top_100_Liked_Questions, Array, Binary_Search | 267 | 50.32 -| 0852 |[Peak Index in a Mountain Array](src/main/kotlin/g0801_0900/s0852_peak_index_in_a_mountain_array)| Easy | Array, Binary_Search | 433 | 94.29 +| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44 -#### Day 3 +#### Day 3 Conditional Statements | | | | | | |-|-|-|-|-|- -| 0367 |[Valid Perfect Square](src/main/kotlin/g0301_0400/s0367_valid_perfect_square)| Easy | Math, Binary_Search | 137 | 94.55 +| 0976 |[Largest Perimeter Triangle](src/main/kotlin/g0901_1000/s0976_largest_perimeter_triangle)| Easy | Array, Math, Sorting, Greedy | 304 | 33.33 -#### Day 4 +#### Day 4 Loop | | | | | | |-|-|-|-|-|- -| 0069 |[Sqrt(x)](src/main/kotlin/g0001_0100/s0069_sqrtx)| Easy | Top_Interview_Questions, Math, Binary_Search | 153 | 95.75 -| 0744 |[Find Smallest Letter Greater Than Target](src/main/kotlin/g0701_0800/s0744_find_smallest_letter_greater_than_target)| Easy | Array, Binary_Search | 162 | 100.00 +| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08 -#### Day 5 +#### Day 5 Function | | | | | | |-|-|-|-|-|- -| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86 -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/kotlin/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 228 | 83.38 +| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02 +| 0496 |[Next Greater Element I](src/main/kotlin/g0401_0500/s0496_next_greater_element_i)| Easy | Array, Hash_Table, Stack, Monotonic_Stack | 171 | 100.00 -#### Day 6 +#### Day 6 Array | | | | | | |-|-|-|-|-|- -| 0441 |[Arranging Coins](src/main/kotlin/g0401_0500/s0441_arranging_coins)| Easy | Math, Binary_Search | 150 | 84.21 +| 0283 |[Move Zeroes](src/main/kotlin/g0201_0300/s0283_move_zeroes)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers | 516 | 79.07 -#### Day 7 +#### Day 7 Array | | | | | | |-|-|-|-|-|- -| 0167 |[Two Sum II - Input Array Is Sorted](src/main/kotlin/g0101_0200/s0167_two_sum_ii_input_array_is_sorted)| Medium | Array, Binary_Search, Two_Pointers | 403 | 68.74 +| 0566 |[Reshape the Matrix](src/main/kotlin/g0501_0600/s0566_reshape_the_matrix)| Easy | Array, Matrix, Simulation | 239 | 99.05 -#### Day 8 +#### Day 8 String | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 +| 0389 |[Find the Difference](src/main/kotlin/g0301_0400/s0389_find_the_difference)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 256 | 64.81 -#### Day 9 +#### Day 9 String | | | | | | |-|-|-|-|-|- +| 0709 |[To Lower Case](src/main/kotlin/g0701_0800/s0709_to_lower_case)| Easy | String | 142 | 98.68 +| 0953 |[Verifying an Alien Dictionary](src/main/kotlin/g0901_1000/s0953_verifying_an_alien_dictionary)| Easy | Array, String, Hash_Table | 137 | 100.00 -#### Day 10 +#### Day 10 Linked List and Tree | | | | | | |-|-|-|-|-|- -| 0350 |[Intersection of Two Arrays II](src/main/kotlin/g0301_0400/s0350_intersection_of_two_arrays_ii)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 321 | 73.37 -| 0633 |[Sum of Square Numbers](src/main/kotlin/g0601_0700/s0633_sum_of_square_numbers)| Medium | Math, Binary_Search, Two_Pointers | 126 | 100.00 +| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52 +| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 236 | 83.39 +| 0404 |[Sum of Left Leaves](src/main/kotlin/g0401_0500/s0404_sum_of_left_leaves)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 173 | 86.05 -#### Day 11 +#### Day 11 Containers and Libraries | | | | | | |-|-|-|-|-|- -| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 +| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86 +| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | Top_Interview_Questions, String, Hash_Table, Sorting | 251 | 87.65 +| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49 -#### Day 12 +#### Day 12 Class and Object | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/kotlin/g0101_0200/s0153_find_minimum_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Array, Binary_Search | 262 | 60.96 +| 0303 |[Range Sum Query - Immutable](src/main/kotlin/g0301_0400/s0303_range_sum_query_immutable)| Easy | Array, Design, Prefix_Sum | 472 | 63.64 -### Binary Search II +### Programming Skills II #### Day 1 | | | | | | |-|-|-|-|-|- -| 0209 |[Minimum Size Subarray Sum](src/main/kotlin/g0201_0300/s0209_minimum_size_subarray_sum)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 315 | 96.73 -| 0611 |[Valid Triangle Number](src/main/kotlin/g0601_0700/s0611_valid_triangle_number)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 203 | 100.00 +| 0896 |[Monotonic Array](src/main/kotlin/g0801_0900/s0896_monotonic_array)| Easy | Array | 576 | 90.91 +| 0028 |[Find the Index of the First Occurrence in a String](src/main/kotlin/g0001_0100/s0028_implement_strstr)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 257 | 32.35 #### Day 2 | | | | | | |-|-|-|-|-|- -| 0658 |[Find K Closest Elements](src/main/kotlin/g0601_0700/s0658_find_k_closest_elements)| Medium | Array, Sorting, Binary_Search, Two_Pointers, Heap_Priority_Queue | 375 | 95.16 +| 0110 |[Balanced Binary Tree](src/main/kotlin/g0101_0200/s0110_balanced_binary_tree)| Easy | Depth_First_Search, Tree, Binary_Tree | 310 | 63.63 +| 0459 |[Repeated Substring Pattern](src/main/kotlin/g0401_0500/s0459_repeated_substring_pattern)| Easy | String, String_Matching | 201 | 100.00 #### Day 3 | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 +| 0150 |[Evaluate Reverse Polish Notation](src/main/kotlin/g0101_0200/s0150_evaluate_reverse_polish_notation)| Medium | Top_Interview_Questions, Array, Math, Stack | 233 | 88.82 +| 0066 |[Plus One](src/main/kotlin/g0001_0100/s0066_plus_one)| Easy | Top_Interview_Questions, Array, Math | 303 | 35.18 #### Day 4 | | | | | | |-|-|-|-|-|- -| 0875 |[Koko Eating Bananas](src/main/kotlin/g0801_0900/s0875_koko_eating_bananas)| Medium | Array, Binary_Search | 267 | 93.85 +| 0043 |[Multiply Strings](src/main/kotlin/g0001_0100/s0043_multiply_strings)| Medium | String, Math, Simulation | 390 | 56.25 #### Day 5 | | | | | | |-|-|-|-|-|- -| 0287 |[Find the Duplicate Number](src/main/kotlin/g0201_0300/s0287_find_the_duplicate_number)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation | 656 | 66.21 +| 0067 |[Add Binary](src/main/kotlin/g0001_0100/s0067_add_binary)| Easy | String, Math, Bit_Manipulation, Simulation | 327 | 32.67 +| 0989 |[Add to Array-Form of Integer](src/main/kotlin/g0901_1000/s0989_add_to_array_form_of_integer)| Easy | Array, Math | 350 | 70.00 #### Day 6 | | | | | | |-|-|-|-|-|- +| 0739 |[Daily Temperatures](src/main/kotlin/g0701_0800/s0739_daily_temperatures)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack | 936 | 80.54 +| 0058 |[Length of Last Word](src/main/kotlin/g0001_0100/s0058_length_of_last_word)| Easy | String | 243 | 63.33 #### Day 7 | | | | | | |-|-|-|-|-|- +| 0048 |[Rotate Image](src/main/kotlin/g0001_0100/s0048_rotate_image)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix | 287 | 46.50 #### Day 8 | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/kotlin/g0201_0300/s0240_search_a_2d_matrix_ii)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer | 460 | 66.08 -| 0275 |[H-Index II](src/main/kotlin/g0201_0300/s0275_h_index_ii)| Medium | Array, Binary_Search | 398 | 81.82 +| 0054 |[Spiral Matrix](src/main/kotlin/g0001_0100/s0054_spiral_matrix)| Medium | Top_Interview_Questions, Array, Matrix, Simulation | 224 | 62.50 +| 0973 |[K Closest Points to Origin](src/main/kotlin/g0901_1000/s0973_k_closest_points_to_origin)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 800 | 37.89 #### Day 9 | | | | | | |-|-|-|-|-|- -| 0540 |[Single Element in a Sorted Array](src/main/kotlin/g0501_0600/s0540_single_element_in_a_sorted_array)| Medium | Array, Binary_Search | 274 | 86.67 +| 0429 |[N-ary Tree Level Order Traversal](src/main/kotlin/g0401_0500/s0429_n_ary_tree_level_order_traversal)| Medium | Breadth_First_Search, Tree | 248 | 75.86 #### Day 10 | | | | | | |-|-|-|-|-|- -| 0222 |[Count Complete Tree Nodes](src/main/kotlin/g0201_0300/s0222_count_complete_tree_nodes)| ||| +| 0503 |[Next Greater Element II](src/main/kotlin/g0501_0600/s0503_next_greater_element_ii)| Medium | Array, Stack, Monotonic_Stack | 331 | 92.68 +| 0556 |[Next Greater Element III](src/main/kotlin/g0501_0600/s0556_next_greater_element_iii)| Medium | String, Math, Two_Pointers | 137 | 80.00 #### Day 11 | | | | | | |-|-|-|-|-|- -| 0826 |[Most Profit Assigning Work](src/main/kotlin/g0801_0900/s0826_most_profit_assigning_work)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 366 | 100.00 -| 0436 |[Find Right Interval](src/main/kotlin/g0401_0500/s0436_find_right_interval)| Medium | Array, Sorting, Binary_Search | 333 | 100.00 +| 0049 |[Group Anagrams](src/main/kotlin/g0001_0100/s0049_group_anagrams)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting | 506 | 86.55 #### Day 12 | | | | | | |-|-|-|-|-|- -| 0081 |[Search in Rotated Sorted Array II](src/main/kotlin/g0001_0100/s0081_search_in_rotated_sorted_array_ii)| Medium | Array, Binary_Search | 352 | 42.31 -| 0162 |[Find Peak Element](src/main/kotlin/g0101_0200/s0162_find_peak_element)| Medium | Top_Interview_Questions, Array, Binary_Search | 297 | 53.85 +| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window | 561 | 54.68 +| 0713 |[Subarray Product Less Than K](src/main/kotlin/g0701_0800/s0713_subarray_product_less_than_k)| Medium | Array, Sliding_Window | 336 | 92.11 #### Day 13 | | | | | | |-|-|-|-|-|- -| 0154 |[Find Minimum in Rotated Sorted Array II](src/main/kotlin/g0101_0200/s0154_find_minimum_in_rotated_sorted_array_ii)| Hard | Array, Binary_Search | 275 | 84.00 -| 0528 |[Random Pick with Weight](src/main/kotlin/g0501_0600/s0528_random_pick_with_weight)| Medium | Math, Binary_Search, Prefix_Sum, Randomized | 393 | 91.38 +| 0304 |[Range Sum Query 2D - Immutable](src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable)| Medium | Array, Matrix, Design, Prefix_Sum | 1373 | 85.71 +| 0910 |[Smallest Range II](src/main/kotlin/g0901_1000/s0910_smallest_range_ii)| Medium | Array, Math, Sorting, Greedy | 234 | 100.00 #### Day 14 | | | | | | |-|-|-|-|-|- +| 0143 |[Reorder List](src/main/kotlin/g0101_0200/s0143_reorder_list)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 395 | 82.26 +| 0138 |[Copy List with Random Pointer](src/main/kotlin/g0101_0200/s0138_copy_list_with_random_pointer)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List | 274 | 80.58 #### Day 15 | | | | | | |-|-|-|-|-|- +| 0002 |[Add Two Numbers](src/main/kotlin/g0001_0100/s0002_add_two_numbers)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion | 417 | 50.44 +| 0445 |[Add Two Numbers II](src/main/kotlin/g0401_0500/s0445_add_two_numbers_ii)| Medium | Math, Stack, Linked_List | 240 | 82.61 #### Day 16 | | | | | | |-|-|-|-|-|- -| 0981 |[Time Based Key-Value Store](src/main/kotlin/g0901_1000/s0981_time_based_key_value_store)| Medium | String, Hash_Table, Binary_Search, Design | 1555 | 10.00 +| 0061 |[Rotate List](src/main/kotlin/g0001_0100/s0061_rotate_list)| Medium | Two_Pointers, Linked_List | 193 | 92.16 +| 0173 |[Binary Search Tree Iterator](src/main/kotlin/g0101_0200/s0173_binary_search_tree_iterator)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 563 | 46.91 #### Day 17 | | | | | | |-|-|-|-|-|- +| 0860 |[Lemonade Change](src/main/kotlin/g0801_0900/s0860_lemonade_change)| Easy | Array, Greedy | 413 | 86.96 #### Day 18 | | | | | | |-|-|-|-|-|- +| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 +| 0341 |[Flatten Nested List Iterator](src/main/kotlin/g0301_0400/s0341_flatten_nested_list_iterator)| Medium | Top_Interview_Questions, Depth_First_Search, Tree, Stack, Design, Queue, Iterator | 210 | 100.00 #### Day 19 | | | | | | |-|-|-|-|-|- +| 0707 |[Design Linked List](src/main/kotlin/g0701_0800/s0707_design_linked_list)| Medium | Design, Linked_List | 243 | 100.00 #### Day 20 | | | | | | |-|-|-|-|-|- -| 0911 |[Online Election](src/main/kotlin/g0901_1000/s0911_online_election)| Medium | Array, Hash_Table, Binary_Search, Design | 766 | 83.33 - -### Dynamic Programming I - -#### Day 1 - -| | | | | | -|-|-|-|-|-|- -| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72 - -#### Day 2 - -| | | | | | -|-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization | 127 | 97.06 -| 0746 |[Min Cost Climbing Stairs](src/main/kotlin/g0701_0800/s0746_min_cost_climbing_stairs)| Easy | Array, Dynamic_Programming | 171 | 96.76 - -#### Day 3 +| 0380 |[Insert Delete GetRandom O(1)](src/main/kotlin/g0301_0400/s0380_insert_delete_getrandom_o1)| Medium | Top_Interview_Questions, Array, Hash_Table, Math, Design, Randomized | 1326 | 68.23 +| 0622 |[Design Circular Queue](src/main/kotlin/g0601_0700/s0622_design_circular_queue)| Medium | Array, Design, Linked_List, Queue | 234 | 92.68 +| 0729 |[My Calendar I](src/main/kotlin/g0701_0800/s0729_my_calendar_i)| Medium | Binary_Search, Design, Ordered_Set, Segment_Tree | 378 | 69.70 -| | | | | | -|-|-|-|-|-|- -| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 -| 0213 |[House Robber II](src/main/kotlin/g0201_0300/s0213_house_robber_ii)| Medium | Array, Dynamic_Programming | 257 | 59.62 -| 0740 |[Delete and Earn](src/main/kotlin/g0701_0800/s0740_delete_and_earn)| Medium | Array, Hash_Table, Dynamic_Programming | 192 | 100.00 +### Graph Theory I -#### Day 4 +#### Day 1 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/kotlin/g0001_0100/s0055_jump_game)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 670 | 66.67 -| 0045 |[Jump Game II](src/main/kotlin/g0001_0100/s0045_jump_game_ii)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy | 227 | 98.14 +| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76 +| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 -#### Day 5 +#### Day 2 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/kotlin/g0001_0100/s0053_maximum_subarray)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer | 662 | 82.48 -| 0918 |[Maximum Sum Circular Subarray](src/main/kotlin/g0901_1000/s0918_maximum_sum_circular_subarray)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 339 | 86.96 +| 0695 |[Max Area of Island](src/main/kotlin/g0601_0700/s0695_max_area_of_island)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 324 | 24.06 -#### Day 6 +#### Day 3 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0152 |[Maximum Product Subarray](src/main/kotlin/g0101_0200/s0152_maximum_product_subarray)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 253 | 88.42 +| 1020 |[Number of Enclaves](src/main/kotlin/g1001_1100/s1020_number_of_enclaves)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 369 | 76.26 -#### Day 7 +#### Day 4 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 1014 |[Best Sightseeing Pair](src/main/kotlin/g1001_1100/s1014_best_sightseeing_pair)| Medium | Array, Dynamic_Programming | 336 | 66.67 -| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 -| 0122 |[Best Time to Buy and Sell Stock II](src/main/kotlin/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 197 | 95.10 +| 1162 |[As Far from Land as Possible](src/main/kotlin/g1101_1200/s1162_as_far_from_land_as_possible)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 362 | 81.25 +| 0417 |[Pacific Atlantic Water Flow](src/main/kotlin/g0401_0500/s0417_pacific_atlantic_water_flow)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 319 | 100.00 -#### Day 8 +#### Day 5 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0309 |[Best Time to Buy and Sell Stock with Cooldown](src/main/kotlin/g0301_0400/s0309_best_time_to_buy_and_sell_stock_with_cooldown)| Medium | Array, Dynamic_Programming | 272 | 73.33 -| 0714 |[Best Time to Buy and Sell Stock with Transaction Fee](src/main/kotlin/g0701_0800/s0714_best_time_to_buy_and_sell_stock_with_transaction_fee)| Medium | Array, Dynamic_Programming, Greedy | 417 | 90.91 +| 0542 |[01 Matrix](src/main/kotlin/g0501_0600/s0542_01_matrix)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 441 | 94.06 -#### Day 9 +#### Day 6 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/kotlin/g0101_0200/s0139_word_break)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization | 197 | 87.17 -| 0042 |[Trapping Rain Water](src/main/kotlin/g0001_0100/s0042_trapping_rain_water)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack | 196 | 100.00 +| 0934 |[Shortest Bridge](src/main/kotlin/g0901_1000/s0934_shortest_bridge)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 301 | 80.95 -#### Day 10 +#### Day 7 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0413 |[Arithmetic Slices](src/main/kotlin/g0401_0500/s0413_arithmetic_slices)| Medium | Array, Dynamic_Programming | 156 | 100.00 -| 0091 |[Decode Ways](src/main/kotlin/g0001_0100/s0091_decode_ways)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 237 | 76.88 +| 0797 |[All Paths From Source to Target](src/main/kotlin/g0701_0800/s0797_all_paths_from_source_to_target)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 232 | 100.00 +| 0841 |[Keys and Rooms](src/main/kotlin/g0801_0900/s0841_keys_and_rooms)| Medium | Depth_First_Search, Breadth_First_Search, Graph | 189 | 69.23 -#### Day 11 +#### Day 8 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0264 |[Ugly Number II](src/main/kotlin/g0201_0300/s0264_ugly_number_ii)| Medium | Hash_Table, Dynamic_Programming, Math, Heap_Priority_Queue | 182 | 95.45 -| 0096 |[Unique Binary Search Trees](src/main/kotlin/g0001_0100/s0096_unique_binary_search_trees)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree | 147 | 88.52 +| 0547 |[Number of Provinces](src/main/kotlin/g0501_0600/s0547_number_of_provinces)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 229 | 79.73 -#### Day 12 +#### Day 9 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0118 |[Pascal's Triangle](src/main/kotlin/g0101_0200/s0118_pascals_triangle)| Easy | Top_Interview_Questions, Array, Dynamic_Programming | 277 | 33.22 -| 0119 |[Pascal's Triangle II](src/main/kotlin/g0101_0200/s0119_pascals_triangle_ii)| Easy | Array, Dynamic_Programming | 157 | 97.27 +| 0802 |[Find Eventual Safe States](src/main/kotlin/g0801_0900/s0802_find_eventual_safe_states)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 511 | 100.00 -#### Day 13 +#### Day 10 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0931 |[Minimum Falling Path Sum](src/main/kotlin/g0901_1000/s0931_minimum_falling_path_sum)| Medium | Array, Dynamic_Programming, Matrix | 201 | 84.21 -| 0120 |[Triangle](src/main/kotlin/g0101_0200/s0120_triangle)| Medium | Array, Dynamic_Programming | 194 | 97.87 +| 1129 |[Shortest Path with Alternating Colors](src/main/kotlin/g1101_1200/s1129_shortest_path_with_alternating_colors)| Medium | Breadth_First_Search, Graph | 241 | 16.67 +| 0847 |[Shortest Path Visiting All Nodes](src/main/kotlin/g0801_0900/s0847_shortest_path_visiting_all_nodes)| Hard | Dynamic_Programming, Breadth_First_Search, Bit_Manipulation, Graph, Bitmask | 164 | 100.00 -#### Day 14 +#### Day 11 Breadth First Search | | | | | | |-|-|-|-|-|- -| 0304 |[Range Sum Query 2D - Immutable](src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable)| Medium | Array, Matrix, Design, Prefix_Sum | 1373 | 85.71 +| 0365 |[Water and Jug Problem](src/main/kotlin/g0301_0400/s0365_water_and_jug_problem)| Medium | Math, Depth_First_Search, Breadth_First_Search | 130 | 100.00 -#### Day 15 +#### Day 12 Breadth First Search | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics | 209 | 49.18 -| 0063 |[Unique Paths II](src/main/kotlin/g0001_0100/s0063_unique_paths_ii)| Medium | Array, Dynamic_Programming, Matrix | 187 | 84.62 +| 0433 |[Minimum Genetic Mutation](src/main/kotlin/g0401_0500/s0433_minimum_genetic_mutation)| Medium | String, Hash_Table, Breadth_First_Search | 204 | 82.08 +| 0752 |[Open the Lock](src/main/kotlin/g0701_0800/s0752_open_the_lock)| Medium | Array, String, Hash_Table, Breadth_First_Search | 310 | 100.00 +| 0127 |[Word Ladder](src/main/kotlin/g0101_0200/s0127_word_ladder)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 396 | 98.68 -#### Day 16 +#### Day 13 Graph Theory | | | | | | |-|-|-|-|-|- -| 0064 |[Minimum Path Sum](src/main/kotlin/g0001_0100/s0064_minimum_path_sum)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix | 222 | 95.70 -| 0221 |[Maximal Square](src/main/kotlin/g0201_0300/s0221_maximal_square)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix | 614 | 44.00 +| 0997 |[Find the Town Judge](src/main/kotlin/g0901_1000/s0997_find_the_town_judge)| Easy | Array, Hash_Table, Graph | 475 | 58.62 -#### Day 17 +#### Day 14 Graph Theory | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 -| 0516 |[Longest Palindromic Subsequence](src/main/kotlin/g0501_0600/s0516_longest_palindromic_subsequence)| Medium | String, Dynamic_Programming | 243 | 87.50 +| 0886 |[Possible Bipartition](src/main/kotlin/g0801_0900/s0886_possible_bipartition)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 397 | 100.00 +| 0785 |[Is Graph Bipartite?](src/main/kotlin/g0701_0800/s0785_is_graph_bipartite)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 215 | 82.35 -#### Day 18 +### SQL I + +#### Day 1 Select | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 -| 0376 |[Wiggle Subsequence](src/main/kotlin/g0301_0400/s0376_wiggle_subsequence)| Medium | Array, Dynamic_Programming, Greedy | 162 | 88.89 +| 0595 |[Big Countries](src/main/kotlin/g0501_0600/s0595_big_countries)| Easy | Database | 417 | 56.09 +| 0584 |[Find Customer Referee](src/main/kotlin/g0501_0600/s0584_find_customer_referee)| Easy | Database | 779 | 43.48 +| 0183 |[Customers Who Never Order](src/main/kotlin/g0101_0200/s0183_customers_who_never_order)| Easy | Database | 712 | 33.67 -#### Day 19 +#### Day 2 Select and Order | | | | | | |-|-|-|-|-|- -| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74 -| 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming | 307 | 38.36 -| 0072 |[Edit Distance](src/main/kotlin/g0001_0100/s0072_edit_distance)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming | 320 | 63.53 +| 0627 |[Swap Salary](src/main/kotlin/g0601_0700/s0627_swap_salary)| Easy | Database | 400 | 51.04 +| 0196 |[Delete Duplicate Emails](src/main/kotlin/g0101_0200/s0196_delete_duplicate_emails)| Easy | Database | 593 | 94.17 -#### Day 20 +#### Day 3 String Processing Functions | | | | | | |-|-|-|-|-|- -| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search | 332 | 50.68 -| 0518 |[Coin Change II](src/main/kotlin/g0501_0600/s0518_coin_change_2)| Medium | Array, Dynamic_Programming | 139 | 100.00 -#### Day 21 +#### Day 4 Union and Select | | | | | | |-|-|-|-|-|- -| 0377 |[Combination Sum IV](src/main/kotlin/g0301_0400/s0377_combination_sum_iv)| Medium | Array, Dynamic_Programming | 217 | 72.41 -| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math | 218 | 63.89 -| 0279 |[Perfect Squares](src/main/kotlin/g0201_0300/s0279_perfect_squares)| Medium | Top_Interview_Questions, Dynamic_Programming, Math, Breadth_First_Search | 176 | 98.80 - -### Programming Skills I +| 0608 |[Tree Node](src/main/kotlin/g0601_0700/s0608_tree_node)| Medium | LeetCode_Curated_SQL_70, Database | 794 | 48.38 +| 0176 |[Second Highest Salary](src/main/kotlin/g0101_0200/s0176_second_highest_salary)| Medium | Database | 219 | 92.54 -#### Day 1 Basic Data Type +#### Day 5 Union | | | | | | |-|-|-|-|-|- +| 0175 |[Combine Two Tables](src/main/kotlin/g0101_0200/s0175_combine_two_tables)| Easy | Database | 473 | 54.97 +| 1148 |[Article Views I](src/main/kotlin/g1101_1200/s1148_article_views_i)| Easy | LeetCode_Curated_SQL_70, Database | 806 | 54.41 -#### Day 2 Operator +#### Day 6 Union | | | | | | |-|-|-|-|-|- -| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44 +| 0197 |[Rising Temperature](src/main/kotlin/g0101_0200/s0197_rising_temperature)| Easy | Database | 394 | 94.15 +| 0607 |[Sales Person](src/main/kotlin/g0601_0700/s0607_sales_person)| Easy | LeetCode_Curated_SQL_70, Database | 2142 | 44.56 -#### Day 3 Conditional Statements +#### Day 7 Function | | | | | | |-|-|-|-|-|- -| 0976 |[Largest Perimeter Triangle](src/main/kotlin/g0901_1000/s0976_largest_perimeter_triangle)| Easy | Array, Math, Sorting, Greedy | 304 | 33.33 +| 1141 |[User Activity for the Past 30 Days I](src/main/kotlin/g1101_1200/s1141_user_activity_for_the_past_30_days_i)| Easy | LeetCode_Curated_SQL_70, Database | 790 | 87.11 -#### Day 4 Loop +#### Day 8 Function | | | | | | |-|-|-|-|-|- -| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08 +| 0586 |[Customer Placing the Largest Number of Orders](src/main/kotlin/g0501_0600/s0586_customer_placing_the_largest_number_of_orders)| Easy | LeetCode_Curated_SQL_70, Database | 768 | 44.85 +| 0511 |[Game Play Analysis I](src/main/kotlin/g0501_0600/s0511_game_play_analysis_i)| Easy | LeetCode_Curated_SQL_70, Database | 790 | 45.04 -#### Day 5 Function +#### Day 9 Control of Flow | | | | | | |-|-|-|-|-|- -| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02 -| 0496 |[Next Greater Element I](src/main/kotlin/g0401_0500/s0496_next_greater_element_i)| Easy | Array, Hash_Table, Stack, Monotonic_Stack | 171 | 100.00 +| 1158 |[Market Analysis I](src/main/kotlin/g1101_1200/s1158_market_analysis_i)| Medium | Database | 2470 | 44.76 -#### Day 6 Array +#### Day 10 Where | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/kotlin/g0201_0300/s0283_move_zeroes)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers | 516 | 79.07 +| 0182 |[Duplicate Emails](src/main/kotlin/g0101_0200/s0182_duplicate_emails)| Easy | Database | 396 | 68.40 +| 1050 |[Actors and Directors Who Cooperated At Least Three Times](src/main/kotlin/g1001_1100/s1050_actors_and_directors_who_cooperated_at_least_three_times)| Easy | LeetCode_Curated_SQL_70, Database | 629 | 81.02 -#### Day 7 Array +### Level 1 + +#### Day 1 Prefix Sum | | | | | | |-|-|-|-|-|- -| 0566 |[Reshape the Matrix](src/main/kotlin/g0501_0600/s0566_reshape_the_matrix)| Easy | Array, Matrix, Simulation | 239 | 99.05 +| 0724 |[Find Pivot Index](src/main/kotlin/g0701_0800/s0724_find_pivot_index)| Easy | Array, Prefix_Sum | 255 | 88.92 -#### Day 8 String +#### Day 2 String | | | | | | |-|-|-|-|-|- -| 0389 |[Find the Difference](src/main/kotlin/g0301_0400/s0389_find_the_difference)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 256 | 64.81 +| 0205 |[Isomorphic Strings](src/main/kotlin/g0201_0300/s0205_isomorphic_strings)| Easy | String, Hash_Table | 278 | 79.96 +| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74 -#### Day 9 String +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- -| 0709 |[To Lower Case](src/main/kotlin/g0701_0800/s0709_to_lower_case)| Easy | String | 142 | 98.68 -| 0953 |[Verifying an Alien Dictionary](src/main/kotlin/g0901_1000/s0953_verifying_an_alien_dictionary)| Easy | Array, String, Hash_Table | 137 | 100.00 +| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 +| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 -#### Day 10 Linked List and Tree +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- | 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52 -| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 236 | 83.39 -| 0404 |[Sum of Left Leaves](src/main/kotlin/g0401_0500/s0404_sum_of_left_leaves)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 173 | 86.05 +| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List | 192 | 63.39 -#### Day 11 Containers and Libraries +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- -| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86 -| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | Top_Interview_Questions, String, Hash_Table, Sorting | 251 | 87.65 -| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49 +| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 +| 0409 |[Longest Palindrome](src/main/kotlin/g0401_0500/s0409_longest_palindrome)| Easy | String, Hash_Table, Greedy | 259 | 60.71 -#### Day 12 Class and Object +#### Day 6 Tree | | | | | | |-|-|-|-|-|- -| 0303 |[Range Sum Query - Immutable](src/main/kotlin/g0301_0400/s0303_range_sum_query_immutable)| Easy | Array, Design, Prefix_Sum | 472 | 63.64 +| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02 +| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 332 | 67.53 -### Programming Skills II +#### Day 7 Binary Search -#### Day 1 +| | | | | | +|-|-|-|-|-|- +| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 +| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86 + +#### Day 8 Binary Search Tree | | | | | | |-|-|-|-|-|- -| 0896 |[Monotonic Array](src/main/kotlin/g0801_0900/s0896_monotonic_array)| Easy | Array | 576 | 90.91 -| 0028 |[Find the Index of the First Occurrence in a String](src/main/kotlin/g0001_0100/s0028_implement_strstr)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 257 | 32.35 +| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 330 | 41.38 +| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/kotlin/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 404 | 75.59 -#### Day 2 +#### Day 9 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 0110 |[Balanced Binary Tree](src/main/kotlin/g0101_0200/s0110_balanced_binary_tree)| Easy | Depth_First_Search, Tree, Binary_Tree | 310 | 63.63 -| 0459 |[Repeated Substring Pattern](src/main/kotlin/g0401_0500/s0459_repeated_substring_pattern)| Easy | String, String_Matching | 201 | 100.00 +| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76 +| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 -#### Day 3 +#### Day 10 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0150 |[Evaluate Reverse Polish Notation](src/main/kotlin/g0101_0200/s0150_evaluate_reverse_polish_notation)| Medium | Top_Interview_Questions, Array, Math, Stack | 233 | 88.82 -| 0066 |[Plus One](src/main/kotlin/g0001_0100/s0066_plus_one)| Easy | Top_Interview_Questions, Array, Math | 303 | 35.18 +| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72 +| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization | 127 | 97.06 -#### Day 4 +#### Day 11 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0043 |[Multiply Strings](src/main/kotlin/g0001_0100/s0043_multiply_strings)| Medium | String, Math, Simulation | 390 | 56.25 +| 0746 |[Min Cost Climbing Stairs](src/main/kotlin/g0701_0800/s0746_min_cost_climbing_stairs)| Easy | Array, Dynamic_Programming | 171 | 96.76 +| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics | 209 | 49.18 -#### Day 5 +#### Day 12 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- -| 0067 |[Add Binary](src/main/kotlin/g0001_0100/s0067_add_binary)| Easy | String, Math, Bit_Manipulation, Simulation | 327 | 32.67 -| 0989 |[Add to Array-Form of Integer](src/main/kotlin/g0901_1000/s0989_add_to_array_form_of_integer)| Easy | Array, Math | 350 | 70.00 +| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window | 561 | 54.68 +| 0424 |[Longest Repeating Character Replacement](src/main/kotlin/g0401_0500/s0424_longest_repeating_character_replacement)| Medium | String, Hash_Table, Sliding_Window | 288 | 84.38 -#### Day 6 +#### Day 13 Hashmap | | | | | | |-|-|-|-|-|- -| 0739 |[Daily Temperatures](src/main/kotlin/g0701_0800/s0739_daily_temperatures)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack | 936 | 80.54 -| 0058 |[Length of Last Word](src/main/kotlin/g0001_0100/s0058_length_of_last_word)| Easy | String | 243 | 63.33 +| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 234 | 92.75 +| 0299 |[Bulls and Cows](src/main/kotlin/g0201_0300/s0299_bulls_and_cows)| Medium | String, Hash_Table, Counting | 254 | 84.82 -#### Day 7 +#### Day 14 Stack | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/kotlin/g0001_0100/s0048_rotate_image)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix | 287 | 46.50 +| 0844 |[Backspace String Compare](src/main/kotlin/g0801_0900/s0844_backspace_string_compare)| Easy | String, Two_Pointers, Stack, Simulation | 126 | 98.31 +| 0394 |[Decode String](src/main/kotlin/g0301_0400/s0394_decode_string)| Medium | Top_100_Liked_Questions, String, Stack, Recursion | 224 | 64.86 -#### Day 8 +#### Day 15 Heap | | | | | | |-|-|-|-|-|- -| 0054 |[Spiral Matrix](src/main/kotlin/g0001_0100/s0054_spiral_matrix)| Medium | Top_Interview_Questions, Array, Matrix, Simulation | 224 | 62.50 -| 0973 |[K Closest Points to Origin](src/main/kotlin/g0901_1000/s0973_k_closest_points_to_origin)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 800 | 37.89 +| 1046 |[Last Stone Weight](src/main/kotlin/g1001_1100/s1046_last_stone_weight)| Easy | Array, Heap_Priority_Queue | 123 | 100.00 +| 0692 |[Top K Frequent Words](src/main/kotlin/g0601_0700/s0692_top_k_frequent_words)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Trie, Bucket_Sort | 239 | 81.10 -#### Day 9 +### Level 2 + +#### Day 1 Implementation/Simulation | | | | | | |-|-|-|-|-|- -| 0429 |[N-ary Tree Level Order Traversal](src/main/kotlin/g0401_0500/s0429_n_ary_tree_level_order_traversal)| Medium | Breadth_First_Search, Tree | 248 | 75.86 +| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08 +| 0054 |[Spiral Matrix](src/main/kotlin/g0001_0100/s0054_spiral_matrix)| Medium | Top_Interview_Questions, Array, Matrix, Simulation | 224 | 62.50 -#### Day 10 +#### Day 2 String | | | | | | |-|-|-|-|-|- -| 0503 |[Next Greater Element II](src/main/kotlin/g0501_0600/s0503_next_greater_element_ii)| Medium | Array, Stack, Monotonic_Stack | 331 | 92.68 -| 0556 |[Next Greater Element III](src/main/kotlin/g0501_0600/s0556_next_greater_element_iii)| Medium | String, Math, Two_Pointers | 137 | 80.00 +| 0014 |[Longest Common Prefix](src/main/kotlin/g0001_0100/s0014_longest_common_prefix)| Easy | Top_Interview_Questions, String | 209 | 88.86 +| 0043 |[Multiply Strings](src/main/kotlin/g0001_0100/s0043_multiply_strings)| Medium | String, Math, Simulation | 390 | 56.25 -#### Day 11 +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/kotlin/g0001_0100/s0049_group_anagrams)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting | 506 | 86.55 +| 0019 |[Remove Nth Node From End of List](src/main/kotlin/g0001_0100/s0019_remove_nth_node_from_end_of_list)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List | 180 | 91.58 +| 0234 |[Palindrome Linked List](src/main/kotlin/g0201_0300/s0234_palindrome_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion | 641 | 79.53 -#### Day 12 +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window | 561 | 54.68 -| 0713 |[Subarray Product Less Than K](src/main/kotlin/g0701_0800/s0713_subarray_product_less_than_k)| Medium | Array, Sliding_Window | 336 | 92.11 +| 0328 |[Odd Even Linked List](src/main/kotlin/g0301_0400/s0328_odd_even_linked_list)| Medium | Top_Interview_Questions, Linked_List | 216 | 86.96 +| 0148 |[Sort List](src/main/kotlin/g0101_0200/s0148_sort_list)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort | 820 | 61.70 -#### Day 13 +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- -| 0304 |[Range Sum Query 2D - Immutable](src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable)| Medium | Array, Matrix, Design, Prefix_Sum | 1373 | 85.71 -| 0910 |[Smallest Range II](src/main/kotlin/g0901_1000/s0910_smallest_range_ii)| Medium | Array, Math, Sorting, Greedy | 234 | 100.00 +| 0621 |[Task Scheduler](src/main/kotlin/g0601_0700/s0621_task_scheduler)| Medium | Array, Hash_Table, Sorting, Greedy, Heap_Priority_Queue, Counting | 266 | 98.36 -#### Day 14 +#### Day 6 Tree | | | | | | |-|-|-|-|-|- -| 0143 |[Reorder List](src/main/kotlin/g0101_0200/s0143_reorder_list)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 395 | 82.26 -| 0138 |[Copy List with Random Pointer](src/main/kotlin/g0101_0200/s0138_copy_list_with_random_pointer)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List | 274 | 80.58 +| 0226 |[Invert Binary Tree](src/main/kotlin/g0201_0300/s0226_invert_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 233 | 54.90 +| 0110 |[Balanced Binary Tree](src/main/kotlin/g0101_0200/s0110_balanced_binary_tree)| Easy | Depth_First_Search, Tree, Binary_Tree | 310 | 63.63 -#### Day 15 +#### Day 7 Tree | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/kotlin/g0001_0100/s0002_add_two_numbers)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion | 417 | 50.44 -| 0445 |[Add Two Numbers II](src/main/kotlin/g0401_0500/s0445_add_two_numbers_ii)| Medium | Math, Stack, Linked_List | 240 | 82.61 +| 0543 |[Diameter of Binary Tree](src/main/kotlin/g0501_0600/s0543_diameter_of_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree | 307 | 43.93 +| 0437 |[Path Sum III](src/main/kotlin/g0401_0500/s0437_path_sum_iii)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree | 403 | 54.12 -#### Day 16 +#### Day 8 Binary Search | | | | | | |-|-|-|-|-|- -| 0061 |[Rotate List](src/main/kotlin/g0001_0100/s0061_rotate_list)| Medium | Two_Pointers, Linked_List | 193 | 92.16 -| 0173 |[Binary Search Tree Iterator](src/main/kotlin/g0101_0200/s0173_binary_search_tree_iterator)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 563 | 46.91 +| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 +| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 -#### Day 17 +#### Day 9 Binary Search Tree | | | | | | |-|-|-|-|-|- -| 0860 |[Lemonade Change](src/main/kotlin/g0801_0900/s0860_lemonade_change)| Easy | Array, Greedy | 413 | 86.96 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/kotlin/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 334 | 35.39 +| 0230 |[Kth Smallest Element in a BST](src/main/kotlin/g0201_0300/s0230_kth_smallest_element_in_a_bst)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 393 | 33.33 +| 0173 |[Binary Search Tree Iterator](src/main/kotlin/g0101_0200/s0173_binary_search_tree_iterator)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 563 | 46.91 -#### Day 18 +#### Day 10 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 -| 0341 |[Flatten Nested List Iterator](src/main/kotlin/g0301_0400/s0341_flatten_nested_list_iterator)| Medium | Top_Interview_Questions, Depth_First_Search, Tree, Stack, Design, Queue, Iterator | 210 | 100.00 +| 0994 |[Rotting Oranges](src/main/kotlin/g0901_1000/s0994_rotting_oranges)| Medium | Array, Breadth_First_Search, Matrix | 164 | 82.95 +| 0417 |[Pacific Atlantic Water Flow](src/main/kotlin/g0401_0500/s0417_pacific_atlantic_water_flow)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 319 | 100.00 -#### Day 19 +#### Day 11 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 0707 |[Design Linked List](src/main/kotlin/g0701_0800/s0707_design_linked_list)| Medium | Design, Linked_List | 243 | 100.00 +| 0210 |[Course Schedule II](src/main/kotlin/g0201_0300/s0210_course_schedule_ii)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 266 | 96.32 +| 0815 |[Bus Routes](src/main/kotlin/g0801_0900/s0815_bus_routes)| Hard | Array, Hash_Table, Breadth_First_Search | 429 | 100.00 -#### Day 20 +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0380 |[Insert Delete GetRandom O(1)](src/main/kotlin/g0301_0400/s0380_insert_delete_getrandom_o1)| Medium | Top_Interview_Questions, Array, Hash_Table, Math, Design, Randomized | 1326 | 68.23 -| 0622 |[Design Circular Queue](src/main/kotlin/g0601_0700/s0622_design_circular_queue)| Medium | Array, Design, Linked_List, Queue | 234 | 92.68 -| 0729 |[My Calendar I](src/main/kotlin/g0701_0800/s0729_my_calendar_i)| Medium | Binary_Search, Design, Ordered_Set, Segment_Tree | 378 | 69.70 - -### Graph Theory I +| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 +| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search | 332 | 50.68 -#### Day 1 Matrix Related Problems +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76 -| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 +| 0416 |[Partition Equal Subset Sum](src/main/kotlin/g0401_0500/s0416_partition_equal_subset_sum)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming | 204 | 98.82 +| 0152 |[Maximum Product Subarray](src/main/kotlin/g0101_0200/s0152_maximum_product_subarray)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 253 | 88.42 -#### Day 2 Matrix Related Problems +#### Day 14 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- -| 0695 |[Max Area of Island](src/main/kotlin/g0601_0700/s0695_max_area_of_island)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 324 | 24.06 +| 0003 |[Longest Substring Without Repeating Characters](src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 258 | 91.09 +| 0016 |[3Sum Closest](src/main/kotlin/g0001_0100/s0016_3sum_closest)| Medium | Array, Sorting, Two_Pointers | 413 | 95.05 +| 0076 |[Minimum Window Substring](src/main/kotlin/g0001_0100/s0076_minimum_window_substring)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 346 | 85.20 -#### Day 3 Matrix Related Problems +#### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 1020 |[Number of Enclaves](src/main/kotlin/g1001_1100/s1020_number_of_enclaves)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 369 | 76.26 +| 0100 |[Same Tree](src/main/kotlin/g0001_0100/s0100_same_tree)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 208 | 72.24 +| 0101 |[Symmetric Tree](src/main/kotlin/g0101_0200/s0101_symmetric_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 190 | 91.36 +| 0199 |[Binary Tree Right Side View](src/main/kotlin/g0101_0200/s0199_binary_tree_right_side_view)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 194 | 92.89 -#### Day 4 Matrix Related Problems +#### Day 16 Design | | | | | | |-|-|-|-|-|- -| 1162 |[As Far from Land as Possible](src/main/kotlin/g1101_1200/s1162_as_far_from_land_as_possible)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 362 | 81.25 -| 0417 |[Pacific Atlantic Water Flow](src/main/kotlin/g0401_0500/s0417_pacific_atlantic_water_flow)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 319 | 100.00 +| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86 +| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 +| 0208 |[Implement Trie (Prefix Tree)](src/main/kotlin/g0201_0300/s0208_implement_trie_prefix_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie | 689 | 61.00 -#### Day 5 Matrix Related Problems +#### Day 17 Interval | | | | | | |-|-|-|-|-|- -| 0542 |[01 Matrix](src/main/kotlin/g0501_0600/s0542_01_matrix)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 441 | 94.06 +| 0057 |[Insert Interval](src/main/kotlin/g0001_0100/s0057_insert_interval)| Medium | Array | 257 | 99.52 +| 0056 |[Merge Intervals](src/main/kotlin/g0001_0100/s0056_merge_intervals)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting | 320 | 94.22 -#### Day 6 Matrix Related Problems +#### Day 18 Stack | | | | | | |-|-|-|-|-|- -| 0934 |[Shortest Bridge](src/main/kotlin/g0901_1000/s0934_shortest_bridge)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 301 | 80.95 +| 0735 |[Asteroid Collision](src/main/kotlin/g0701_0800/s0735_asteroid_collision)| Medium | Array, Stack | 243 | 100.00 +| 0227 |[Basic Calculator II](src/main/kotlin/g0201_0300/s0227_basic_calculator_ii)| Medium | Top_Interview_Questions, String, Math, Stack | 383 | 62.50 -#### Day 7 Standard Traversal +#### Day 19 Union Find | | | | | | |-|-|-|-|-|- -| 0797 |[All Paths From Source to Target](src/main/kotlin/g0701_0800/s0797_all_paths_from_source_to_target)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 232 | 100.00 -| 0841 |[Keys and Rooms](src/main/kotlin/g0801_0900/s0841_keys_and_rooms)| Medium | Depth_First_Search, Breadth_First_Search, Graph | 189 | 69.23 +| 0547 |[Number of Provinces](src/main/kotlin/g0501_0600/s0547_number_of_provinces)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 229 | 79.73 +| 0947 |[Most Stones Removed with Same Row or Column](src/main/kotlin/g0901_1000/s0947_most_stones_removed_with_same_row_or_column)| Medium | Depth_First_Search, Graph, Union_Find | 200 | 100.00 -#### Day 8 Standard Traversal +#### Day 20 Brute Force/Backtracking | | | | | | |-|-|-|-|-|- -| 0547 |[Number of Provinces](src/main/kotlin/g0501_0600/s0547_number_of_provinces)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 229 | 79.73 +| 0039 |[Combination Sum](src/main/kotlin/g0001_0100/s0039_combination_sum)| Medium | Top_100_Liked_Questions, Array, Backtracking | 317 | 86.85 +| 0046 |[Permutations](src/main/kotlin/g0001_0100/s0046_permutations)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking | 186 | 100.00 -#### Day 9 Standard Traversal +### Udemy + +#### Udemy Integers | | | | | | |-|-|-|-|-|- -| 0802 |[Find Eventual Safe States](src/main/kotlin/g0801_0900/s0802_find_eventual_safe_states)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 511 | 100.00 +| 0412 |[Fizz Buzz](src/main/kotlin/g0401_0500/s0412_fizz_buzz)| Easy | Top_Interview_Questions, String, Math, Simulation | 307 | 71.81 +| 0136 |[Single Number](src/main/kotlin/g0101_0200/s0136_single_number)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation | 344 | 83.63 +| 0007 |[Reverse Integer](src/main/kotlin/g0001_0100/s0007_reverse_integer)| Medium | Top_Interview_Questions, Math | 245 | 60.32 +| 0009 |[Palindrome Number](src/main/kotlin/g0001_0100/s0009_palindrome_number)| Easy | Math | 238 | 96.24 +| 0172 |[Factorial Trailing Zeroes](src/main/kotlin/g0101_0200/s0172_factorial_trailing_zeroes)| Medium | Top_Interview_Questions, Math | 220 | 67.65 +| 0050 |[Pow(x, n)](src/main/kotlin/g0001_0100/s0050_powx_n)| Medium | Top_Interview_Questions, Math, Recursion | 264 | 52.98 -#### Day 10 Standard Traversal +#### Udemy Strings | | | | | | |-|-|-|-|-|- -| 0847 |[Shortest Path Visiting All Nodes](src/main/kotlin/g0801_0900/s0847_shortest_path_visiting_all_nodes)| Hard | Dynamic_Programming, Breadth_First_Search, Bit_Manipulation, Graph, Bitmask | 164 | 100.00 +| 0344 |[Reverse String](src/main/kotlin/g0301_0400/s0344_reverse_string)| Easy | Top_Interview_Questions, String, Two_Pointers, Recursion | 445 | 69.75 +| 0014 |[Longest Common Prefix](src/main/kotlin/g0001_0100/s0014_longest_common_prefix)| Easy | Top_Interview_Questions, String | 209 | 88.86 +| 0187 |[Repeated DNA Sequences](src/main/kotlin/g0101_0200/s0187_repeated_dna_sequences)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 319 | 79.03 +| 0003 |[Longest Substring Without Repeating Characters](src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 258 | 91.09 +| 0020 |[Valid Parentheses](src/main/kotlin/g0001_0100/s0020_valid_parentheses)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack | 226 | 72.53 +| 0005 |[Longest Palindromic Substring](src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming | 323 | 75.48 +| 0394 |[Decode String](src/main/kotlin/g0301_0400/s0394_decode_string)| Medium | Top_100_Liked_Questions, String, Stack, Recursion | 224 | 64.86 +| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | Top_Interview_Questions, String, Hash_Table, Sorting | 251 | 87.65 +| 0049 |[Group Anagrams](src/main/kotlin/g0001_0100/s0049_group_anagrams)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting | 506 | 86.55 +| 0151 |[Reverse Words in a String](src/main/kotlin/g0101_0200/s0151_reverse_words_in_a_string)| Medium | String, Two_Pointers | 206 | 98.90 +| 0273 |[Integer to English Words](src/main/kotlin/g0201_0300/s0273_integer_to_english_words)| Hard | String, Math, Recursion | 273 | 82.93 -#### Day 11 Breadth First Search +#### Udemy Binary Search | | | | | | |-|-|-|-|-|- -| 0365 |[Water and Jug Problem](src/main/kotlin/g0301_0400/s0365_water_and_jug_problem)| Medium | Math, Depth_First_Search, Breadth_First_Search | 130 | 100.00 +| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Array, Binary_Search | 261 | 77.91 +| 0033 |[Search in Rotated Sorted Array](src/main/kotlin/g0001_0100/s0033_search_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search | 184 | 86.08 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/kotlin/g0101_0200/s0153_find_minimum_in_rotated_sorted_array)| Medium | Top_100_Liked_Questions, Array, Binary_Search | 262 | 60.96 -#### Day 12 Breadth First Search +#### Udemy Arrays | | | | | | |-|-|-|-|-|- -| 0433 |[Minimum Genetic Mutation](src/main/kotlin/g0401_0500/s0433_minimum_genetic_mutation)| Medium | String, Hash_Table, Breadth_First_Search | 204 | 82.08 -| 0752 |[Open the Lock](src/main/kotlin/g0701_0800/s0752_open_the_lock)| Medium | Array, String, Hash_Table, Breadth_First_Search | 310 | 100.00 -| 0127 |[Word Ladder](src/main/kotlin/g0101_0200/s0127_word_ladder)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 396 | 98.68 +| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06 +| 0283 |[Move Zeroes](src/main/kotlin/g0201_0300/s0283_move_zeroes)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Two_Pointers | 516 | 79.07 +| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 234 | 92.75 +| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49 +| 0058 |[Length of Last Word](src/main/kotlin/g0001_0100/s0058_length_of_last_word)| Easy | String | 243 | 63.33 +| 0605 |[Can Place Flowers](src/main/kotlin/g0601_0700/s0605_can_place_flowers)| Easy | Array, Greedy | 209 | 85.71 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/kotlin/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 197 | 95.10 +| 0080 |[Remove Duplicates from Sorted Array II](src/main/kotlin/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii)| Medium | Array, Two_Pointers | 357 | 44.78 +| 0189 |[Rotate Array](src/main/kotlin/g0101_0200/s0189_rotate_array)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers | 483 | 86.95 +| 0055 |[Jump Game](src/main/kotlin/g0001_0100/s0055_jump_game)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 670 | 66.67 +| 0075 |[Sort Colors](src/main/kotlin/g0001_0100/s0075_sort_colors)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 198 | 85.66 +| 0066 |[Plus One](src/main/kotlin/g0001_0100/s0066_plus_one)| Easy | Top_Interview_Questions, Array, Math | 303 | 35.18 +| 0238 |[Product of Array Except Self](src/main/kotlin/g0201_0300/s0238_product_of_array_except_self)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum | 669 | 48.96 +| 0448 |[Find All Numbers Disappeared in an Array](src/main/kotlin/g0401_0500/s0448_find_all_numbers_disappeared_in_an_array)| Easy | Array, Hash_Table | 394 | 100.00 +| 0442 |[Find All Duplicates in an Array](src/main/kotlin/g0401_0500/s0442_find_all_duplicates_in_an_array)| Medium | Array, Hash_Table | 480 | 73.81 +| 0041 |[First Missing Positive](src/main/kotlin/g0001_0100/s0041_first_missing_positive)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table | 345 | 100.00 +| 0697 |[Degree of an Array](src/main/kotlin/g0601_0700/s0697_degree_of_an_array)| Easy | Array, Hash_Table | 289 | 84.62 +| 0532 |[K-diff Pairs in an Array](src/main/kotlin/g0501_0600/s0532_k_diff_pairs_in_an_array)| Medium | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 230 | 84.62 +| 0713 |[Subarray Product Less Than K](src/main/kotlin/g0701_0800/s0713_subarray_product_less_than_k)| Medium | Array, Sliding_Window | 336 | 92.11 +| 1007 |[Minimum Domino Rotations For Equal Row](src/main/kotlin/g1001_1100/s1007_minimum_domino_rotations_for_equal_row)| Medium | Array, Greedy | 421 | 50.00 +| 0456 |[132 Pattern](src/main/kotlin/g0401_0500/s0456_132_pattern)| Medium | Array, Binary_Search, Stack, Ordered_Set, Monotonic_Stack | 434 | 100.00 +| 0239 |[Sliding Window Maximum](src/main/kotlin/g0201_0300/s0239_sliding_window_maximum)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue | 1059 | 86.14 -#### Day 13 Graph Theory +#### Udemy Two Pointers | | | | | | |-|-|-|-|-|- -| 0997 |[Find the Town Judge](src/main/kotlin/g0901_1000/s0997_find_the_town_judge)| Easy | Array, Hash_Table, Graph | 475 | 58.62 +| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74 +| 0125 |[Valid Palindrome](src/main/kotlin/g0101_0200/s0125_valid_palindrome)| Easy | Top_Interview_Questions, String, Two_Pointers | 353 | 52.06 +| 0977 |[Squares of a Sorted Array](src/main/kotlin/g0901_1000/s0977_squares_of_a_sorted_array)| Easy | Array, Sorting, Two_Pointers | 375 | 18.43 +| 0026 |[Remove Duplicates from Sorted Array](src/main/kotlin/g0001_0100/s0026_remove_duplicates_from_sorted_array)| Easy | Top_Interview_Questions, Array, Two_Pointers | 361 | 77.19 +| 0042 |[Trapping Rain Water](src/main/kotlin/g0001_0100/s0042_trapping_rain_water)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack | 196 | 100.00 +| 0015 |[3Sum](src/main/kotlin/g0001_0100/s0015_3sum)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers | 761 | 90.55 -#### Day 14 Graph Theory +#### Udemy Famous Algorithm | | | | | | |-|-|-|-|-|- -| 0886 |[Possible Bipartition](src/main/kotlin/g0801_0900/s0886_possible_bipartition)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 397 | 100.00 -| 0785 |[Is Graph Bipartite?](src/main/kotlin/g0701_0800/s0785_is_graph_bipartite)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 215 | 82.35 - -### SQL I +| 0053 |[Maximum Subarray](src/main/kotlin/g0001_0100/s0053_maximum_subarray)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer | 662 | 82.48 +| 0169 |[Majority Element](src/main/kotlin/g0101_0200/s0169_majority_element)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer | 460 | 51.25 -#### Day 1 Select +#### Udemy Sorting Algorithms | | | | | | |-|-|-|-|-|- -| 0595 |[Big Countries](src/main/kotlin/g0501_0600/s0595_big_countries)| Easy | Database | 417 | 56.09 -| 0584 |[Find Customer Referee](src/main/kotlin/g0501_0600/s0584_find_customer_referee)| Easy | Database | 779 | 43.48 -| 0183 |[Customers Who Never Order](src/main/kotlin/g0101_0200/s0183_customers_who_never_order)| Easy | Database | 712 | 33.67 +| 0912 |[Sort an Array](src/main/kotlin/g0901_1000/s0912_sort_an_array)| Medium | Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Merge_Sort, Bucket_Sort, Counting_Sort, Radix_Sort | 606 | 98.48 -#### Day 2 Select and Order +#### Udemy 2D Arrays/Matrix | | | | | | |-|-|-|-|-|- -| 0627 |[Swap Salary](src/main/kotlin/g0601_0700/s0627_swap_salary)| Easy | Database | 400 | 51.04 -| 0196 |[Delete Duplicate Emails](src/main/kotlin/g0101_0200/s0196_delete_duplicate_emails)| Easy | Database | 593 | 94.17 +| 0304 |[Range Sum Query 2D - Immutable](src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable)| Medium | Array, Matrix, Design, Prefix_Sum | 1373 | 85.71 +| 0074 |[Search a 2D Matrix](src/main/kotlin/g0001_0100/s0074_search_a_2d_matrix)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix | 290 | 40.17 +| 0054 |[Spiral Matrix](src/main/kotlin/g0001_0100/s0054_spiral_matrix)| Medium | Top_Interview_Questions, Array, Matrix, Simulation | 224 | 62.50 +| 0048 |[Rotate Image](src/main/kotlin/g0001_0100/s0048_rotate_image)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix | 287 | 46.50 +| 0073 |[Set Matrix Zeroes](src/main/kotlin/g0001_0100/s0073_set_matrix_zeroes)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix | 255 | 100.00 +| 0056 |[Merge Intervals](src/main/kotlin/g0001_0100/s0056_merge_intervals)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting | 320 | 94.22 -#### Day 3 String Processing Functions +#### Udemy Linked List | | | | | | |-|-|-|-|-|- +| 0114 |[Flatten Binary Tree to Linked List](src/main/kotlin/g0101_0200/s0114_flatten_binary_tree_to_linked_list)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List | 191 | 93.10 +| 0445 |[Add Two Numbers II](src/main/kotlin/g0401_0500/s0445_add_two_numbers_ii)| Medium | Math, Stack, Linked_List | 240 | 82.61 +| 0328 |[Odd Even Linked List](src/main/kotlin/g0301_0400/s0328_odd_even_linked_list)| Medium | Top_Interview_Questions, Linked_List | 216 | 86.96 +| 0061 |[Rotate List](src/main/kotlin/g0001_0100/s0061_rotate_list)| Medium | Two_Pointers, Linked_List | 193 | 92.16 +| 0024 |[Swap Nodes in Pairs](src/main/kotlin/g0001_0100/s0024_swap_nodes_in_pairs)| Medium | Top_100_Liked_Questions, Linked_List, Recursion | 149 | 99.39 +| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52 +| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List | 192 | 63.39 +| 0141 |[Linked List Cycle](src/main/kotlin/g0101_0200/s0141_linked_list_cycle)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 223 | 91.85 +| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 279 | 45.78 +| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion | 176 | 96.25 +| 0160 |[Intersection of Two Linked Lists](src/main/kotlin/g0101_0200/s0160_intersection_of_two_linked_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List | 262 | 83.50 +| 0234 |[Palindrome Linked List](src/main/kotlin/g0201_0300/s0234_palindrome_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Stack, Linked_List, Recursion | 641 | 79.53 +| 0138 |[Copy List with Random Pointer](src/main/kotlin/g0101_0200/s0138_copy_list_with_random_pointer)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List | 274 | 80.58 +| 0025 |[Reverse Nodes in k-Group](src/main/kotlin/g0001_0100/s0025_reverse_nodes_in_k_group)| Hard | Top_100_Liked_Questions, Linked_List, Recursion | 194 | 87.72 +| 0146 |[LRU Cache](src/main/kotlin/g0101_0200/s0146_lru_cache)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List | 1116 | 97.93 +| 0707 |[Design Linked List](src/main/kotlin/g0701_0800/s0707_design_linked_list)| Medium | Design, Linked_List | 243 | 100.00 -#### Day 4 Union and Select +#### Udemy Tree Stack Queue | | | | | | |-|-|-|-|-|- -| 0608 |[Tree Node](src/main/kotlin/g0601_0700/s0608_tree_node)| Medium | LeetCode_Curated_SQL_70, Database | 794 | 48.38 -| 0176 |[Second Highest Salary](src/main/kotlin/g0101_0200/s0176_second_highest_salary)| Medium | Database | 219 | 92.54 +| 0144 |[Binary Tree Preorder Traversal](src/main/kotlin/g0101_0200/s0144_binary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 277 | 37.90 +| 0094 |[Binary Tree Inorder Traversal](src/main/kotlin/g0001_0100/s0094_binary_tree_inorder_traversal)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack | 269 | 38.80 +| 0145 |[Binary Tree Postorder Traversal](src/main/kotlin/g0101_0200/s0145_binary_tree_postorder_traversal)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 211 | 80.00 +| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 332 | 67.53 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/kotlin/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 316 | 34.25 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/kotlin/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree)| Easy | Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 334 | 35.39 +| 1008 |[Construct Binary Search Tree from Preorder Traversal](src/main/kotlin/g1001_1100/s1008_construct_binary_search_tree_from_preorder_traversal)| Medium | Array, Tree, Binary_Tree, Stack, Monotonic_Stack, Binary_Search_Tree | 145 | 100.00 +| 0543 |[Diameter of Binary Tree](src/main/kotlin/g0501_0600/s0543_diameter_of_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree | 307 | 43.93 +| 0938 |[Range Sum of BST](src/main/kotlin/g0901_1000/s0938_range_sum_of_bst)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 356 | 55.36 +| 0100 |[Same Tree](src/main/kotlin/g0001_0100/s0100_same_tree)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 208 | 72.24 +| 0226 |[Invert Binary Tree](src/main/kotlin/g0201_0300/s0226_invert_binary_tree)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 233 | 54.90 +| 0111 |[Minimum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0111_minimum_depth_of_binary_tree)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 525 | 90.51 +| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 236 | 83.39 +| 0110 |[Balanced Binary Tree](src/main/kotlin/g0101_0200/s0110_balanced_binary_tree)| Easy | Depth_First_Search, Tree, Binary_Tree | 310 | 63.63 +| 0701 |[Insert into a Binary Search Tree](src/main/kotlin/g0701_0800/s0701_insert_into_a_binary_search_tree)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 311 | 79.03 +| 0297 |[Serialize and Deserialize Binary Tree](src/main/kotlin/g0201_0300/s0297_serialize_and_deserialize_binary_tree)| Hard | Top_Interview_Questions, String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 475 | 78.85 +| 0124 |[Binary Tree Maximum Path Sum](src/main/kotlin/g0101_0200/s0124_binary_tree_maximum_path_sum)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 331 | 74.42 +| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 330 | 41.38 +| 0337 |[House Robber III](src/main/kotlin/g0301_0400/s0337_house_robber_iii)| Medium | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 282 | 84.62 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/kotlin/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree | 386 | 45.21 +| 0968 |[Binary Tree Cameras](src/main/kotlin/g0901_1000/s0968_binary_tree_cameras)| Hard | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 176 | 100.00 -#### Day 5 Union +#### Udemy Trie and Heap | | | | | | |-|-|-|-|-|- -| 0175 |[Combine Two Tables](src/main/kotlin/g0101_0200/s0175_combine_two_tables)| Easy | Database | 473 | 54.97 +| 0208 |[Implement Trie (Prefix Tree)](src/main/kotlin/g0201_0300/s0208_implement_trie_prefix_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie | 689 | 61.00 +| 0745 |[Prefix and Suffix Search](src/main/kotlin/g0701_0800/s0745_prefix_and_suffix_search)| Hard | String, Design, Trie | 1638 | 100.00 -#### Day 6 Union +#### Udemy Graph | | | | | | |-|-|-|-|-|- -| 0197 |[Rising Temperature](src/main/kotlin/g0101_0200/s0197_rising_temperature)| Easy | Database | 394 | 94.15 -| 0607 |[Sales Person](src/main/kotlin/g0601_0700/s0607_sales_person)| Easy | LeetCode_Curated_SQL_70, Database | 2142 | 44.56 +| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 252 | 95.41 +| 0133 |[Clone Graph](src/main/kotlin/g0101_0200/s0133_clone_graph)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 351 | 60.91 +| 0417 |[Pacific Atlantic Water Flow](src/main/kotlin/g0401_0500/s0417_pacific_atlantic_water_flow)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 319 | 100.00 -#### Day 7 Function +#### Udemy Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0120 |[Triangle](src/main/kotlin/g0101_0200/s0120_triangle)| Medium | Array, Dynamic_Programming | 194 | 97.87 +| 0118 |[Pascal's Triangle](src/main/kotlin/g0101_0200/s0118_pascals_triangle)| Easy | Top_Interview_Questions, Array, Dynamic_Programming | 277 | 33.22 +| 0119 |[Pascal's Triangle II](src/main/kotlin/g0101_0200/s0119_pascals_triangle_ii)| Easy | Array, Dynamic_Programming | 157 | 97.27 +| 0139 |[Word Break](src/main/kotlin/g0101_0200/s0139_word_break)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization | 197 | 87.17 +| 0152 |[Maximum Product Subarray](src/main/kotlin/g0101_0200/s0152_maximum_product_subarray)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 253 | 88.42 +| 0198 |[House Robber](src/main/kotlin/g0101_0200/s0198_house_robber)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 156 | 92.24 +| 0213 |[House Robber II](src/main/kotlin/g0201_0300/s0213_house_robber_ii)| Medium | Array, Dynamic_Programming | 257 | 59.62 +| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72 +| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization | 127 | 97.06 +| 0064 |[Minimum Path Sum](src/main/kotlin/g0001_0100/s0064_minimum_path_sum)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix | 222 | 95.70 +| 0300 |[Longest Increasing Subsequence](src/main/kotlin/g0201_0300/s0300_longest_increasing_subsequence)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Binary_Search | 318 | 82.28 +| 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming | 307 | 38.36 +| 0072 |[Edit Distance](src/main/kotlin/g0001_0100/s0072_edit_distance)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming | 320 | 63.53 +| 0044 |[Wildcard Matching](src/main/kotlin/g0001_0100/s0044_wildcard_matching)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Greedy, Recursion | 401 | 86.11 +| 0010 |[Regular Expression Matching](src/main/kotlin/g0001_0100/s0010_regular_expression_matching)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion | 292 | 58.58 -#### Day 8 Function +#### Udemy Backtracking/Recursion | | | | | | |-|-|-|-|-|- -| 0586 |[Customer Placing the Largest Number of Orders](src/main/kotlin/g0501_0600/s0586_customer_placing_the_largest_number_of_orders)| Easy | LeetCode_Curated_SQL_70, Database | 768 | 44.85 -| 0511 |[Game Play Analysis I](src/main/kotlin/g0501_0600/s0511_game_play_analysis_i)| Easy | LeetCode_Curated_SQL_70, Database | 790 | 45.04 +| 0022 |[Generate Parentheses](src/main/kotlin/g0001_0100/s0022_generate_parentheses)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking | 210 | 78.51 +| 0039 |[Combination Sum](src/main/kotlin/g0001_0100/s0039_combination_sum)| Medium | Top_100_Liked_Questions, Array, Backtracking | 317 | 86.85 +| 0216 |[Combination Sum III](src/main/kotlin/g0201_0300/s0216_combination_sum_iii)| Medium | Array, Backtracking | 175 | 90.91 +| 0078 |[Subsets](src/main/kotlin/g0001_0100/s0078_subsets)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking | 191 | 97.44 +| 0017 |[Letter Combinations of a Phone Number](src/main/kotlin/g0001_0100/s0017_letter_combinations_of_a_phone_number)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking | 262 | 73.59 +| 0046 |[Permutations](src/main/kotlin/g0001_0100/s0046_permutations)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking | 186 | 100.00 -#### Day 9 Control of Flow +#### Udemy Bit Manipulation | | | | | | |-|-|-|-|-|- -| 1158 |[Market Analysis I](src/main/kotlin/g1101_1200/s1158_market_analysis_i)| Medium | Database | 2470 | 44.76 +| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44 +| 0389 |[Find the Difference](src/main/kotlin/g0301_0400/s0389_find_the_difference)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 256 | 64.81 +| 0190 |[Reverse Bits](src/main/kotlin/g0101_0200/s0190_reverse_bits)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 198 | 81.82 +| 0461 |[Hamming Distance](src/main/kotlin/g0401_0500/s0461_hamming_distance)| Easy | Bit_Manipulation | 150 | 96.15 +| 1009 |[Complement of Base 10 Integer](src/main/kotlin/g1001_1100/s1009_complement_of_base_10_integer)| Easy | Bit_Manipulation | 126 | 72.73 +| 0338 |[Counting Bits](src/main/kotlin/g0301_0400/s0338_counting_bits)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation | 186 | 99.26 +| 0371 |[Sum of Two Integers](src/main/kotlin/g0301_0400/s0371_sum_of_two_integers)| Medium | Top_Interview_Questions, Math, Bit_Manipulation | 129 | 95.45 +| 0029 |[Divide Two Integers](src/main/kotlin/g0001_0100/s0029_divide_two_integers)| Medium | Top_Interview_Questions, Math, Bit_Manipulation | 281 | 31.67 -#### Day 10 Where +#### Udemy Design | | | | | | |-|-|-|-|-|- -| 0182 |[Duplicate Emails](src/main/kotlin/g0101_0200/s0182_duplicate_emails)| Easy | Database | 396 | 68.40 -| 1050 |[Actors and Directors Who Cooperated At Least Three Times](src/main/kotlin/g1001_1100/s1050_actors_and_directors_who_cooperated_at_least_three_times)| Easy | LeetCode_Curated_SQL_70, Database | 629 | 81.02 +| 0155 |[Min Stack](src/main/kotlin/g0101_0200/s0155_min_stack)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design | 331 | 84.88 ## Algorithms | # | Title | Difficulty | Tag | Time, ms | Time, % |------|----------------|-------------|-------------|----------|-------- | 1200 |[Minimum Absolute Difference](src/main/kotlin/g1101_1200/s1200_minimum_absolute_difference)| Easy | Array, Sorting | 507 | 75.00 -| 1195 |[Fizz Buzz Multithreaded](src/main/kotlin/g1101_1200/s1195_fizz_buzz_multithreaded)| Medium || | +| 1195 |[Fizz Buzz Multithreaded](src/main/kotlin/g1101_1200/s1195_fizz_buzz_multithreaded)| Medium | Concurrency | 6 | 87.26 | 1192 |[Critical Connections in a Network](src/main/kotlin/g1101_1200/s1192_critical_connections_in_a_network)| Hard | Depth_First_Search, Graph, Biconnected_Component | 1696 | 60.00 | 1191 |[K-Concatenation Maximum Sum](src/main/kotlin/g1101_1200/s1191_k_concatenation_maximum_sum)| Medium | Array, Dynamic_Programming | 389 | 100.00 | 1190 |[Reverse Substrings Between Each Pair of Parentheses](src/main/kotlin/g1101_1200/s1190_reverse_substrings_between_each_pair_of_parentheses)| Medium | String, Stack | 153 | 42.86 @@ -1748,7 +1753,45 @@ | 1156 |[Swap For Longest Repeated Character Substring](src/main/kotlin/g1101_1200/s1156_swap_for_longest_repeated_character_substring)| Medium | String, Sliding_Window | 195 | 20.00 | 1155 |[Number of Dice Rolls With Target Sum](src/main/kotlin/g1101_1200/s1155_number_of_dice_rolls_with_target_sum)| Medium | Dynamic_Programming | 158 | 80.95 | 1154 |[Day of the Year](src/main/kotlin/g1101_1200/s1154_day_of_the_year)| Easy | String, Math | 317 | 70.00 +| 1148 |[Article Views I](src/main/kotlin/g1101_1200/s1148_article_views_i)| Easy | LeetCode_Curated_SQL_70, Database, SQL_I_Day_5_Union | 806 | 54.41 +| 1147 |[Longest Chunked Palindrome Decomposition](src/main/kotlin/g1101_1200/s1147_longest_chunked_palindrome_decomposition)| Hard | String, Dynamic_Programming, Greedy, Two_Pointers, Hash_Function, Rolling_Hash | 148 | 50.00 +| 1146 |[Snapshot Array](src/main/kotlin/g1101_1200/s1146_snapshot_array)| Medium | Array, Hash_Table, Binary_Search, Design, Binary_Search_II_Day_18 | 1064 | 57.14 +| 1145 |[Binary Tree Coloring Game](src/main/kotlin/g1101_1200/s1145_binary_tree_coloring_game)| Medium | Depth_First_Search, Tree, Binary_Tree | 181 | 100.00 +| 1144 |[Decrease Elements To Make Array Zigzag](src/main/kotlin/g1101_1200/s1144_decrease_elements_to_make_array_zigzag)| Medium | Array, Greedy | 144 | 100.00 | 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming | 307 | 38.36 +| 1141 |[User Activity for the Past 30 Days I](src/main/kotlin/g1101_1200/s1141_user_activity_for_the_past_30_days_i)| Easy | LeetCode_Curated_SQL_70, Database, SQL_I_Day_7_Function | 790 | 87.11 +| 1140 |[Stone Game II](src/main/kotlin/g1101_1200/s1140_stone_game_ii)| Medium | Array, Dynamic_Programming, Math, Game_Theory | 166 | 93.27 +| 1139 |[Largest 1-Bordered Square](src/main/kotlin/g1101_1200/s1139_largest_1_bordered_square)| Medium | Array, Dynamic_Programming, Matrix | 224 | 100.00 +| 1138 |[Alphabet Board Path](src/main/kotlin/g1101_1200/s1138_alphabet_board_path)| Medium | String, Hash_Table | 138 | 100.00 +| 1137 |[N-th Tribonacci Number](src/main/kotlin/g1101_1200/s1137_n_th_tribonacci_number)| Easy | Dynamic_Programming, Math, Memoization, Dynamic_Programming_I_Day_1 | 122 | 69.35 +| 1131 |[Maximum of Absolute Value Expression](src/main/kotlin/g1101_1200/s1131_maximum_of_absolute_value_expression)| Medium | Array, Math | 333 | 100.00 +| 1130 |[Minimum Cost Tree From Leaf Values](src/main/kotlin/g1101_1200/s1130_minimum_cost_tree_from_leaf_values)| Medium | Dynamic_Programming, Greedy, Stack, Monotonic_Stack | 145 | 66.67 +| 1129 |[Shortest Path with Alternating Colors](src/main/kotlin/g1101_1200/s1129_shortest_path_with_alternating_colors)| Medium | Breadth_First_Search, Graph, Graph_Theory_I_Day_10_Standard_Traversal | 241 | 16.67 +| 1128 |[Number of Equivalent Domino Pairs](src/main/kotlin/g1101_1200/s1128_number_of_equivalent_domino_pairs)| Easy | Array, Hash_Table, Counting | 289 | 80.00 +| 1125 |[Smallest Sufficient Team](src/main/kotlin/g1101_1200/s1125_smallest_sufficient_team)| Hard | Array, Dynamic_Programming, Bit_Manipulation, Bitmask | 181 | 100.00 +| 1124 |[Longest Well-Performing Interval](src/main/kotlin/g1101_1200/s1124_longest_well_performing_interval)| Medium | Array, Hash_Table, Stack, Prefix_Sum, Monotonic_Stack | 313 | 100.00 +| 1123 |[Lowest Common Ancestor of Deepest Leaves](src/main/kotlin/g1101_1200/s1123_lowest_common_ancestor_of_deepest_leaves)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 221 | 66.67 +| 1122 |[Relative Sort Array](src/main/kotlin/g1101_1200/s1122_relative_sort_array)| Easy | Array, Hash_Table, Sorting, Counting_Sort | 183 | 90.00 +| 1117 |[Building H2O](src/main/kotlin/g1101_1200/s1117_building_h2o)| Medium | Concurrency | 20 | 45.16 +| 1116 |[Print Zero Even Odd](src/main/kotlin/g1101_1200/s1116_print_zero_even_odd)| Medium | Concurrency | 7 | 39.21 +| 1115 |[Print FooBar Alternately](src/main/kotlin/g1101_1200/s1115_print_foobar_alternately)| Medium | Concurrency | 23 | 71.25 +| 1114 |[Print in Order](src/main/kotlin/g1101_1200/s1114_print_in_order)| Easy | Concurrency | 13 | 30.13 +| 1111 |[Maximum Nesting Depth of Two Valid Parentheses Strings](src/main/kotlin/g1101_1200/s1111_maximum_nesting_depth_of_two_valid_parentheses_strings)| Medium | String, Stack | 207 | 33.33 +| 1110 |[Delete Nodes And Return Forest](src/main/kotlin/g1101_1200/s1110_delete_nodes_and_return_forest)| Medium | Depth_First_Search, Tree, Binary_Tree | 223 | 100.00 +| 1109 |[Corporate Flight Bookings](src/main/kotlin/g1101_1200/s1109_corporate_flight_bookings)| Medium | Array, Prefix_Sum | 719 | 100.00 +| 1108 |[Defanging an IP Address](src/main/kotlin/g1101_1200/s1108_defanging_an_ip_address)| Easy | String | 159 | 62.10 +| 1106 |[Parsing A Boolean Expression](src/main/kotlin/g1101_1200/s1106_parsing_a_boolean_expression)| Hard | String, Stack, Recursion | 205 | 100.00 +| 1105 |[Filling Bookcase Shelves](src/main/kotlin/g1101_1200/s1105_filling_bookcase_shelves)| Medium | Array, Dynamic_Programming | 175 | 33.33 +| 1104 |[Path In Zigzag Labelled Binary Tree](src/main/kotlin/g1101_1200/s1104_path_in_zigzag_labelled_binary_tree)| Medium | Math, Tree, Binary_Tree | 136 | 100.00 +| 1103 |[Distribute Candies to People](src/main/kotlin/g1101_1200/s1103_distribute_candies_to_people)| Easy | Math, Simulation | 129 | 100.00 +| 1079 |[Letter Tile Possibilities](src/main/kotlin/g1001_1100/s1079_letter_tile_possibilities)| Medium | String, Backtracking | 144 | 100.00 +| 1078 |[Occurrences After Bigram](src/main/kotlin/g1001_1100/s1078_occurrences_after_bigram)| Easy | String | 151 | 88.24 +| 1075 |[Project Employees I](src/main/kotlin/g1001_1100/s1075_project_employees_i)| Easy | Database | 1268 | 94.71 +| 1074 |[Number of Submatrices That Sum to Target](src/main/kotlin/g1001_1100/s1074_number_of_submatrices_that_sum_to_target)| Hard | Array, Hash_Table, Matrix, Prefix_Sum | 770 | 100.00 +| 1073 |[Adding Two Negabinary Numbers](src/main/kotlin/g1001_1100/s1073_adding_two_negabinary_numbers)| Medium | Array, Math | 187 | 100.00 +| 1072 |[Flip Columns For Maximum Number of Equal Rows](src/main/kotlin/g1001_1100/s1072_flip_columns_for_maximum_number_of_equal_rows)| Medium | Array, Hash_Table, Matrix | 536 | 100.00 +| 1071 |[Greatest Common Divisor of Strings](src/main/kotlin/g1001_1100/s1071_greatest_common_divisor_of_strings)| Easy | String, Math | 150 | 80.68 +| 1070 |[Product Sales Analysis III](src/main/kotlin/g1001_1100/s1070_product_sales_analysis_iii)| Medium | Database | 1561 | 95.47 | 1068 |[Product Sales Analysis I](src/main/kotlin/g1001_1100/s1068_product_sales_analysis_i)| Easy | Database | 1897 | 79.88 | 1061 |[Lexicographically Smallest Equivalent String](src/main/kotlin/g1001_1100/s1061_lexicographically_smallest_equivalent_string)| Medium | String, Union_Find | 166 | 100.00 | 1054 |[Distant Barcodes](src/main/kotlin/g1001_1100/s1054_distant_barcodes)| Medium | Array, Hash_Table, Sorting, Greedy, Heap_Priority_Queue, Counting | 622 | 75.00 diff --git a/src/main/kotlin/g1001_1100/s1070_product_sales_analysis_iii/readme.md b/src/main/kotlin/g1001_1100/s1070_product_sales_analysis_iii/readme.md new file mode 100644 index 00000000..ebdedf21 --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1070_product_sales_analysis_iii/readme.md @@ -0,0 +1,98 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1070\. Product Sales Analysis III + +Medium + +SQL Schema + +Table: `Sales` + + +-------------+-------+ + | Column Name | Type | + +-------------+-------+ + | sale_id | int | + | product_id | int | + | year | int | + | quantity | int | + | price | int | + +-------------+-------+ + +(sale_id, year) is the primary key of this table. product_id is a foreign key to `Product` table. + +Each row of this table shows a sale on the product product_id in a certain year. + +Note that the price is per unit. + +Table: `Product` + + +--------------+---------+ + | Column Name | Type | + +--------------+---------+ + | product_id | int | + | product_name | varchar | + +--------------+---------+ + +product_id is the primary key of this table. + +Each row of this table indicates the product name of each product. + +Write an SQL query that selects the **product id**, **year**, **quantity**, and **price** for the **first year** of every product sold. + +Return the resulting table in **any order**. + +The query result format is in the following example. + +**Example 1:** + +**Input:** Sales table: + + +---------+------------+------+----------+-------+ + | sale_id | product_id | year | quantity | price | + +---------+------------+------+----------+-------+ + | 1 | 100 | 2008 | 10 | 5000 | + | 2 | 100 | 2009 | 12 | 5000 | + | 7 | 200 | 2011 | 15 | 9000 | + +---------+------------+------+----------+-------+ + +Product table: + + +------------+--------------+ + | product_id | product_name | + +------------+--------------+ + | 100 | Nokia | + | 200 | Apple | + | 300 | Samsung | + +------------+--------------+ + +**Output:** + + +------------+------------+----------+-------+ + | product_id | first_year | quantity | price | + +------------+------------+----------+-------+ + | 100 | 2008 | 10 | 5000 | + | 200 | 2011 | 15 | 9000 | + +------------+------------+----------+-------+ + +## Solution + +```sql +# Write your MySQL query statement below +SELECT + a.product_id, sale_year AS first_year, quantity, price +FROM +( + SELECT + *, + RANK() OVER(PARTITION BY product_id ORDER BY sale_year) as rk + FROM + Sales +) AS a +LEFT JOIN + Product AS p +ON + a.product_id = p.product_id +WHERE + rk = 1 +``` \ No newline at end of file diff --git a/src/main/kotlin/g1001_1100/s1071_greatest_common_divisor_of_strings/readme.md b/src/main/kotlin/g1001_1100/s1071_greatest_common_divisor_of_strings/readme.md new file mode 100644 index 00000000..3a23080c --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1071_greatest_common_divisor_of_strings/readme.md @@ -0,0 +1,56 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1071\. Greatest Common Divisor of Strings + +Easy + +For two strings `s` and `t`, we say "`t` divides `s`" if and only if `s = t + ... + t` (i.e., `t` is concatenated with itself one or more times). + +Given two strings `str1` and `str2`, return _the largest string_ `x` _such that_ `x` _divides both_ `str1` _and_ `str2`. + +**Example 1:** + +**Input:** str1 = "ABCABC", str2 = "ABC" + +**Output:** "ABC" + +**Example 2:** + +**Input:** str1 = "ABABAB", str2 = "ABAB" + +**Output:** "AB" + +**Example 3:** + +**Input:** str1 = "LEET", str2 = "CODE" + +**Output:** "" + +**Constraints:** + +* `1 <= str1.length, str2.length <= 1000` +* `str1` and `str2` consist of English uppercase letters. + +## Solution + +```kotlin +class Solution { + fun gcdOfStrings(str1: String?, str2: String?): String { + if (str1 == null || str2 == null) { + return "" + } + if (str1 == str2) { + return str1 + } + val m = str1.length + val n = str2.length + if (m > n && str1.substring(0, n) == str2) { + return gcdOfStrings(str1.substring(n), str2) + } + return if (n > m && str2.substring(0, m) == str1) { + gcdOfStrings(str2.substring(m), str1) + } else "" + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1001_1100/s1072_flip_columns_for_maximum_number_of_equal_rows/readme.md b/src/main/kotlin/g1001_1100/s1072_flip_columns_for_maximum_number_of_equal_rows/readme.md new file mode 100644 index 00000000..2f129ec1 --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1072_flip_columns_for_maximum_number_of_equal_rows/readme.md @@ -0,0 +1,84 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1072\. Flip Columns For Maximum Number of Equal Rows + +Medium + +You are given an `m x n` binary matrix `matrix`. + +You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from `0` to `1` or vice versa). + +Return _the maximum number of rows that have all values equal after some number of flips_. + +**Example 1:** + +**Input:** matrix = \[\[0,1],[1,1]] + +**Output:** 1 + +**Explanation:** After flipping no values, 1 row has all values equal. + +**Example 2:** + +**Input:** matrix = \[\[0,1],[1,0]] + +**Output:** 2 + +**Explanation:** After flipping values in the first column, both rows have equal values. + +**Example 3:** + +**Input:** matrix = \[\[0,0,0],[0,0,1],[1,1,0]] + +**Output:** 2 + +**Explanation:** After flipping values in the first two columns, the last two rows have equal values. + +**Constraints:** + +* `m == matrix.length` +* `n == matrix[i].length` +* `1 <= m, n <= 300` +* `matrix[i][j]` is either `0` or `1`. + +## Solution + +```kotlin +class Solution { + fun maxEqualRowsAfterFlips(matrix: Array): Int { + /* + Idea: + For a given row[i], 0<=i or + row[i]^row[j] == 111...111 <2> (xor result is a row full of '1') + + Go further, in case<2> row[j] can turn to row[i] by flipping each column of row[j] + IF assume row[i][0] is 0, then question is convert into: + 1> flipping each column of each row if row[i][0] is not '0', + 2> count the frequency of each row. + The biggest number of frequencies is the answer. + */ + + // O(M*N), int M = matrix.length, N = matrix[0].length; + var answer = 0 + val frequency: MutableMap = HashMap() + for (row in matrix) { + val rowStr = StringBuilder() + for (c in row) { + if (row[0] == 1) { + rowStr.append(if (c == 1) 0 else 1) + } else { + rowStr.append(c) + } + } + val key = rowStr.toString() + val value = frequency.getOrDefault(key, 0) + 1 + frequency[key] = value + answer = answer.coerceAtLeast(value) + } + return answer + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1001_1100/s1073_adding_two_negabinary_numbers/readme.md b/src/main/kotlin/g1001_1100/s1073_adding_two_negabinary_numbers/readme.md new file mode 100644 index 00000000..0235bd7a --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1073_adding_two_negabinary_numbers/readme.md @@ -0,0 +1,87 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1073\. Adding Two Negabinary Numbers + +Medium + +Given two numbers `arr1` and `arr2` in base **\-2**, return the result of adding them together. + +Each number is given in _array format_: as an array of 0s and 1s, from most significant bit to least significant bit. For example, `arr = [1,1,0,1]` represents the number `(-2)^3 + (-2)^2 + (-2)^0 = -3`. A number `arr` in _array, format_ is also guaranteed to have no leading zeros: either `arr == [0]` or `arr[0] == 1`. + +Return the result of adding `arr1` and `arr2` in the same format: as an array of 0s and 1s with no leading zeros. + +**Example 1:** + +**Input:** arr1 = [1,1,1,1,1], arr2 = [1,0,1] + +**Output:** [1,0,0,0,0] + +**Explanation:** arr1 represents 11, arr2 represents 5, the output represents 16. + +**Example 2:** + +**Input:** arr1 = [0], arr2 = [0] + +**Output:** [0] + +**Example 3:** + +**Input:** arr1 = [0], arr2 = [1] + +**Output:** [1] + +**Constraints:** + +* `1 <= arr1.length, arr2.length <= 1000` +* `arr1[i]` and `arr2[i]` are `0` or `1` +* `arr1` and `arr2` have no leading zeros + +## Solution + +```kotlin +class Solution { + fun addNegabinary(arr1: IntArray, arr2: IntArray): IntArray { + val len1 = arr1.size + val len2 = arr2.size + val reverseArr1 = IntArray(len1) + for (i in len1 - 1 downTo 0) { + reverseArr1[len1 - i - 1] = arr1[i] + } + val reverseArr2 = IntArray(len2) + for (i in len2 - 1 downTo 0) { + reverseArr2[len2 - i - 1] = arr2[i] + } + val sumArray = IntArray(len1.coerceAtLeast(len2) + 2) + System.arraycopy(reverseArr1, 0, sumArray, 0, len1) + for (i in sumArray.indices) { + if (i < len2) { + sumArray[i] += reverseArr2[i] + } + if (sumArray[i] > 1) { + sumArray[i] -= 2 + sumArray[i + 1]-- + } else if (sumArray[i] == -1) { + sumArray[i] = 1 + sumArray[i + 1]++ + } + } + var resultLen = sumArray.size + for (i in sumArray.indices.reversed()) { + if (sumArray[i] == 0) { + resultLen-- + } else { + break + } + } + if (resultLen == 0) { + return intArrayOf(0) + } + val result = IntArray(resultLen) + for (i in resultLen - 1 downTo 0) { + result[resultLen - i - 1] = sumArray[i] + } + return result + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1001_1100/s1074_number_of_submatrices_that_sum_to_target/readme.md b/src/main/kotlin/g1001_1100/s1074_number_of_submatrices_that_sum_to_target/readme.md new file mode 100644 index 00000000..62a8ac42 --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1074_number_of_submatrices_that_sum_to_target/readme.md @@ -0,0 +1,75 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1074\. Number of Submatrices That Sum to Target + +Hard + +Given a `matrix` and a `target`, return the number of non-empty submatrices that sum to target. + +A submatrix `x1, y1, x2, y2` is the set of all cells `matrix[x][y]` with `x1 <= x <= x2` and `y1 <= y <= y2`. + +Two submatrices `(x1, y1, x2, y2)` and `(x1', y1', x2', y2')` are different if they have some coordinate that is different: for example, if `x1 != x1'`. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2020/09/02/mate1.jpg) + +**Input:** matrix = \[\[0,1,0],[1,1,1],[0,1,0]], target = 0 + +**Output:** 4 + +**Explanation:** The four 1x1 submatrices that only contain 0. + +**Example 2:** + +**Input:** matrix = \[\[1,-1],[-1,1]], target = 0 + +**Output:** 5 + +**Explanation:** The two 1x2 submatrices, plus the two 2x1 submatrices, plus the 2x2 submatrix. + +**Example 3:** + +**Input:** matrix = \[\[904]], target = 0 + +**Output:** 0 + +**Constraints:** + +* `1 <= matrix.length <= 100` +* `1 <= matrix[0].length <= 100` +* `-1000 <= matrix[i] <= 1000` +* `-10^8 <= target <= 10^8` + +## Solution + +```kotlin +class Solution { + fun numSubmatrixSumTarget(matrix: Array, target: Int): Int { + val rows = matrix.size + val columns = matrix[0].size + for (i in 0 until rows) { + for (j in 1 until columns) { + matrix[i][j] += matrix[i][j - 1] + } + } + val sumMap: HashMap = HashMap() + var cur: Int + var res = 0 + for (i in 0 until columns) { + for (j in i until columns) { + sumMap.clear() + sumMap[0] = 1 + cur = 0 + for (ints in matrix) { + cur += ints[j] - if (i > 0) ints[i - 1] else 0 + res += sumMap.getOrDefault(cur - target, 0) + sumMap[cur] = sumMap.getOrDefault(cur, 0) + 1 + } + } + } + return res + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1001_1100/s1075_project_employees_i/readme.md b/src/main/kotlin/g1001_1100/s1075_project_employees_i/readme.md new file mode 100644 index 00000000..77e11852 --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1075_project_employees_i/readme.md @@ -0,0 +1,90 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1075\. Project Employees I + +Easy + +SQL Schema + +Table: `Project` + + +-------------+---------+ + | Column Name | Type | + +-------------+---------+ + | project_id | int | + | employee_id | int | + +-------------+---------+ + +(project_id, employee_id) is the primary key of this table. + +employee_id is a foreign key to `Employee` table. + +Each row of this table indicates that the employee with employee_id is working on the project with project_id. + +Table: `Employee` + + +------------------+---------+ + | Column Name | Type | + +------------------+---------+ + | employee_id | int | + | name | varchar | + | experience_years | int | + +------------------+---------+ + +employee_id is the primary key of this table. It's guaranteed that experience_years is not NULL. + +Each row of this table contains information about one employee. + +Write an SQL query that reports the **average** experience years of all the employees for each project, **rounded to 2 digits**. + +Return the result table in **any order**. + +The query result format is in the following example. + +**Example 1:** + +**Input:** Project table: + + +-------------+-------------+ + | project_id | employee_id | + +-------------+-------------+ + | 1 | 1 | + | 1 | 2 | + | 1 | 3 | + | 2 | 1 | + | 2 | 4 | + +-------------+-------------+ + +Employee table: + + +-------------+--------+------------------+ + | employee_id | name | experience_years | + +-------------+--------+------------------+ + | 1 | Khaled | 3 | + | 2 | Ali | 2 | + | 3 | John | 1 | + | 4 | Doe | 2 | + +-------------+--------+------------------+ + +**Output:** + + +-------------+---------------+ + | project_id | average_years | + +-------------+---------------+ + | 1 | 2.00 | + | 2 | 2.50 | + +-------------+---------------+ + +**Explanation:** The average experience years for the first project is (3 + 2 + 1) / 3 = 2.00 and for the second project is (3 + 2) / 2 = 2.50 + +## Solution + +```sql +# Write your MySQL query statement below +select project_id,round(avg( + experience_years +),2) as average_years from Project p +left join +Employee e on p.employee_id=e.employee_id group by p.project_id; +``` \ No newline at end of file diff --git a/src/main/kotlin/g1001_1100/s1078_occurrences_after_bigram/readme.md b/src/main/kotlin/g1001_1100/s1078_occurrences_after_bigram/readme.md new file mode 100644 index 00000000..8f1d1857 --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1078_occurrences_after_bigram/readme.md @@ -0,0 +1,52 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1078\. Occurrences After Bigram + +Easy + +Given two strings `first` and `second`, consider occurrences in some text of the form `"first second third"`, where `second` comes immediately after `first`, and `third` comes immediately after `second`. + +Return _an array of all the words_ `third` _for each occurrence of_ `"first second third"`. + +**Example 1:** + +**Input:** text = "alice is a good girl she is a good student", first = "a", second = "good" + +**Output:** ["girl","student"] + +**Example 2:** + +**Input:** text = "we will we will rock you", first = "we", second = "will" + +**Output:** ["we","rock"] + +**Constraints:** + +* `1 <= text.length <= 1000` +* `text` consists of lowercase English letters and spaces. +* All the words in `text` a separated by **a single space**. +* `1 <= first.length, second.length <= 10` +* `first` and `second` consist of lowercase English letters. + +## Solution + +```kotlin +class Solution { + fun findOcurrences(text: String, first: String, second: String): Array { + val list: MutableList = ArrayList() + val str = text.split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() + for (i in str.indices) { + if (str[i] == first && str.size - 1 >= i + 2 && str[i + 1] == second) { + list.add(str[i + 2]) + } + } + val s = arrayOfNulls(list.size) + var j = 0 + for (ele in list) { + s[j++] = ele + } + return s + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1001_1100/s1079_letter_tile_possibilities/readme.md b/src/main/kotlin/g1001_1100/s1079_letter_tile_possibilities/readme.md new file mode 100644 index 00000000..a1da10be --- /dev/null +++ b/src/main/kotlin/g1001_1100/s1079_letter_tile_possibilities/readme.md @@ -0,0 +1,67 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1079\. Letter Tile Possibilities + +Medium + +You have `n` `tiles`, where each tile has one letter `tiles[i]` printed on it. + +Return _the number of possible non-empty sequences of letters_ you can make using the letters printed on those `tiles`. + +**Example 1:** + +**Input:** tiles = "AAB" + +**Output:** 8 + +**Explanation:** The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA". + +**Example 2:** + +**Input:** tiles = "AAABBC" + +**Output:** 188 + +**Example 3:** + +**Input:** tiles = "V" + +**Output:** 1 + +**Constraints:** + +* `1 <= tiles.length <= 7` +* `tiles` consists of uppercase English letters. + +## Solution + +```kotlin +class Solution { + private var count = 0 + + fun numTilePossibilities(tiles: String): Int { + count = 0 + val chars = tiles.toCharArray() + chars.sort() + val visited = BooleanArray(chars.size) + dfs(chars, 0, visited) + return count + } + + private fun dfs(chars: CharArray, length: Int, visited: BooleanArray) { + if (length == chars.size) { + return + } + for (i in chars.indices) { + if (visited[i] || i - 1 >= 0 && chars[i] == chars[i - 1] && !visited[i - 1]) { + continue + } + count++ + visited[i] = true + dfs(chars, length + 1, visited) + visited[i] = false + } + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1103_distribute_candies_to_people/readme.md b/src/main/kotlin/g1101_1200/s1103_distribute_candies_to_people/readme.md new file mode 100644 index 00000000..084afd46 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1103_distribute_candies_to_people/readme.md @@ -0,0 +1,82 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1103\. Distribute Candies to People + +Easy + +We distribute some number of `candies`, to a row of **`n = num_people`** people in the following way: + +We then give 1 candy to the first person, 2 candies to the second person, and so on until we give `n` candies to the last person. + +Then, we go back to the start of the row, giving `n + 1` candies to the first person, `n + 2` candies to the second person, and so on until we give `2 * n` candies to the last person. + +This process repeats (with us giving one more candy each time, and moving to the start of the row after we reach the end) until we run out of candies. The last person will receive all of our remaining candies (not necessarily one more than the previous gift). + +Return an array (of length `num_people` and sum `candies`) that represents the final distribution of candies. + +**Example 1:** + +**Input:** candies = 7, num\_people = 4 + +**Output:** [1,2,3,1] + +**Explanation:** + +On the first turn, ans[0] += 1, and the array is [1,0,0,0]. + +On the second turn, ans[1] += 2, and the array is [1,2,0,0]. + +On the third turn, ans[2] += 3, and the array is [1,2,3,0]. + +On the fourth turn, ans[3] += 1 (because there is only one candy left), and the final array is [1,2,3,1]. + +**Example 2:** + +**Input:** candies = 10, num\_people = 3 + +**Output:** [5,2,3] + +**Explanation:** + +On the first turn, ans[0] += 1, and the array is [1,0,0]. + +On the second turn, ans[1] += 2, and the array is [1,2,0]. + +On the third turn, ans[2] += 3, and the array is [1,2,3]. + +On the fourth turn, ans[0] += 4, and the final array is [5,2,3]. + +**Constraints:** + +* 1 <= candies <= 10^9 +* 1 <= num\_people <= 1000 + +## Solution + +```kotlin +@Suppress("NAME_SHADOWING") +class Solution { + fun distributeCandies(candies: Int, numPeople: Int): IntArray { + var candies = candies + val candiesDistribution = IntArray(numPeople) + var count = 1 + while (candies > 0) { + for (i in 0 until numPeople) { + if (candies >= count) { + candiesDistribution[i] += count + candies -= count + count++ + } else if (candies > 0) { + candiesDistribution[i] += candies + candies -= candies + } + if (candies == 0) { + return candiesDistribution + } + } + } + return candiesDistribution + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1104_path_in_zigzag_labelled_binary_tree/readme.md b/src/main/kotlin/g1101_1200/s1104_path_in_zigzag_labelled_binary_tree/readme.md new file mode 100644 index 00000000..2fbedf32 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1104_path_in_zigzag_labelled_binary_tree/readme.md @@ -0,0 +1,55 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1104\. Path In Zigzag Labelled Binary Tree + +Medium + +In an infinite binary tree where every node has two children, the nodes are labelled in row order. + +In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right, while in the even numbered rows (second, fourth, sixth,...), the labelling is right to left. + +![](https://assets.leetcode.com/uploads/2019/06/24/tree.png) + +Given the `label` of a node in this tree, return the labels in the path from the root of the tree to the node with that `label`. + +**Example 1:** + +**Input:** label = 14 + +**Output:** [1,3,4,14] + +**Example 2:** + +**Input:** label = 26 + +**Output:** [1,2,6,10,26] + +**Constraints:** + +* `1 <= label <= 10^6` + +## Solution + +```kotlin +import java.util.LinkedList + +@Suppress("NAME_SHADOWING") +class Solution { + fun pathInZigZagTree(label: Int): List { + var label = label + val answer: MutableList = LinkedList() + while (label != 0) { + answer.add(0, label) + val logNode = (Math.log(label.toDouble()) / Math.log(2.0)).toInt() + val levelStart = Math.pow(2.0, logNode.toDouble()).toInt() + val diff = label - levelStart + val d2 = diff / 2 + val prevEnd = levelStart - 1 + val prevLabel = prevEnd - d2 + label = prevLabel + } + return answer + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1105_filling_bookcase_shelves/readme.md b/src/main/kotlin/g1101_1200/s1105_filling_bookcase_shelves/readme.md new file mode 100644 index 00000000..f2ff9787 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1105_filling_bookcase_shelves/readme.md @@ -0,0 +1,69 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1105\. Filling Bookcase Shelves + +Medium + +You are given an array `books` where books[i] = [thicknessi, heighti] indicates the thickness and height of the ith book. You are also given an integer `shelfWidth`. + +We want to place these books in order onto bookcase shelves that have a total width `shelfWidth`. + +We choose some of the books to place on this shelf such that the sum of their thickness is less than or equal to `shelfWidth`, then build another level of the shelf of the bookcase so that the total height of the bookcase has increased by the maximum height of the books we just put down. We repeat this process until there are no more books to place. + +Note that at each step of the above process, the order of the books we place is the same order as the given sequence of books. + +* For example, if we have an ordered list of `5` books, we might place the first and second book onto the first shelf, the third book on the second shelf, and the fourth and fifth book on the last shelf. + +Return _the minimum possible height that the total bookshelf can be after placing shelves in this manner_. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2019/06/24/shelves.png) + +**Input:** books = \[\[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelf\_width = 4 + +**Output:** 6 + +**Explanation:** + +The sum of the heights of the 3 shelves is 1 + 3 + 2 = 6. + +Notice that book number 2 does not have to be on the first shelf. + +**Example 2:** + +**Input:** books = \[\[1,3],[2,4],[3,2]], shelfWidth = 6 + +**Output:** 4 + +**Constraints:** + +* `1 <= books.length <= 1000` +* 1 <= thicknessi <= shelfWidth <= 1000 +* 1 <= heighti <= 1000 + +## Solution + +```kotlin +class Solution { + fun minHeightShelves(books: Array, shelfWidth: Int): Int { + val n = books.size + val dp = IntArray(n + 1) + dp.fill(Int.MAX_VALUE) + dp[0] = 0 + for (i in 1..n) { + var widthLeft = shelfWidth + var maxH = 0 + for (j in i - 1 downTo 0) { + widthLeft -= books[j][0] + maxH = Math.max(maxH, books[j][1]) + if (widthLeft >= 0) { + dp[i] = Math.min(dp[i], maxH + dp[j]) + } + } + } + return dp[n] + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1106_parsing_a_boolean_expression/readme.md b/src/main/kotlin/g1101_1200/s1106_parsing_a_boolean_expression/readme.md new file mode 100644 index 00000000..ec67e20d --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1106_parsing_a_boolean_expression/readme.md @@ -0,0 +1,138 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1106\. Parsing A Boolean Expression + +Hard + +Return the result of evaluating a given boolean `expression`, represented as a string. + +An expression can either be: + +* `"t"`, evaluating to `True`; +* `"f"`, evaluating to `False`; +* `"!(expr)"`, evaluating to the logical NOT of the inner expression `expr`; +* `"&(expr1,expr2,...)"`, evaluating to the logical AND of 2 or more inner expressions `expr1, expr2, ...`; +* `"|(expr1,expr2,...)"`, evaluating to the logical OR of 2 or more inner expressions `expr1, expr2, ...` + +**Example 1:** + +**Input:** expression = "!(f)" + +**Output:** true + +**Example 2:** + +**Input:** expression = "\|(f,t)" + +**Output:** true + +**Example 3:** + +**Input:** expression = "&(t,f)" + +**Output:** false + +**Constraints:** + +* 1 <= expression.length <= 2 * 104 +* `expression[i]` consists of characters in `{'(', ')', '&', '|', '!', 't', 'f', ','}`. +* `expression` is a valid expression representing a boolean, as given in the description. + +## Solution + +```kotlin +class Solution { + private var source: String? = null + private var index = 0 + + fun parseBoolExpr(expression: String?): Boolean { + source = expression + index = 0 + return expr() + } + + private fun expr(): Boolean { + val res: Boolean + res = if (match('!')) { + not() + } else if (match('&')) { + and() + } else if (match('|')) { + or() + } else { + bool() + } + return res + } + + private operator fun not(): Boolean { + consume('!') + return !group()[0] + } + + private fun or(): Boolean { + consume('|') + var res = false + for (e in group()) { + res = res or e + } + return res + } + + private fun and(): Boolean { + consume('&') + var res = true + for (e in group()) { + res = res and e + } + return res + } + + private fun group(): List { + consume('(') + val res: MutableList = ArrayList() + while (!match(')')) { + res.add(expr()) + if (match(',')) { + advance() + } + } + consume(')') + return res + } + + private fun bool(): Boolean { + val isTrue = match('t') + advance() + return isTrue + } + + private val isAtEnd: Boolean + private get() = index >= source!!.length + + private fun advance() { + if (isAtEnd) { + return + } + index++ + } + + private fun peek(): Char { + return source!![index] + } + + private fun match(ch: Char): Boolean { + return if (isAtEnd) { + false + } else peek() == ch + } + + private fun consume(ch: Char) { + if (!match(ch)) { + return + } + advance() + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1108_defanging_an_ip_address/readme.md b/src/main/kotlin/g1101_1200/s1108_defanging_an_ip_address/readme.md new file mode 100644 index 00000000..9fde3815 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1108_defanging_an_ip_address/readme.md @@ -0,0 +1,36 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1108\. Defanging an IP Address + +Easy + +Given a valid (IPv4) IP `address`, return a defanged version of that IP address. + +A _defanged IP address_ replaces every period `"."` with `"[.]"`. + +**Example 1:** + +**Input:** address = "1.1.1.1" + +**Output:** "1[.]1[.]1[.]1" + +**Example 2:** + +**Input:** address = "255.100.50.0" + +**Output:** "255[.]100[.]50[.]0" + +**Constraints:** + +* The given `address` is a valid IPv4 address. + +## Solution + +```kotlin +class Solution { + fun defangIPaddr(address: String): String { + return address.replace(".", "[.]") + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1109_corporate_flight_bookings/readme.md b/src/main/kotlin/g1101_1200/s1109_corporate_flight_bookings/readme.md new file mode 100644 index 00000000..a42565e2 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1109_corporate_flight_bookings/readme.md @@ -0,0 +1,74 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1109\. Corporate Flight Bookings + +Medium + +There are `n` flights that are labeled from `1` to `n`. + +You are given an array of flight bookings `bookings`, where bookings[i] = [firsti, lasti, seatsi] represents a booking for flights firsti through lasti (**inclusive**) with seatsi seats reserved for **each flight** in the range. + +Return _an array_ `answer` _of length_ `n`_, where_ `answer[i]` _is the total number of seats reserved for flight_ `i`. + +**Example 1:** + +**Input:** bookings = \[\[1,2,10],[2,3,20],[2,5,25]], n = 5 + +**Output:** [10,55,45,25,25] + +**Explanation:** + +Flight labels: 1 2 3 4 5 + +Booking 1 reserved: 10 10 + +Booking 2 reserved: 20 20 + +Booking 3 reserved: 25 25 25 25 + +Total seats: 10 55 45 25 25 Hence, answer = [10,55,45,25,25] + +**Example 2:** + +**Input:** bookings = \[\[1,2,10],[2,2,15]], n = 2 + +**Output:** [10,25] + +**Explanation:** + +Flight labels: 1 2 + +Booking 1 reserved: 10 10 + +Booking 2 reserved: 15 + +Total seats: 10 25 Hence, answer = [10,25] + +**Constraints:** + +* 1 <= n <= 2 * 104 +* 1 <= bookings.length <= 2 * 104 +* `bookings[i].length == 3` +* 1 <= firsti <= lasti <= n +* 1 <= seatsi <= 104 + +## Solution + +```kotlin +class Solution { + fun corpFlightBookings(bookings: Array, n: Int): IntArray { + val ret = IntArray(n) + for (booking in bookings) { + ret[booking[0] - 1] += booking[2] + if (booking[1] < n) { + ret[booking[1]] -= booking[2] + } + } + for (i in 1 until n) { + ret[i] += ret[i - 1] + } + return ret + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1110_delete_nodes_and_return_forest/readme.md b/src/main/kotlin/g1101_1200/s1110_delete_nodes_and_return_forest/readme.md new file mode 100644 index 00000000..f3e70d17 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1110_delete_nodes_and_return_forest/readme.md @@ -0,0 +1,91 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1110\. Delete Nodes And Return Forest + +Medium + +Given the `root` of a binary tree, each node in the tree has a distinct value. + +After deleting all nodes with a value in `to_delete`, we are left with a forest (a disjoint union of trees). + +Return the roots of the trees in the remaining forest. You may return the result in any order. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2019/07/01/screen-shot-2019-07-01-at-53836-pm.png) + +**Input:** root = [1,2,3,4,5,6,7], to\_delete = [3,5] + +**Output:** [[1,2,null,4],[6],[7]] + +**Example 2:** + +**Input:** root = [1,2,4,null,3], to\_delete = [3] + +**Output:** [[1,2,4]] + +**Constraints:** + +* The number of nodes in the given tree is at most `1000`. +* Each node has a distinct value between `1` and `1000`. +* `to_delete.length <= 1000` +* `to_delete` contains distinct values between `1` and `1000`. + +## Solution + +```kotlin +import com_github_leetcode.TreeNode +import java.util.LinkedList +import java.util.Queue + +/* + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + private var toDelete: MutableSet = mutableSetOf() + private val nodes: Queue = LinkedList() + + private fun deleteAndSplit(root: TreeNode?): TreeNode? { + if (root == null) { + return null + } + if (toDelete.contains(root.`val`)) { + if (root.left != null) { + nodes.add(root.left) + } + if (root.right != null) { + nodes.add(root.right) + } + return null + } + root.left = deleteAndSplit(root.left) + root.right = deleteAndSplit(root.right) + return root + } + + fun delNodes(root: TreeNode?, localToDelete: IntArray): List { + toDelete = HashSet() + for (node in localToDelete) { + toDelete.add(node) + } + nodes.add(root) + val forests: MutableList = ArrayList() + while (nodes.isNotEmpty()) { + var node = nodes.poll() + node = deleteAndSplit(node) + if (node != null) { + forests.add(node) + } + } + return forests + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1111_maximum_nesting_depth_of_two_valid_parentheses_strings/readme.md b/src/main/kotlin/g1101_1200/s1111_maximum_nesting_depth_of_two_valid_parentheses_strings/readme.md new file mode 100644 index 00000000..f8d1a943 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1111_maximum_nesting_depth_of_two_valid_parentheses_strings/readme.md @@ -0,0 +1,73 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1111\. Maximum Nesting Depth of Two Valid Parentheses Strings + +Medium + +A string is a _valid parentheses string_ (denoted VPS) if and only if it consists of `"("` and `")"` characters only, and: + +* It is the empty string, or +* It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are VPS's, or +* It can be written as `(A)`, where `A` is a VPS. + +We can similarly define the _nesting depth_ `depth(S)` of any VPS `S` as follows: + +* `depth("") = 0` +* `depth(A + B) = max(depth(A), depth(B))`, where `A` and `B` are VPS's +* `depth("(" + A + ")") = 1 + depth(A)`, where `A` is a VPS. + +For example, `""`, `"()()"`, and `"()(()())"` are VPS's (with nesting depths 0, 1, and 2), and `")("` and `"(()"` are not VPS's. + +Given a VPS seq, split it into two disjoint subsequences `A` and `B`, such that `A` and `B` are VPS's (and `A.length + B.length = seq.length`). + +Now choose **any** such `A` and `B` such that `max(depth(A), depth(B))` is the minimum possible value. + +Return an `answer` array (of length `seq.length`) that encodes such a choice of `A` and `B`: `answer[i] = 0` if `seq[i]` is part of `A`, else `answer[i] = 1`. Note that even though multiple answers may exist, you may return any of them. + +**Example 1:** + +**Input:** seq = "(()())" + +**Output:** [0,1,1,1,1,0] + +**Example 2:** + +**Input:** seq = "()(())()" + +**Output:** [0,0,0,1,1,0,1,1] + +**Constraints:** + +* `1 <= seq.size <= 10000` + +## Solution + +```kotlin +class Solution { + fun maxDepthAfterSplit(seq: String): IntArray { + val n = seq.length + val ans = IntArray(n) + val chars = seq.toCharArray() + var depth = 0 + for (i in 0 until n) { + if (chars[i] == '(') { + depth++ + if (depth % 2 == 0) { + ans[i] = 0 + } else { + ans[i] = 1 + } + } else { + if (depth % 2 == 0) { + ans[i] = 0 + } else { + ans[i] = 1 + } + depth-- + } + } + return ans + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1114_print_in_order/readme.md b/src/main/kotlin/g1101_1200/s1114_print_in_order/readme.md new file mode 100644 index 00000000..a971c6a4 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1114_print_in_order/readme.md @@ -0,0 +1,74 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1114\. Print in Order + +Easy + +Suppose we have a class: + +public class Foo { public void first() { print("first"); } public void second() { print("second"); } public void third() { print("third"); } } + +The same instance of `Foo` will be passed to three different threads. Thread A will call `first()`, thread B will call `second()`, and thread C will call `third()`. Design a mechanism and modify the program to ensure that `second()` is executed after `first()`, and `third()` is executed after `second()`. + +**Note:** + +We do not know how the threads will be scheduled in the operating system, even though the numbers in the input seem to imply the ordering. The input format you see is mainly to ensure our tests' comprehensiveness. + +**Example 1:** + +**Input:** nums = [1,2,3] + +**Output:** "firstsecondthird" + +**Explanation:** There are three threads being fired asynchronously. The input [1,2,3] means thread A calls first(), thread B calls second(), and thread C calls third(). "firstsecondthird" is the correct output. + +**Example 2:** + +**Input:** nums = [1,3,2] + +**Output:** "firstsecondthird" + +**Explanation:** The input [1,3,2] means thread A calls first(), thread B calls third(), and thread C calls second(). "firstsecondthird" is the correct output. + +**Constraints:** + +* `nums` is a permutation of `[1, 2, 3]`. + +## Solution + +```kotlin +class Foo { + @Volatile + private var firstFinished = false + + @Volatile + private var secondFinished = false + fun first(printFirst: Runnable) { + // printFirst.run() outputs "first". Do not change or remove this line. + printFirst.run() + firstFinished = true + } + + fun second(printSecond: Runnable) { + // printSecond.run() outputs "second". Do not change or remove this line. + while (true) { + if (firstFinished) { + printSecond.run() + secondFinished = true + break + } + } + } + + fun third(printThird: Runnable) { + // printThird.run() outputs "third". Do not change or remove this line. + while (true) { + if (firstFinished && secondFinished) { + printThird.run() + break + } + } + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1115_print_foobar_alternately/readme.md b/src/main/kotlin/g1101_1200/s1115_print_foobar_alternately/readme.md new file mode 100644 index 00000000..581d943a --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1115_print_foobar_alternately/readme.md @@ -0,0 +1,78 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1115\. Print FooBar Alternately + +Medium + +Suppose you are given the following code: + +class FooBar { public void foo() { for (int i = 0; i < n; i++) { print("foo"); } } public void bar() { for (int i = 0; i < n; i++) { print("bar"); } } } + +The same instance of `FooBar` will be passed to two different threads: + +* thread `A` will call `foo()`, while +* thread `B` will call `bar()`. + +Modify the given program to output `"foobar"` `n` times. + +**Example 1:** + +**Input:** n = 1 + +**Output:** "foobar" + +**Explanation:** There are two threads being fired asynchronously. One of them calls foo(), while the other calls bar(). "foobar" is being output 1 time. + +**Example 2:** + +**Input:** n = 2 + +**Output:** "foobarfoobar" + +**Explanation:** "foobar" is being output 2 times. + +**Constraints:** + +* `1 <= n <= 1000` + +## Solution + +```kotlin +import java.util.concurrent.Semaphore + +class FooBar(private val n: Int) { + private val fooSemaphore: Semaphore + private val barSemaphore: Semaphore + + init { + fooSemaphore = Semaphore(1) + barSemaphore = Semaphore(1) + try { + barSemaphore.acquire() + } catch (ignored: InterruptedException) { + // ignored + } + } + + @Throws(InterruptedException::class) + fun foo(printFoo: Runnable) { + for (i in 0 until n) { + fooSemaphore.acquire() + // printFoo.run() outputs "foo". Do not change or remove this line. + printFoo.run() + barSemaphore.release() + } + } + + @Throws(InterruptedException::class) + fun bar(printBar: Runnable) { + for (i in 0 until n) { + barSemaphore.acquire() + // printBar.run() outputs "bar". Do not change or remove this line. + printBar.run() + fooSemaphore.release() + } + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1116_print_zero_even_odd/readme.md b/src/main/kotlin/g1101_1200/s1116_print_zero_even_odd/readme.md new file mode 100644 index 00000000..2292a307 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1116_print_zero_even_odd/readme.md @@ -0,0 +1,113 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1116\. Print Zero Even Odd + +Medium + +You have a function `printNumber` that can be called with an integer parameter and prints it to the console. + +* For example, calling `printNumber(7)` prints `7` to the console. + +You are given an instance of the class `ZeroEvenOdd` that has three functions: `zero`, `even`, and `odd`. The same instance of `ZeroEvenOdd` will be passed to three different threads: + +* **Thread A:** calls `zero()` that should only output `0`'s. +* **Thread B:** calls `even()` that should only output even numbers. +* **Thread C:** calls `odd()` that should only output odd numbers. + +Modify the given class to output the series `"010203040506..."` where the length of the series must be `2n`. + +Implement the `ZeroEvenOdd` class: + +* `ZeroEvenOdd(int n)` Initializes the object with the number `n` that represents the numbers that should be printed. +* `void zero(printNumber)` Calls `printNumber` to output one zero. +* `void even(printNumber)` Calls `printNumber` to output one even number. +* `void odd(printNumber)` Calls `printNumber` to output one odd number. + +**Example 1:** + +**Input:** n = 2 + +**Output:** "0102" + +**Explanation:** There are three threads being fired asynchronously. One of them calls zero(), the other calls even(), and the last one calls odd(). "0102" is the correct output. + +**Example 2:** + +**Input:** n = 5 + +**Output:** "0102030405" + +**Constraints:** + +* `1 <= n <= 1000` + +## Solution + +```kotlin +import java.util.concurrent.Semaphore +import java.util.function.IntConsumer + +class ZeroEvenOdd(private val n: Int) { + private val zeroSemaphore = Semaphore(1) + private val oddSemaphore = Semaphore(1) + private val evenSemaphore = Semaphore(1) + + init { + try { + oddSemaphore.acquire() + evenSemaphore.acquire() + } catch (ignored: InterruptedException) { + // ignored + } + } + + // printNumber.accept(x) outputs "x", where x is an integer. + @Throws(InterruptedException::class) + fun zero(printNumber: IntConsumer) { + for (i in 1..n) { + zeroSemaphore.acquire() + printNumber.accept(0) + if (i % 2 == 0) { + oddSemaphore.release() + } else { + evenSemaphore.release() + } + } + oddSemaphore.release() + evenSemaphore.release() + } + + @Throws(InterruptedException::class) + fun odd(printNumber: IntConsumer) { + var i = 1 + while (i <= n) { + evenSemaphore.acquire() + if (i > n) { + zeroSemaphore.release() + evenSemaphore.release() + break + } + printNumber.accept(i) + zeroSemaphore.release() + i += 2 + } + } + + @Throws(InterruptedException::class) + fun even(printNumber: IntConsumer) { + var i = 2 + while (i <= n) { + oddSemaphore.acquire() + if (i > n) { + zeroSemaphore.release() + oddSemaphore.release() + break + } + printNumber.accept(i) + zeroSemaphore.release() + i += 2 + } + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1117_building_h2o/readme.md b/src/main/kotlin/g1101_1200/s1117_building_h2o/readme.md new file mode 100644 index 00000000..70aa12ae --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1117_building_h2o/readme.md @@ -0,0 +1,95 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1117\. Building H2O + +Medium + +There are two kinds of threads: `oxygen` and `hydrogen`. Your goal is to group these threads to form water molecules. + +There is a barrier where each thread has to wait until a complete molecule can be formed. Hydrogen and oxygen threads will be given `releaseHydrogen` and `releaseOxygen` methods respectively, which will allow them to pass the barrier. These threads should pass the barrier in groups of three, and they must immediately bond with each other to form a water molecule. You must guarantee that all the threads from one molecule bond before any other threads from the next molecule do. + +In other words: + +* If an oxygen thread arrives at the barrier when no hydrogen threads are present, it must wait for two hydrogen threads. +* If a hydrogen thread arrives at the barrier when no other threads are present, it must wait for an oxygen thread and another hydrogen thread. + +We do not have to worry about matching the threads up explicitly; the threads do not necessarily know which other threads they are paired up with. The key is that threads pass the barriers in complete sets; thus, if we examine the sequence of threads that bind and divide them into groups of three, each group should contain one oxygen and two hydrogen threads. + +Write synchronization code for oxygen and hydrogen molecules that enforces these constraints. + +**Example 1:** + +**Input:** water = "HOH" + +**Output:** "HHO" + +**Explanation:** "HOH" and "OHH" are also valid answers. + +**Example 2:** + +**Input:** water = "OOHHHH" + +**Output:** "HHOHHO" + +**Explanation:** "HOHHHO", "OHHHHO", "HHOHOH", "HOHHOH", "OHHHOH", "HHOOHH", "HOHOHH" and "OHHOHH" are also valid answers. + +**Constraints:** + +* `3 * n == water.length` +* `1 <= n <= 20` +* `water[i]` is either `'H'` or `'O'`. +* There will be exactly `2 * n` `'H'` in `water`. +* There will be exactly `n` `'O'` in `water`. + +## Solution + +```kotlin +import java.util.concurrent.Semaphore + +class H2O { + private val hSemaphore: Semaphore + private val oSemaphore: Semaphore + + init { + hSemaphore = Semaphore(2) + oSemaphore = Semaphore(2) + } + + @Throws(InterruptedException::class) + fun hydrogen(releaseHydrogen: Runnable) { + hSemaphore.acquire() + // releaseHydrogen.run() outputs "H". Do not change or remove this line. + releaseHydrogen.run() + oSemaphore.release() + } + + @Throws(InterruptedException::class) + fun oxygen(releaseOxygen: Runnable) { + oSemaphore.acquire(2) + // releaseOxygen.run() outputs "O". Do not change or remove this line. + releaseOxygen.run() + hSemaphore.release(2) + } + + class HydrogenRunnable(private val h2O: H2O) : Runnable { + override fun run() { + try { + h2O.hydrogen { print('H') } + } catch (ignored: InterruptedException) { + // ignored + } + } + } + + class OxygenRunnable(private val h2O: H2O) : Runnable { + override fun run() { + try { + h2O.oxygen { print('O') } + } catch (ignored: InterruptedException) { + // ignored + } + } + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1122_relative_sort_array/readme.md b/src/main/kotlin/g1101_1200/s1122_relative_sort_array/readme.md new file mode 100644 index 00000000..6a6faa57 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1122_relative_sort_array/readme.md @@ -0,0 +1,58 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1122\. Relative Sort Array + +Easy + +Given two arrays `arr1` and `arr2`, the elements of `arr2` are distinct, and all elements in `arr2` are also in `arr1`. + +Sort the elements of `arr1` such that the relative ordering of items in `arr1` are the same as in `arr2`. Elements that do not appear in `arr2` should be placed at the end of `arr1` in **ascending** order. + +**Example 1:** + +**Input:** arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6] + +**Output:** [2,2,2,1,4,3,3,9,6,7,19] + +**Example 2:** + +**Input:** arr1 = [28,6,22,8,44,17], arr2 = [22,28,8,6] + +**Output:** [22,28,8,6,17,44] + +**Constraints:** + +* `1 <= arr1.length, arr2.length <= 1000` +* `0 <= arr1[i], arr2[i] <= 1000` +* All the elements of `arr2` are **distinct**. +* Each `arr2[i]` is in `arr1`. + +## Solution + +```kotlin +class Solution { + fun relativeSortArray(arr1: IntArray, arr2: IntArray): IntArray { + val map = IntArray(1001) + for (a in arr1) { + map[a]++ + } + var i = 0 + for (b in arr2) { + while (map[b] != 0) { + map[b]-- + arr1[i] = b + i++ + } + } + for (j in map.indices) { + while (map[j] != 0) { + arr1[i] = j + map[j]-- + i++ + } + } + return arr1 + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1123_lowest_common_ancestor_of_deepest_leaves/readme.md b/src/main/kotlin/g1101_1200/s1123_lowest_common_ancestor_of_deepest_leaves/readme.md new file mode 100644 index 00000000..e997eb4c --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1123_lowest_common_ancestor_of_deepest_leaves/readme.md @@ -0,0 +1,89 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1123\. Lowest Common Ancestor of Deepest Leaves + +Medium + +Given the `root` of a binary tree, return _the lowest common ancestor of its deepest leaves_. + +Recall that: + +* The node of a binary tree is a leaf if and only if it has no children +* The depth of the root of the tree is `0`. if the depth of a node is `d`, the depth of each of its children is `d + 1`. +* The lowest common ancestor of a set `S` of nodes, is the node `A` with the largest depth such that every node in `S` is in the subtree with root `A`. + +**Example 1:** + +![](https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/01/sketch1.png) + +**Input:** root = [3,5,1,6,2,0,8,null,null,7,4] + +**Output:** [2,7,4] + +**Explanation:** We return the node with value 2, colored in yellow in the diagram. The nodes coloured in blue are the deepest leaf-nodes of the tree. Note that nodes 6, 0, and 8 are also leaf nodes, but the depth of them is 2, but the depth of nodes 7 and 4 is 3. + +**Example 2:** + +**Input:** root = [1] + +**Output:** [1] + +**Explanation:** The root is the deepest node in the tree, and it's the lca of itself. + +**Example 3:** + +**Input:** root = [0,1,3,null,2] + +**Output:** [2] + +**Explanation:** The deepest leaf node in the tree is 2, the lca of one node is itself. + +**Constraints:** + +* The number of nodes in the tree will be in the range `[1, 1000]`. +* `0 <= Node.val <= 1000` +* The values of the nodes in the tree are **unique**. + +**Note:** This question is the same as 865: [https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/) + +## Solution + +```kotlin +import com_github_leetcode.TreeNode + +/* + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun lcaDeepestLeaves(root: TreeNode?): TreeNode? { + if (root == null) { + return null + } + val leftDep = getDep(root.left) + val rightDep = getDep(root.right) + return if (leftDep == rightDep) { + root + } else { + if (leftDep > rightDep) { + lcaDeepestLeaves(root.left) + } else { + lcaDeepestLeaves(root.right) + } + } + } + + fun getDep(root: TreeNode?): Int { + return if (root == null) { + 0 + } else 1 + Math.max(getDep(root.left), getDep(root.right)) + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1124_longest_well_performing_interval/readme.md b/src/main/kotlin/g1101_1200/s1124_longest_well_performing_interval/readme.md new file mode 100644 index 00000000..5a3f78bf --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1124_longest_well_performing_interval/readme.md @@ -0,0 +1,63 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1124\. Longest Well-Performing Interval + +Medium + +We are given `hours`, a list of the number of hours worked per day for a given employee. + +A day is considered to be a _tiring day_ if and only if the number of hours worked is (strictly) greater than `8`. + +A _well-performing interval_ is an interval of days for which the number of tiring days is strictly larger than the number of non-tiring days. + +Return the length of the longest well-performing interval. + +**Example 1:** + +**Input:** hours = [9,9,6,0,6,6,9] + +**Output:** 3 + +**Explanation:** The longest well-performing interval is [9,9,6]. + +**Example 2:** + +**Input:** hours = [6,6,6] + +**Output:** 0 + +**Constraints:** + +* 1 <= hours.length <= 104 +* `0 <= hours[i] <= 16` + +## Solution + +```kotlin +class Solution { + fun longestWPI(hours: IntArray): Int { + var i = 0 + val map = HashMap() + var sum = 0 + map[sum] = -1 + var max = Int.MIN_VALUE + for (`val` in hours) { + sum += if (`val` > 8) 1 else -1 + if (!map.containsKey(sum)) { + map[sum] = i + } + if (sum > 0) { + max = i + 1 + } else if (map.containsKey(sum - 1)) { + max = Math.max(i - map[sum - 1]!!, max) + } + i++ + } + if (max == Int.MIN_VALUE) { + max = 0 + } + return max + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1125_smallest_sufficient_team/readme.md b/src/main/kotlin/g1101_1200/s1125_smallest_sufficient_team/readme.md new file mode 100644 index 00000000..96cac728 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1125_smallest_sufficient_team/readme.md @@ -0,0 +1,110 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1125\. Smallest Sufficient Team + +Hard + +In a project, you have a list of required skills `req_skills`, and a list of people. The ith person `people[i]` contains a list of skills that the person has. + +Consider a sufficient team: a set of people such that for every required skill in `req_skills`, there is at least one person in the team who has that skill. We can represent these teams by the index of each person. + +* For example, `team = [0, 1, 3]` represents the people with skills `people[0]`, `people[1]`, and `people[3]`. + +Return _any sufficient team of the smallest possible size, represented by the index of each person_. You may return the answer in **any order**. + +It is **guaranteed** an answer exists. + +**Example 1:** + +**Input:** req\_skills = ["java","nodejs","reactjs"], people = \[\["java"],["nodejs"],["nodejs","reactjs"]] + +**Output:** [0,2] + +**Example 2:** + +**Input:** req\_skills = ["algorithms","math","java","reactjs","csharp","aws"], people = \[\["algorithms","math","java"],["algorithms","math","reactjs"],["java","csharp","aws"],["reactjs","csharp"],["csharp","math"],["aws","java"]] + +**Output:** [1,2] + +**Constraints:** + +* `1 <= req_skills.length <= 16` +* `1 <= req_skills[i].length <= 16` +* `req_skills[i]` consists of lowercase English letters. +* All the strings of `req_skills` are **unique**. +* `1 <= people.length <= 60` +* `0 <= people[i].length <= 16` +* `1 <= people[i][j].length <= 16` +* `people[i][j]` consists of lowercase English letters. +* All the strings of `people[i]` are **unique**. +* Every skill in `people[i]` is a skill in `req_skills`. +* It is guaranteed a sufficient team exists. + +## Solution + +```kotlin +class Solution { + private var ans: List = ArrayList() + fun smallestSufficientTeam(skills: Array, people: List>): IntArray { + val n = skills.size + val m = people.size + val map: MutableMap = HashMap() + for (i in 0 until n) { + map[skills[i]] = i + } + val arr = IntArray(m) + for (i in 0 until m) { + val list = people[i] + var `val` = 0 + for (skill in list) { + `val` = `val` or (1 shl map[skill]!!) + } + arr[i] = `val` + } + val banned = BooleanArray(m) + for (i in 0 until m) { + for (j in i + 1 until m) { + val `val` = arr[i] or arr[j] + if (`val` == arr[i]) { + banned[j] = true + } else if (`val` == arr[j]) { + banned[i] = true + } + } + } + helper(0, n, arr, mutableListOf(), banned) + val res = IntArray(ans.size) + for (i in res.indices) { + res[i] = ans[i] + } + return res + } + + private fun helper(cur: Int, n: Int, arr: IntArray, list: MutableList, banned: BooleanArray) { + if (cur == (1 shl n) - 1) { + if (ans.isEmpty() || ans.size > list.size) { + ans = ArrayList(list) + } + return + } + if (ans.isNotEmpty() && list.size >= ans.size) { + return + } + var zero = 0 + while (cur shr zero and 1 == 1) { + zero++ + } + for (i in arr.indices) { + if (banned[i]) { + continue + } + if (arr[i] shr zero and 1 == 1) { + list.add(i) + helper(cur or arr[i], n, arr, list, banned) + list.removeAt(list.size - 1) + } + } + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1128_number_of_equivalent_domino_pairs/readme.md b/src/main/kotlin/g1101_1200/s1128_number_of_equivalent_domino_pairs/readme.md new file mode 100644 index 00000000..053fd3ca --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1128_number_of_equivalent_domino_pairs/readme.md @@ -0,0 +1,47 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1128\. Number of Equivalent Domino Pairs + +Easy + +Given a list of `dominoes`, `dominoes[i] = [a, b]` is **equivalent to** `dominoes[j] = [c, d]` if and only if either (`a == c` and `b == d`), or (`a == d` and `b == c`) - that is, one domino can be rotated to be equal to another domino. + +Return _the number of pairs_ `(i, j)` _for which_ `0 <= i < j < dominoes.length`_, and_ `dominoes[i]` _is **equivalent to**_ `dominoes[j]`. + +**Example 1:** + +**Input:** dominoes = \[\[1,2],[2,1],[3,4],[5,6]] + +**Output:** 1 + +**Example 2:** + +**Input:** dominoes = \[\[1,2],[1,2],[1,1],[1,2],[2,2]] + +**Output:** 3 + +**Constraints:** + +* 1 <= dominoes.length <= 4 * 104 +* `dominoes[i].length == 2` +* `1 <= dominoes[i][j] <= 9` + +## Solution + +```kotlin +class Solution { + fun numEquivDominoPairs(dominoes: Array): Int { + val map: MutableMap = HashMap() + var count = 0 + for (dominoe in dominoes) { + val smaller = Math.min(dominoe[0], dominoe[1]) + val bigger = Math.max(dominoe[0], dominoe[1]) + val key = smaller * 10 + bigger + count += map.getOrDefault(key, 0) + map[key] = map.getOrDefault(key, 0) + 1 + } + return count + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1129_shortest_path_with_alternating_colors/readme.md b/src/main/kotlin/g1101_1200/s1129_shortest_path_with_alternating_colors/readme.md new file mode 100644 index 00000000..7fe0bc05 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1129_shortest_path_with_alternating_colors/readme.md @@ -0,0 +1,112 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1129\. Shortest Path with Alternating Colors + +Medium + +You are given an integer `n`, the number of nodes in a directed graph where the nodes are labeled from `0` to `n - 1`. Each edge is red or blue in this graph, and there could be self-edges and parallel edges. + +You are given two arrays `redEdges` and `blueEdges` where: + +* redEdges[i] = [ai, bi] indicates that there is a directed red edge from node ai to node bi in the graph, and +* blueEdges[j] = [uj, vj] indicates that there is a directed blue edge from node uj to node vj in the graph. + +Return an array `answer` of length `n`, where each `answer[x]` is the length of the shortest path from node `0` to node `x` such that the edge colors alternate along the path, or `-1` if such a path does not exist. + +**Example 1:** + +**Input:** n = 3, redEdges = \[\[0,1],[1,2]], blueEdges = [] + +**Output:** [0,1,-1] + +**Example 2:** + +**Input:** n = 3, redEdges = \[\[0,1]], blueEdges = \[\[2,1]] + +**Output:** [0,1,-1] + +**Constraints:** + +* `1 <= n <= 100` +* `0 <= redEdges.length, blueEdges.length <= 400` +* `redEdges[i].length == blueEdges[j].length == 2` +* 0 <= ai, bi, uj, vj < n + +## Solution + +```kotlin +import java.util.LinkedList +import java.util.Queue + +@Suppress("NAME_SHADOWING") +class Solution { + private class Pair(var node: Int, var color: Int) + + private fun bfs( + q: Queue, + vis: Array, + graph: List>, + blue: Boolean, + shortestPaths: IntArray + ) { + var blue = blue + var level = 0 + q.add(0) + if (blue) { + vis[0][1] = true + } else { + vis[0][0] = true + } + while (q.isNotEmpty()) { + var size = q.size + while (size-- > 0) { + val curr = q.poll() + shortestPaths[curr] = Math.min(level, shortestPaths[curr]) + for (nextNode in graph[curr]) { + if (nextNode.color == 1 && blue && !vis[nextNode.node][1]) { + q.add(nextNode.node) + vis[nextNode.node][1] = true + } + if (!blue && nextNode.color == 0 && !vis[nextNode.node][0]) { + q.add(nextNode.node) + vis[nextNode.node][0] = true + } + } + } + blue = !blue + level++ + } + } + + fun shortestAlternatingPaths(n: Int, redEdges: Array, blueEdges: Array): IntArray { + val graph: MutableList> = ArrayList() + for (i in 0 until n) { + graph.add(mutableListOf()) + } + for (edge in redEdges) { + val a = edge[0] + val b = edge[1] + // red -> 0 + graph[a].add(Pair(b, 0)) + } + for (edge in blueEdges) { + val u = edge[0] + val v = edge[1] + // blue -> 1 + graph[u].add(Pair(v, 1)) + } + val shortestPaths = IntArray(n) + val q: Queue = LinkedList() + shortestPaths.fill(Int.MAX_VALUE) + bfs(q, Array(n) { BooleanArray(2) }, graph, true, shortestPaths) + bfs(q, Array(n) { BooleanArray(2) }, graph, false, shortestPaths) + for (i in 0 until n) { + if (shortestPaths[i] == Int.MAX_VALUE) { + shortestPaths[i] = -1 + } + } + return shortestPaths + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1130_minimum_cost_tree_from_leaf_values/readme.md b/src/main/kotlin/g1101_1200/s1130_minimum_cost_tree_from_leaf_values/readme.md new file mode 100644 index 00000000..f7aa4866 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1130_minimum_cost_tree_from_leaf_values/readme.md @@ -0,0 +1,79 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1130\. Minimum Cost Tree From Leaf Values + +Medium + +Given an array `arr` of positive integers, consider all binary trees such that: + +* Each node has either `0` or `2` children; +* The values of `arr` correspond to the values of each **leaf** in an in-order traversal of the tree. +* The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree, respectively. + +Among all possible binary trees considered, return _the smallest possible sum of the values of each non-leaf node_. It is guaranteed this sum fits into a **32-bit** integer. + +A node is a **leaf** if and only if it has zero children. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2021/08/10/tree1.jpg) + +**Input:** arr = [6,2,4] + +**Output:** 32 + +**Explanation:** There are two possible trees shown. The first has a non-leaf node sum 36, and the second has non-leaf node sum 32. + +**Example 2:** + +![](https://assets.leetcode.com/uploads/2021/08/10/tree2.jpg) + +**Input:** arr = [4,11] + +**Output:** 44 + +**Constraints:** + +* `2 <= arr.length <= 40` +* `1 <= arr[i] <= 15` +* It is guaranteed that the answer fits into a **32-bit** signed integer (i.e., it is less than 231). + +## Solution + +```kotlin +import java.util.ArrayDeque +import java.util.Deque + +class Solution { + fun mctFromLeafValues(arr: IntArray): Int { + var res = 0 + val st: Deque = ArrayDeque() + st.push(Int.MAX_VALUE) + for (num in arr) { + // do until the present num is bigger than nums in stack (we need to maintain the + // increasing order in stack (bottom to up)) + while (st.peek() <= num) { + // find two smallest leafs (integer on top of stack is smallest and at bottom is + // largest UPTIL NOW) + // the next smaller leaf could either be present num or the + val smallestLeaf = st.pop() + val smallerLeaf = Math.min(st.peek(), num) + // num on top of stack after above pop() + // multiply minimum leafs to reduce the SUM + res += smallestLeaf * smallerLeaf + } + st.push(num) + } + // if the size is 2 or less we do not to worry because we have already used it in above step + // since 1st num we added was Integer.MAX, and we do not need to use that, so just do this + // step if the size > 2 (basically there are at least 2 elements from the array) + while (st.size > 2) { + val smallestLeaf = st.pop() + val smallerLeaf = st.peek() + res += smallestLeaf * smallerLeaf + } + return res + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1131_maximum_of_absolute_value_expression/readme.md b/src/main/kotlin/g1101_1200/s1131_maximum_of_absolute_value_expression/readme.md new file mode 100644 index 00000000..b7bdd620 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1131_maximum_of_absolute_value_expression/readme.md @@ -0,0 +1,60 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1131\. Maximum of Absolute Value Expression + +Medium + +Given two arrays of integers with equal lengths, return the maximum value of: + +`|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|` + +where the maximum is taken over all `0 <= i, j < arr1.length`. + +**Example 1:** + +**Input:** arr1 = [1,2,3,4], arr2 = [-1,4,5,6] + +**Output:** 13 + +**Example 2:** + +**Input:** arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4] + +**Output:** 20 + +**Constraints:** + +* `2 <= arr1.length == arr2.length <= 40000` +* `-10^6 <= arr1[i], arr2[i] <= 10^6` + +## Solution + +```kotlin +class Solution { + fun maxAbsValExpr(arr1: IntArray, arr2: IntArray): Int { + if (arr1.size != arr2.size) { + return 0 + } + var max1 = Int.MIN_VALUE + var max2 = Int.MIN_VALUE + var max3 = Int.MIN_VALUE + var max4 = Int.MIN_VALUE + var min1 = Int.MAX_VALUE + var min2 = Int.MAX_VALUE + var min3 = Int.MAX_VALUE + var min4 = Int.MAX_VALUE + for (i in arr1.indices) { + max1 = Math.max(arr1[i] + arr2[i] + i, max1) + min1 = Math.min(arr1[i] + arr2[i] + i, min1) + max2 = Math.max(i - arr1[i] - arr2[i], max2) + min2 = Math.min(i - arr1[i] - arr2[i], min2) + max3 = Math.max(arr1[i] - arr2[i] + i, max3) + min3 = Math.min(arr1[i] - arr2[i] + i, min3) + max4 = Math.max(arr2[i] - arr1[i] + i, max4) + min4 = Math.min(arr2[i] - arr1[i] + i, min4) + } + return Math.max(Math.max(max1 - min1, max2 - min2), Math.max(max3 - min3, max4 - min4)) + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1137_n_th_tribonacci_number/readme.md b/src/main/kotlin/g1101_1200/s1137_n_th_tribonacci_number/readme.md new file mode 100644 index 00000000..ce3dbcfe --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1137_n_th_tribonacci_number/readme.md @@ -0,0 +1,57 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1137\. N-th Tribonacci Number + +Easy + +The Tribonacci sequence Tn is defined as follows: + +T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. + +Given `n`, return the value of Tn. + +**Example 1:** + +**Input:** n = 4 + +**Output:** 4 + +**Explanation:** T\_3 = 0 + 1 + 1 = 2 T\_4 = 1 + 1 + 2 = 4 + +**Example 2:** + +**Input:** n = 25 + +**Output:** 1389537 + +**Constraints:** + +* `0 <= n <= 37` +* The answer is guaranteed to fit within a 32-bit integer, ie. `answer <= 2^31 - 1`. + +## Solution + +```kotlin +class Solution { + fun tribonacci(n: Int): Int { + return if (n == 0) { + 0 + } else if (n <= 2) { + 1 + } else { + var tn = 0 + var tn1 = 1 + var tn2 = 1 + var tmp = 0 + for (i in 3..n) { + tmp = tn + tn1 + tn2 + tn = tn1 + tn1 = tn2 + tn2 = tmp + } + tmp + } + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1138_alphabet_board_path/readme.md b/src/main/kotlin/g1101_1200/s1138_alphabet_board_path/readme.md new file mode 100644 index 00000000..a08c5256 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1138_alphabet_board_path/readme.md @@ -0,0 +1,85 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1138\. Alphabet Board Path + +Medium + +On an alphabet board, we start at position `(0, 0)`, corresponding to character `board[0][0]`. + +Here, `board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"]`, as shown in the diagram below. + +![](https://assets.leetcode.com/uploads/2019/07/28/azboard.png) + +We may make the following moves: + +* `'U'` moves our position up one row, if the position exists on the board; +* `'D'` moves our position down one row, if the position exists on the board; +* `'L'` moves our position left one column, if the position exists on the board; +* `'R'` moves our position right one column, if the position exists on the board; +* `'!'` adds the character `board[r][c]` at our current position `(r, c)` to the answer. + +(Here, the only positions that exist on the board are positions with letters on them.) + +Return a sequence of moves that makes our answer equal to `target` in the minimum number of moves. You may return any path that does so. + +**Example 1:** + +**Input:** target = "leet" + +**Output:** "DDR!UURRR!!DDD!" + +**Example 2:** + +**Input:** target = "code" + +**Output:** "RR!DDRR!UUL!R!" + +**Constraints:** + +* `1 <= target.length <= 100` +* `target` consists only of English lowercase letters. + +## Solution + +```kotlin +class Solution { + fun alphabetBoardPath(target: String): String { + if (target.isEmpty()) { + return "" + } + var sourceRow = 0 + var sourceCol = 0 + val path = StringBuilder() + for (c in target.toCharArray()) { + val position = c.code - 97 + val targetRow = position / 5 + val targetCol = position % 5 + if (targetCol < sourceCol) { + path.append(helper("L", sourceCol - targetCol)) + } + if (targetRow < sourceRow) { + path.append(helper("U", sourceRow - targetRow)) + } + if (targetRow > sourceRow) { + path.append(helper("D", targetRow - sourceRow)) + } + if (targetCol > sourceCol) { + path.append(helper("R", targetCol - sourceCol)) + } + path.append("!") + sourceRow = targetRow + sourceCol = targetCol + } + return path.toString() + } + + fun helper(dir: String?, time: Int): StringBuilder { + val path = StringBuilder() + for (i in 0 until time) { + path.append(dir) + } + return path + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1139_largest_1_bordered_square/readme.md b/src/main/kotlin/g1101_1200/s1139_largest_1_bordered_square/readme.md new file mode 100644 index 00000000..735c8768 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1139_largest_1_bordered_square/readme.md @@ -0,0 +1,74 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1139\. Largest 1-Bordered Square + +Medium + +Given a 2D `grid` of `0`s and `1`s, return the number of elements in the largest **square** subgrid that has all `1`s on its **border**, or `0` if such a subgrid doesn't exist in the `grid`. + +**Example 1:** + +**Input:** grid = \[\[1,1,1],[1,0,1],[1,1,1]] + +**Output:** 9 + +**Example 2:** + +**Input:** grid = \[\[1,1,0,0]] + +**Output:** 1 + +**Constraints:** + +* `1 <= grid.length <= 100` +* `1 <= grid[0].length <= 100` +* `grid[i][j]` is `0` or `1` + +## Solution + +```kotlin +class Solution { + fun largest1BorderedSquare(grid: Array): Int { + val rightToLeft = arrayOfNulls(grid.size) + val bottomToUp = arrayOfNulls(grid.size) + for (i in grid.indices) { + rightToLeft[i] = grid[i].clone() + bottomToUp[i] = grid[i].clone() + } + val row = grid.size + val col = grid[0].size + for (i in 0 until row) { + for (j in col - 2 downTo 0) { + if (grid[i][j] == 1) { + rightToLeft[i]!![j] = rightToLeft[i]!![j + 1] + 1 + } + } + } + for (j in 0 until col) { + for (i in row - 2 downTo 0) { + if (grid[i][j] == 1) { + bottomToUp[i]!![j] = bottomToUp[i + 1]!![j] + 1 + } + } + } + var res = 0 + for (i in 0 until row) { + for (j in 0 until col) { + val curLen = rightToLeft[i]!![j] + for (k in curLen downTo 1) { + if (bottomToUp[i]!![j] >= k && rightToLeft[i + k - 1]!![j] >= k && + bottomToUp[i]!![j + k - 1] >= k + ) { + if (k > res) { + res = k + } + break + } + } + } + } + return res * res + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1140_stone_game_ii/readme.md b/src/main/kotlin/g1101_1200/s1140_stone_game_ii/readme.md new file mode 100644 index 00000000..940a3827 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1140_stone_game_ii/readme.md @@ -0,0 +1,73 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1140\. Stone Game II + +Medium + +Alice and Bob continue their games with piles of stones. There are a number of piles **arranged in a row**, and each pile has a positive integer number of stones `piles[i]`. The objective of the game is to end with the most stones. + +Alice and Bob take turns, with Alice starting first. Initially, `M = 1`. + +On each player's turn, that player can take **all the stones** in the **first** `X` remaining piles, where `1 <= X <= 2M`. Then, we set `M = max(M, X)`. + +The game continues until all the stones have been taken. + +Assuming Alice and Bob play optimally, return the maximum number of stones Alice can get. + +**Example 1:** + +**Input:** piles = [2,7,9,4,4] + +**Output:** 10 + +**Explanation:** If Alice takes one pile at the beginning, Bob takes two piles, then Alice takes 2 piles again. Alice can get 2 + 4 + 4 = 10 piles in total. If Alice takes two piles at the beginning, then Bob can take all three piles left. In this case, Alice get 2 + 7 = 9 piles in total. So we return 10 since it's larger. + +**Example 2:** + +**Input:** piles = [1,2,3,4,5,100] + +**Output:** 104 + +**Constraints:** + +* `1 <= piles.length <= 100` +* 1 <= piles[i] <= 104 + +## Solution + +```kotlin +class Solution { + private val dp = Array(105) { IntArray(105) } + private fun help(i: Int, m: Int, p: IntArray): Int { + if (i >= p.size) { + dp[i][m] = 0 + return 0 + } + if (dp[i][m] != -1) { + return dp[i][m] + } + var ans = Int.MIN_VALUE + var total = 0 + for (j in 0 until 2 * m) { + if (i + j < p.size) { + total += p[i + j] + ans = Math.max(ans, total - help(i + j + 1, Math.max(m, j + 1), p)) + } + } + dp[i][m] = ans + return ans + } + + fun stoneGameII(piles: IntArray): Int { + var sum = 0 + for (arr1 in dp) { + arr1.fill(-1) + } + for (z in piles) { + sum += z + } + return (sum + help(0, 1, piles)) / 2 + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1141_user_activity_for_the_past_30_days_i/readme.md b/src/main/kotlin/g1101_1200/s1141_user_activity_for_the_past_30_days_i/readme.md new file mode 100644 index 00000000..b2b5afe7 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1141_user_activity_for_the_past_30_days_i/readme.md @@ -0,0 +1,71 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1141\. User Activity for the Past 30 Days I + +Easy + +SQL Schema + +Table: `Activity` + + +---------------+---------+ + | Column Name | Type | + +---------------+---------+ + | user_id | int | + | session_id | int | + | activity_date | date | + | activity_type | enum | + +---------------+---------+ + There is no primary key for this table, it may have duplicate rows. + The activity_type column is an ENUM of type ('open_session', 'end_session', 'scroll_down', 'send_message'). + The table shows the user activities for a social media website. + Note that each session belongs to exactly one user. + +Write an SQL query to find the daily active user count for a period of `30` days ending `2019-07-27` inclusively. A user was active on someday if they made at least one activity on that day. + +Return the result table in **any order**. + +The query result format is in the following example. + +**Example 1:** + +**Input:** + + Activity table: + +---------+------------+---------------+---------------+ + | user_id | session_id | activity_date | activity_type | + +---------+------------+---------------+---------------+ + | 1 | 1 | 2019-07-20 | open_session | + | 1 | 1 | 2019-07-20 | scroll_down | + | 1 | 1 | 2019-07-20 | end_session | + | 2 | 4 | 2019-07-20 | open_session | + | 2 | 4 | 2019-07-21 | send_message | + | 2 | 4 | 2019-07-21 | end_session | + | 3 | 2 | 2019-07-21 | open_session | + | 3 | 2 | 2019-07-21 | send_message | + | 3 | 2 | 2019-07-21 | end_session | + | 4 | 3 | 2019-06-25 | open_session | + | 4 | 3 | 2019-06-25 | end_session | + +---------+------------+---------------+---------------+ + +**Output:** + + +------------+--------------+ + | day | active_users | + +------------+--------------+ + | 2019-07-20 | 2 | + | 2019-07-21 | 2 | + +------------+--------------+ + +**Explanation:** Note that we do not care about days with zero active users. + +## Solution + +```sql +# Write your MySQL query statement below +SELECT activity_date as "day", COUNT(DISTINCT user_id) AS active_users +FROM activity +WHERE (activity_date > '2019-06-27' AND activity_date <= '2019-07-27') +GROUP BY activity_date; +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1144_decrease_elements_to_make_array_zigzag/readme.md b/src/main/kotlin/g1101_1200/s1144_decrease_elements_to_make_array_zigzag/readme.md new file mode 100644 index 00000000..cc079a48 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1144_decrease_elements_to_make_array_zigzag/readme.md @@ -0,0 +1,92 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1144\. Decrease Elements To Make Array Zigzag + +Medium + +Given an array `nums` of integers, a _move_ consists of choosing any element and **decreasing it by 1**. + +An array `A` is a _zigzag array_ if either: + +* Every even-indexed element is greater than adjacent elements, ie. `A[0] > A[1] < A[2] > A[3] < A[4] > ...` +* OR, every odd-indexed element is greater than adjacent elements, ie. `A[0] < A[1] > A[2] < A[3] > A[4] < ...` + +Return the minimum number of moves to transform the given array `nums` into a zigzag array. + +**Example 1:** + +**Input:** nums = [1,2,3] + +**Output:** 2 + +**Explanation:** We can decrease 2 to 0 or 3 to 1. + +**Example 2:** + +**Input:** nums = [9,6,1,6,2] + +**Output:** 4 + +**Constraints:** + +* `1 <= nums.length <= 1000` +* `1 <= nums[i] <= 1000` + +## Solution + +```kotlin +@Suppress("NAME_SHADOWING") +class Solution { + fun movesToMakeZigzag(nums: IntArray): Int { + var nums = nums + var ans: Int + val n = nums.size + var cur = 0 + if (n == 1) { + return 0 + } + val clone = nums.clone() + run { + var i = 0 + while (i < n) { + if (i == 0) { + if (nums[i] <= nums[i + 1]) { + cur += nums[i + 1] - nums[i] + 1 + nums[i + 1] = nums[i] - 1 + } + } else if (i == n - 1) { + if (nums[i] <= nums[i - 1]) { + cur += nums[i - 1] - nums[i] + 1 + } + } else { + if (nums[i] <= nums[i + 1]) { + cur += nums[i + 1] - nums[i] + 1 + nums[i + 1] = nums[i] - 1 + } + if (nums[i] <= nums[i - 1]) { + cur += nums[i - 1] - nums[i] + 1 + } + } + i += 2 + } + } + ans = cur + cur = 0 + nums = clone + var i = 1 + while (i < n) { + if (i != n - 1 && nums[i] <= nums[i + 1]) { + cur += nums[i + 1] - nums[i] + 1 + nums[i + 1] = nums[i] - 1 + } + if (nums[i] <= nums[i - 1]) { + cur += nums[i - 1] - nums[i] + 1 + } + i += 2 + } + ans = Math.min(ans, cur) + return ans + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1145_binary_tree_coloring_game/readme.md b/src/main/kotlin/g1101_1200/s1145_binary_tree_coloring_game/readme.md new file mode 100644 index 00000000..97c554c4 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1145_binary_tree_coloring_game/readme.md @@ -0,0 +1,77 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1145\. Binary Tree Coloring Game + +Medium + +Two players play a turn based game on a binary tree. We are given the `root` of this binary tree, and the number of nodes `n` in the tree. `n` is odd, and each node has a distinct value from `1` to `n`. + +Initially, the first player names a value `x` with `1 <= x <= n`, and the second player names a value `y` with `1 <= y <= n` and `y != x`. The first player colors the node with value `x` red, and the second player colors the node with value `y` blue. + +Then, the players take turns starting with the first player. In each turn, that player chooses a node of their color (red if player 1, blue if player 2) and colors an **uncolored** neighbor of the chosen node (either the left child, right child, or parent of the chosen node.) + +If (and only if) a player cannot choose such a node in this way, they must pass their turn. If both players pass their turn, the game ends, and the winner is the player that colored more nodes. + +You are the second player. If it is possible to choose such a `y` to ensure you win the game, return `true`. If it is not possible, return `false`. + +**Example 1:** + +![](https://assets.leetcode.com/uploads/2019/08/01/1480-binary-tree-coloring-game.png) + +**Input:** root = [1,2,3,4,5,6,7,8,9,10,11], n = 11, x = 3 + +**Output:** true + +**Explanation:** The second player can choose the node with value 2. + +**Example 2:** + +**Input:** root = [1,2,3], n = 3, x = 1 + +**Output:** false + +**Constraints:** + +* The number of nodes in the tree is `n`. +* `1 <= x <= n <= 100` +* `n` is odd. +* 1 <= Node.val <= n +* All the values of the tree are **unique**. + +## Solution + +```kotlin +import com_github_leetcode.TreeNode + +/* + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun btreeGameWinningMove(root: TreeNode?, n: Int, x: Int): Boolean { + if (root == null) { + return false + } + if (root.`val` == x) { + val leftCount = countNodes(root.left) + val rightCount = countNodes(root.right) + val parent = n - (leftCount + rightCount + 1) + return parent > leftCount + rightCount || leftCount > parent + rightCount || rightCount > parent + leftCount + } + return btreeGameWinningMove(root.left, n, x) || btreeGameWinningMove(root.right, n, x) + } + + private fun countNodes(root: TreeNode?): Int { + return if (root == null) { + 0 + } else countNodes(root.left) + countNodes(root.right) + 1 + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1146_snapshot_array/readme.md b/src/main/kotlin/g1101_1200/s1146_snapshot_array/readme.md new file mode 100644 index 00000000..5c80b2c6 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1146_snapshot_array/readme.md @@ -0,0 +1,80 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1146\. Snapshot Array + +Medium + +Implement a SnapshotArray that supports the following interface: + +* `SnapshotArray(int length)` initializes an array-like data structure with the given length. **Initially, each element equals 0**. +* `void set(index, val)` sets the element at the given `index` to be equal to `val`. +* `int snap()` takes a snapshot of the array and returns the `snap_id`: the total number of times we called `snap()` minus `1`. +* `int get(index, snap_id)` returns the value at the given `index`, at the time we took the snapshot with the given `snap_id` + +**Example 1:** + +**Input:** ["SnapshotArray","set","snap","set","get"] [[3],[0,5],[],[0,6],[0,0]] + +**Output:** [null,null,0,null,5] + +**Explanation:** + +SnapshotArray snapshotArr = new SnapshotArray(3); // set the length to be 3 +snapshotArr.set(0,5); // Set array[0] = 5 +snapshotArr.snap(); // Take a snapshot, return snap_id = 0 +snapshotArr.set(0,6); +snapshotArr.get(0,0); // Get the value of array[0] with snap_id = 0, return 5 + +**Constraints:** + +* `1 <= length <= 50000` +* At most `50000` calls will be made to `set`, `snap`, and `get`. +* `0 <= index < length` +* `0 <= snap_id < `(the total number of times we call `snap()`) +* `0 <= val <= 10^9` + +## Solution + +```kotlin +import java.util.TreeMap + +class SnapshotArray(length: Int) { + private var snapId = -1 + private val indexToSnapMap: MutableMap> + private val ar: IntArray + + init { + indexToSnapMap = HashMap() + ar = IntArray(length) + } + + operator fun set(index: Int, `val`: Int) { + if (indexToSnapMap.containsKey(index)) { + if (!indexToSnapMap[index]!!.containsKey(snapId)) { + indexToSnapMap[index]!![snapId] = ar[index] + } + } else { + val snapToValueMap = TreeMap() + snapToValueMap[snapId] = ar[index] + indexToSnapMap[index] = snapToValueMap + } + ar[index] = `val` + } + + fun snap(): Int { + snapId++ + return snapId + } + + operator fun get(index: Int, snapId: Int): Int { + if (indexToSnapMap.containsKey(index)) { + val value = indexToSnapMap[index]!!.ceilingEntry(snapId) + if (value != null) { + return value.value + } + } + return ar[index] + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1147_longest_chunked_palindrome_decomposition/readme.md b/src/main/kotlin/g1101_1200/s1147_longest_chunked_palindrome_decomposition/readme.md new file mode 100644 index 00000000..850c647e --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1147_longest_chunked_palindrome_decomposition/readme.md @@ -0,0 +1,80 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1147\. Longest Chunked Palindrome Decomposition + +Hard + +You are given a string `text`. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that: + +* subtexti is a **non-empty** string. +* The concatenation of all the substrings is equal to `text` (i.e., subtext1 + subtext2 + ... + subtextk == text). +* subtexti == subtextk - i + 1 for all valid values of `i` (i.e., `1 <= i <= k`). + +Return the largest possible value of `k`. + +**Example 1:** + +**Input:** text = "ghiabcdefhelloadamhelloabcdefghi" + +**Output:** 7 + +**Explanation:** We can split the string on "(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)". + +**Example 2:** + +**Input:** text = "merchant" + +**Output:** 1 + +**Explanation:** We can split the string on "(merchant)". + +**Example 3:** + +**Input:** text = "antaprezatepzapreanta" + +**Output:** 11 + +**Explanation:** We can split the string on "(a)(nt)(a)(pre)(za)(tpe)(za)(pre)(a)(nt)(a)". + +**Constraints:** + +* `1 <= text.length <= 1000` +* `text` consists only of lowercase English characters. + +## Solution + +```kotlin +class Solution { + fun longestDecomposition(text: String): Int { + val n = text.length + var l = 0 + var r = n - 1 + var len = 1 + var ans = 0 + var lft: String + var rit: String + var perfectSubstring = false + while (l + len <= r - len + 1) { + lft = text.substring(l, l + len) + rit = text.substring(r - len + 1, r + 1) + if (lft == rit) { + ans += 2 + if (l + len == r - len + 1) { + perfectSubstring = true + break + } + l = l + len + r = r - len + len = 1 + } else { + len++ + } + } + if (!perfectSubstring) { + ans++ + } + return ans + } +} +``` \ No newline at end of file diff --git a/src/main/kotlin/g1101_1200/s1148_article_views_i/readme.md b/src/main/kotlin/g1101_1200/s1148_article_views_i/readme.md new file mode 100644 index 00000000..016fe951 --- /dev/null +++ b/src/main/kotlin/g1101_1200/s1148_article_views_i/readme.md @@ -0,0 +1,61 @@ +[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin) +[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork) + +## 1148\. Article Views I + +Easy + +SQL Schema + +Table: `Views` + + +---------------+---------+ + | Column Name | Type | + +---------------+---------+ + | article_id | int | + | author_id | int | + | viewer_id | int | + | view_date | date | + +---------------+---------+ + There is no primary key for this table, it may have duplicate rows. + Each row of this table indicates that some viewer viewed an article (written by some author) on some date. + Note that equal author_id and viewer_id indicate the same person. + +Write an SQL query to find all the authors that viewed at least one of their own articles. + +Return the result table sorted by `id` in ascending order. + +The query result format is in the following example. + +**Example 1:** + +**Input:** + + Views table: + +------------+-----------+-----------+------------+ + | article_id | author_id | viewer_id | view_date | + +------------+-----------+-----------+------------+ + | 1 | 3 | 5 | 2019-08-01 | + | 1 | 3 | 6 | 2019-08-02 | + | 2 | 7 | 7 | 2019-08-01 | + | 2 | 7 | 6 | 2019-08-02 | + | 4 | 7 | 1 | 2019-07-22 | + | 3 | 4 | 4 | 2019-07-21 | + | 3 | 4 | 4 | 2019-07-21 | + +------------+-----------+-----------+------------+ + +**Output:** + + +------+ + | id | + +------+ + | 4 | + | 7 | + +------+ + +## Solution + +```sql +# Write your MySQL query statement below +select distinct author_id as id from Views where author_id = viewer_id order by author_id; +``` \ No newline at end of file