diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b6c3379e9..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/configuration-reference -version: 2.1 - -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/configuration-reference/#jobs -jobs: - build-linux: - # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/configuration-reference/#executor-job - docker: - - image: cimg/openjdk:17.0.16 - # Add steps to the job - # See: https://circleci.com/docs/configuration-reference/#steps - steps: - - checkout - - run: - name: "Build gradle" - command: chmod +x gradlew && ./gradlew clean build - -# Orchestrate jobs using workflows -# See: https://circleci.com/docs/configuration-reference/#workflows -workflows: - say-hello-workflow: - jobs: - - build-linux diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3aa979cf9..cfda197e8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -59,11 +59,11 @@ jobs: # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} @@ -91,6 +91,6 @@ jobs: exit 1 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@v4 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a27e8cc36..bcdebc243 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,17 +17,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'corretto' java-version: '17' cache: 'gradle' - name: Cache SonarCloud packages - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar @@ -44,11 +44,11 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'corretto' java-version: '17' @@ -62,11 +62,11 @@ jobs: runs-on: macOS-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'corretto' java-version: '17' @@ -78,11 +78,11 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'corretto' java-version: '17' diff --git a/README.md b/README.md index e67e978c8..9fe99c3db 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,6 @@ implementation 'com.github.javadev:leetcode-in-java:1.49' > ["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) -* [Top Interview 150](#top-interview-150) -* [Data Structure I](#data-structure-i) -* [Data Structure II](#data-structure-ii) * [Algorithm I](#algorithm-i) * [Algorithm II](#algorithm-ii) * [Binary Search I](#binary-search-i) @@ -49,2068 +43,2074 @@ implementation 'com.github.javadev:leetcode-in-java:1.49' * [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) +* [Top Interview 150](#top-interview-150) +* [Data Structure I](#data-structure-i) +* [Data Structure II](#data-structure-ii) -### Level 1 +### Algorithm I -#### Day 1 Prefix Sum +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- -| 1480 |[Running Sum of 1d Array](src/main/java/g1401_1500/s1480_running_sum_of_1d_array/Solution.java)| Easy | Array, Prefix_Sum | 0 | 100.00 -| 0724 |[Find Pivot Index](src/main/java/g0701_0800/s0724_find_pivot_index/Solution.java)| Easy | Array, Prefix_Sum, LeetCode_75_Prefix_Sum | 2 | 69.67 +| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 +| 0278 |[First Bad Version](src/main/java/g0201_0300/s0278_first_bad_version/Solution.java)| Easy | Binary_Search, Interactive | 15 | 87.89 +| 0035 |[Search Insert Position](src/main/java/g0001_0100/s0035_search_insert_position/Solution.java)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -#### Day 2 String +#### Day 2 Two Pointers | | | | | | |-|-|-|-|-|- -| 0205 |[Isomorphic Strings](src/main/java/g0201_0300/s0205_isomorphic_strings/Solution.java)| Easy | String, Hash_Table | 2 | 99.18 -| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 +| 0977 |[Squares of a Sorted Array](src/main/java/g0901_1000/s0977_squares_of_a_sorted_array/Solution.java)| Easy | Array, Sorting, Two_Pointers | 1 | 100.00 +| 0189 |[Rotate Array](src/main/java/g0101_0200/s0189_rotate_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -#### Day 3 Linked List +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 -| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0283 |[Move Zeroes](src/main/java/g0201_0300/s0283_move_zeroes/Solution.java)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 83.99 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/java/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers | 2 | 92.62 -#### Day 4 Linked List +#### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 -| 0142 |[Linked List Cycle II](src/main/java/g0101_0200/s0142_linked_list_cycle_ii/Solution.java)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0344 |[Reverse String](src/main/java/g0301_0400/s0344_reverse_string/Solution.java)| Easy | String, Two_Pointers, Recursion | 1 | 99.91 +| 0557 |[Reverse Words in a String III](src/main/java/g0501_0600/s0557_reverse_words_in_a_string_iii/Solution.java)| Easy | String, Two_Pointers | 4 | 97.75 -#### Day 5 Greedy +#### Day 5 Two Pointers | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 -| 0409 |[Longest Palindrome](src/main/java/g0401_0500/s0409_longest_palindrome/Solution.java)| Easy | String, Hash_Table, Greedy | 2 | 92.90 +| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 +| 0019 |[Remove Nth Node From End of List](src/main/java/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 -#### Day 6 Tree +#### Day 6 Sliding Window | | | | | | |-|-|-|-|-|- -| 0589 |[N-ary Tree Preorder Traversal](src/main/java/g0501_0600/s0589_n_ary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Stack | 1 | 90.98 -| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 +| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 +| 0567 |[Permutation in String](src/main/java/g0501_0600/s0567_permutation_in_string/Solution.java)| Medium | String, Hash_Table, Two_Pointers, Sliding_Window | 5 | 93.93 -#### Day 7 Binary Search +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 -| 0278 |[First Bad Version](src/main/java/g0201_0300/s0278_first_bad_version/Solution.java)| Easy | Binary_Search, Interactive | 15 | 87.89 +| 0733 |[Flood Fill](src/main/java/g0701_0800/s0733_flood_fill/Solution.java)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 1 | 85.36 +| 0695 |[Max Area of Island](src/main/java/g0601_0700/s0695_max_area_of_island/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 3 | 76.79 -#### Day 8 Binary Search Tree +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/java/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 4 | 100.00 +| 0617 |[Merge Two Binary Trees](src/main/java/g0601_0700/s0617_merge_two_binary_trees/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 1 | 72.47 +| 0116 |[Populating Next Right Pointers in Each Node](src/main/java/g0101_0200/s0116_populating_next_right_pointers_in_each_node/Solution.java)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 0 | 100.00 -#### Day 9 Graph/BFS/DFS +#### Day 9 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0733 |[Flood Fill](src/main/java/g0701_0800/s0733_flood_fill/Solution.java)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 1 | 85.36 -| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 +| 0542 |[01 Matrix](src/main/java/g0501_0600/s0542_01_matrix/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 7 | 95.83 +| 0994 |[Rotting Oranges](src/main/java/g0901_1000/s0994_rotting_oranges/Solution.java)| Medium | Top_100_Liked_Questions, Array, Breadth_First_Search, Matrix, LeetCode_75_Graphs/BFS | 3 | 74.27 -#### Day 10 Dynamic Programming +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0509 |[Fibonacci Number](src/main/java/g0501_0600/s0509_fibonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 0 | 100.00 -| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -#### Day 11 Dynamic Programming +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0746 |[Min Cost Climbing Stairs](src/main/java/g0701_0800/s0746_min_cost_climbing_stairs/Solution.java)| Easy | Array, Dynamic_Programming, LeetCode_75_DP/1D | 1 | 86.38 -| 0062 |[Unique Paths](src/main/java/g0001_0100/s0062_unique_paths/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0077 |[Combinations](src/main/java/g0001_0100/s0077_combinations/Solution.java)| Medium | Backtracking | 15 | 92.38 +| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 +| 0784 |[Letter Case Permutation](src/main/java/g0701_0800/s0784_letter_case_permutation/Solution.java)| Medium | String, Bit_Manipulation, Backtracking | 10 | 40.38 -#### Day 12 Sliding Window/Two Pointer +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/java/g0401_0500/s0438_find_all_anagrams_in_a_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 3 | 99.83 -| 0424 |[Longest Repeating Character Replacement](src/main/java/g0401_0500/s0424_longest_repeating_character_replacement/Solution.java)| Medium | String, Hash_Table, Sliding_Window | 5 | 95.15 +| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 -#### Day 13 Hashmap +#### Day 13 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 -| 0299 |[Bulls and Cows](src/main/java/g0201_0300/s0299_bulls_and_cows/Solution.java)| Medium | String, Hash_Table, Counting | 6 | 86.69 +| 0231 |[Power of Two](src/main/java/g0201_0300/s0231_power_of_two/Solution.java)| Easy | Math, Bit_Manipulation, Recursion | 1 | 100.00 +| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 -#### Day 14 Stack +#### Day 14 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0844 |[Backspace String Compare](src/main/java/g0801_0900/s0844_backspace_string_compare/Solution.java)| Easy | String, Two_Pointers, Stack, Simulation | 0 | 100.00 -| 0394 |[Decode String](src/main/java/g0301_0400/s0394_decode_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, LeetCode_75_Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0190 |[Reverse Bits](src/main/java/g0101_0200/s0190_reverse_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 0 | 100.00 +| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 -#### Day 15 Heap +### Algorithm II + +#### Day 1 Binary Search | | | | | | |-|-|-|-|-|- -| 1046 |[Last Stone Weight](src/main/java/g1001_1100/s1046_last_stone_weight/Solution.java)| Easy | Array, Heap_Priority_Queue | 2 | 73.81 -| 0692 |[Top K Frequent Words](src/main/java/g0601_0700/s0692_top_k_frequent_words/Solution.java)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Trie, Bucket_Sort | 11 | 38.54 - -### Level 2 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 -#### Day 1 Implementation/Simulation +#### Day 2 Binary Search | | | | | | |-|-|-|-|-|- -| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 -| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 -| 1706 |[Where Will the Ball Fall](src/main/java/g1701_1800/s1706_where_will_the_ball_fall/Solution.java)| Medium | Array, Dynamic_Programming, Depth_First_Search, Matrix, Simulation | 2 | 64.55 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/java/g0101_0200/s0162_find_peak_element/Solution.java)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 -#### Day 2 String +#### Day 3 Two Pointers | | | | | | |-|-|-|-|-|- -| 0014 |[Longest Common Prefix](src/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java)| Easy | Top_Interview_Questions, String, Big_O_Time_O(n\*m)_Space_O(m) | 0 | 100.00 -| 0043 |[Multiply Strings](src/main/java/g0001_0100/s0043_multiply_strings/Solution.java)| Medium | String, Math, Simulation | 1 | 100.00 +| 0082 |[Remove Duplicates from Sorted List II](src/main/java/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 -#### Day 3 Linked List +#### Day 4 Two Pointers | | | | | | |-|-|-|-|-|- -| 0019 |[Remove Nth Node From End of List](src/main/java/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 -| 0234 |[Palindrome Linked List](src/main/java/g0201_0300/s0234_palindrome_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 4 | 84.46 +| 0844 |[Backspace String Compare](src/main/java/g0801_0900/s0844_backspace_string_compare/Solution.java)| Easy | String, Two_Pointers, Stack, Simulation | 0 | 100.00 +| 0986 |[Interval List Intersections](src/main/java/g0901_1000/s0986_interval_list_intersections/Solution.java)| Medium | Array, Two_Pointers | 2 | 99.95 +| 0011 |[Container With Most Water](src/main/java/g0001_0100/s0011_container_with_most_water/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 3 | 96.01 -#### Day 4 Linked List +#### Day 5 Sliding Window | | | | | | |-|-|-|-|-|- -| 0328 |[Odd Even Linked List](src/main/java/g0301_0400/s0328_odd_even_linked_list/Solution.java)| Medium | Linked_List, LeetCode_75_LinkedList | 0 | 100.00 -| 0148 |[Sort List](src/main/java/g0101_0200/s0148_sort_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 9 | 93.90 +| 0438 |[Find All Anagrams in a String](src/main/java/g0401_0500/s0438_find_all_anagrams_in_a_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 3 | 99.83 +| 0713 |[Subarray Product Less Than K](src/main/java/g0701_0800/s0713_subarray_product_less_than_k/Solution.java)| Medium | Array, Sliding_Window | 8 | 39.00 +| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 99.76 -#### Day 5 Greedy +#### Day 6 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 2131 |[Longest Palindrome by Concatenating Two Letter Words](src/main/java/g2101_2200/s2131_longest_palindrome_by_concatenating_two_letter_words/Solution.java)| Medium | Array, String, Hash_Table, Greedy, Counting | 73 | 76.60 -| 0621 |[Task Scheduler](src/main/java/g0601_0700/s0621_task_scheduler/Solution.java)| Medium | Array, Hash_Table, Sorting, Greedy, Heap_Priority_Queue, Counting | 3 | 84.32 +| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 +| 0547 |[Number of Provinces](src/main/java/g0501_0600/s0547_number_of_provinces/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find, LeetCode_75_Graphs/DFS | 2 | 69.51 -#### Day 6 Tree +#### Day 7 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0110 |[Balanced Binary Tree](src/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree | 1 | 98.82 +| 0117 |[Populating Next Right Pointers in Each Node II](src/main/java/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 0 | 100.00 +| 0572 |[Subtree of Another Tree](src/main/java/g0501_0600/s0572_subtree_of_another_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Hash_Function, String_Matching | 2 | 97.06 -#### Day 7 Tree +#### Day 8 Breadth First Search Depth First Search | | | | | | |-|-|-|-|-|- -| 0543 |[Diameter of Binary Tree](src/main/java/g0501_0600/s0543_diameter_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0437 |[Path Sum III](src/main/java/g0401_0500/s0437_path_sum_iii/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 2 | 100.00 +| 1091 |[Shortest Path in Binary Matrix](src/main/java/g1001_1100/s1091_shortest_path_in_binary_matrix/Solution.java)| Medium | Array, Breadth_First_Search, Matrix | 22 | 69.99 +| 0130 |[Surrounded Regions](src/main/java/g0101_0200/s0130_surrounded_regions/Solution.java)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 2 | 84.66 +| 0797 |[All Paths From Source to Target](src/main/java/g0701_0800/s0797_all_paths_from_source_to_target/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 2 | 90.53 -#### Day 8 Binary Search +#### Day 9 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 -| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0078 |[Subsets](src/main/java/g0001_0100/s0078_subsets/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 +| 0090 |[Subsets II](src/main/java/g0001_0100/s0090_subsets_ii/Solution.java)| Medium | Array, Bit_Manipulation, Backtracking | 2 | 82.94 -#### Day 9 Binary Search Tree +#### Day 10 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 -| 0230 |[Kth Smallest Element in a BST](src/main/java/g0201_0300/s0230_kth_smallest_element_in_a_bst/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 +| 0047 |[Permutations II](src/main/java/g0001_0100/s0047_permutations_ii/Solution.java)| Medium | Array, Backtracking | 1 | 99.86 +| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 +| 0040 |[Combination Sum II](src/main/java/g0001_0100/s0040_combination_sum_ii/Solution.java)| Medium | Array, Backtracking | 2 | 99.75 -#### Day 10 Graph/BFS/DFS +#### Day 11 Recursion Backtracking | | | | | | |-|-|-|-|-|- -| 0994 |[Rotting Oranges](src/main/java/g0901_1000/s0994_rotting_oranges/Solution.java)| Medium | Top_100_Liked_Questions, Array, Breadth_First_Search, Matrix, LeetCode_75_Graphs/BFS | 3 | 74.27 -| 0417 |[Pacific Atlantic Water Flow](src/main/java/g0401_0500/s0417_pacific_atlantic_water_flow/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 5 | 92.62 +| 0017 |[Letter Combinations of a Phone Number](src/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0022 |[Generate Parentheses](src/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 0 | 100.00 +| 0079 |[Word Search](src/main/java/g0001_0100/s0079_word_search/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 64 | 98.51 -#### Day 11 Graph/BFS/DFS +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0210 |[Course Schedule II](src/main/java/g0201_0300/s0210_course_schedule_ii/Solution.java)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 4 | 91.07 -| 0815 |[Bus Routes](src/main/java/g0801_0900/s0815_bus_routes/Solution.java)| Hard | Array, Hash_Table, Breadth_First_Search | 49 | 89.11 +| 0213 |[House Robber II](src/main/java/g0201_0300/s0213_house_robber_ii/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 +| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 -#### Day 12 Dynamic Programming +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 +| 0045 |[Jump Game II](src/main/java/g0001_0100/s0045_jump_game_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0062 |[Unique Paths](src/main/java/g0001_0100/s0062_unique_paths/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 -#### Day 13 Dynamic Programming +#### Day 14 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0416 |[Partition Equal Subset Sum](src/main/java/g0401_0500/s0416_partition_equal_subset_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 5 | 99.88 -| 0152 |[Maximum Product Subarray](src/main/java/g0101_0200/s0152_maximum_product_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 92.74 +| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 +| 0413 |[Arithmetic Slices](src/main/java/g0401_0500/s0413_arithmetic_slices/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 -#### Day 14 Sliding Window/Two Pointer +#### Day 15 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 -| 0016 |[3Sum Closest](src/main/java/g0001_0100/s0016_3sum_closest/Solution.java)| Medium | Array, Sorting, Two_Pointers | 4 | 98.21 -| 0076 |[Minimum Window Substring](src/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 2 | 99.83 +| 0091 |[Decode Ways](src/main/java/g0001_0100/s0091_decode_ways/Solution.java)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 2 | 66.37 +| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 -#### Day 15 Tree +#### Day 16 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0100 |[Same Tree](src/main/java/g0001_0100/s0100_same_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -| 0101 |[Symmetric Tree](src/main/java/g0101_0200/s0101_symmetric_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0199 |[Binary Tree Right Side View](src/main/java/g0101_0200/s0199_binary_tree_right_side_view/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 +| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 +| 0673 |[Number of Longest Increasing Subsequence](src/main/java/g0601_0700/s0673_number_of_longest_increasing_subsequence/Solution.java)| Medium | Array, Dynamic_Programming, Segment_Tree, Binary_Indexed_Tree | 25 | 68.75 -#### Day 16 Design +#### Day 17 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0232 |[Implement Queue using Stacks](src/main/java/g0201_0300/s0232_implement_queue_using_stacks/MyQueue.java)| Easy | Stack, Design, Queue | 1 | 67.21 -| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 -| 0208 |[Implement Trie (Prefix Tree)](src/main/java/g0201_0300/s0208_implement_trie_prefix_tree/Trie.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 32 | 95.05 +| 1143 |[Longest Common Subsequence](src/main/java/g1101_1200/s1143_longest_common_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 19 | 89.05 +| 0583 |[Delete Operation for Two Strings](src/main/java/g0501_0600/s0583_delete_operation_for_two_strings/Solution.java)| Medium | String, Dynamic_Programming | 12 | 79.10 -#### Day 17 Interval +#### Day 18 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0057 |[Insert Interval](src/main/java/g0001_0100/s0057_insert_interval/Solution.java)| Medium | Array | 0 | 100.00 -| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 +| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 +| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 +| 0343 |[Integer Break](src/main/java/g0301_0400/s0343_integer_break/Solution.java)| Medium | Dynamic_Programming, Math | 0 | 100.00 -#### Day 18 Stack +#### Day 19 Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0735 |[Asteroid Collision](src/main/java/g0701_0800/s0735_asteroid_collision/Solution.java)| Medium | Array, Stack, LeetCode_75_Stack | 2 | 99.59 -| 0227 |[Basic Calculator II](src/main/java/g0201_0300/s0227_basic_calculator_ii/Solution.java)| Medium | String, Math, Stack | 8 | 95.32 +| 0201 |[Bitwise AND of Numbers Range](src/main/java/g0201_0300/s0201_bitwise_and_of_numbers_range/Solution.java)| Medium | Bit_Manipulation | 3 | 100.00 -#### Day 19 Union Find +#### Day 20 Others | | | | | | |-|-|-|-|-|- -| 0547 |[Number of Provinces](src/main/java/g0501_0600/s0547_number_of_provinces/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find, LeetCode_75_Graphs/DFS | 2 | 69.51 -| 0947 |[Most Stones Removed with Same Row or Column](src/main/java/g0901_1000/s0947_most_stones_removed_with_same_row_or_column/Solution.java)| Medium | Depth_First_Search, Graph, Union_Find | 7 | 98.83 +| 0384 |[Shuffle an Array](src/main/java/g0301_0400/s0384_shuffle_an_array/Solution.java)| Medium | Array, Math, Randomized | 52 | 91.77 -#### Day 20 Brute Force/Backtracking +#### Day 21 Others | | | | | | |-|-|-|-|-|- -| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 -| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 +| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 +| 0149 |[Max Points on a Line](src/main/java/g0101_0200/s0149_max_points_on_a_line/Solution.java)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 7 | 99.18 -### Udemy +### Binary Search I -#### Udemy Integers +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0412 |[Fizz Buzz](src/main/java/g0401_0500/s0412_fizz_buzz/Solution.java)| Easy | String, Math, Simulation | 1 | 100.00 -| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 -| 0007 |[Reverse Integer](src/main/java/g0001_0100/s0007_reverse_integer/Solution.java)| Medium | Top_Interview_Questions, Math, Big_O_Time_O(log10(x))_Space_O(1) | 0 | 100.00 -| 0009 |[Palindrome Number](src/main/java/g0001_0100/s0009_palindrome_number/Solution.java)| Easy | Math, Big_O_Time_O(log10(x))_Space_O(1) | 4 | 100.00 -| 0172 |[Factorial Trailing Zeroes](src/main/java/g0101_0200/s0172_factorial_trailing_zeroes/Solution.java)| Medium | Top_Interview_Questions, Math | 0 | 100.00 -| 0050 |[Pow(x, n)](src/main/java/g0001_0100/s0050_powx_n/Solution.java)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 +| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 +| 0374 |[Guess Number Higher or Lower](src/main/java/g0301_0400/s0374_guess_number_higher_or_lower/Solution.java)| Easy | Binary_Search, Interactive, LeetCode_75_Binary_Search | 0 | 100.00 -#### Udemy Strings +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0344 |[Reverse String](src/main/java/g0301_0400/s0344_reverse_string/Solution.java)| Easy | String, Two_Pointers, Recursion | 1 | 99.91 -| 0014 |[Longest Common Prefix](src/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java)| Easy | Top_Interview_Questions, String, Big_O_Time_O(n\*m)_Space_O(m) | 0 | 100.00 -| 0187 |[Repeated DNA Sequences](src/main/java/g0101_0200/s0187_repeated_dna_sequences/Solution.java)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 29 | 77.11 -| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 -| 0020 |[Valid Parentheses](src/main/java/g0001_0100/s0020_valid_parentheses/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 2 | 97.19 -| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 -| 0394 |[Decode String](src/main/java/g0301_0400/s0394_decode_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, LeetCode_75_Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 -| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 -| 0151 |[Reverse Words in a String](src/main/java/g0101_0200/s0151_reverse_words_in_a_string/Solution.java)| Medium | String, Two_Pointers, LeetCode_75_Array/String | 2 | 99.69 -| 0273 |[Integer to English Words](src/main/java/g0201_0300/s0273_integer_to_english_words/Solution.java)| Hard | String, Math, Recursion | 3 | 95.67 +| 0035 |[Search Insert Position](src/main/java/g0001_0100/s0035_search_insert_position/Solution.java)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0852 |[Peak Index in a Mountain Array](src/main/java/g0801_0900/s0852_peak_index_in_a_mountain_array/Solution.java)| Medium | Array, Binary_Search | 0 | 100.00 -#### Udemy Binary Search +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 -| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 +| 0367 |[Valid Perfect Square](src/main/java/g0301_0400/s0367_valid_perfect_square/Solution.java)| Easy | Math, Binary_Search | 0 | 100.00 +| 1385 |[Find the Distance Value Between Two Arrays](src/main/java/g1301_1400/s1385_find_the_distance_value_between_two_arrays/Solution.java)| Easy | Array, Sorting, Binary_Search, Two_Pointers | 5 | 65.78 -#### Udemy Arrays +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 -| 0283 |[Move Zeroes](src/main/java/g0201_0300/s0283_move_zeroes/Solution.java)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 83.99 -| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 -| 0217 |[Contains Duplicate](src/main/java/g0201_0300/s0217_contains_duplicate/Solution.java)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 6 | 96.68 -| 0058 |[Length of Last Word](src/main/java/g0001_0100/s0058_length_of_last_word/Solution.java)| Easy | String | 0 | 100.00 -| 0605 |[Can Place Flowers](src/main/java/g0601_0700/s0605_can_place_flowers/Solution.java)| Easy | Array, Greedy, LeetCode_75_Array/String | 1 | 96.77 -| 0122 |[Best Time to Buy and Sell Stock II](src/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 1 | 76.91 -| 0080 |[Remove Duplicates from Sorted Array II](src/main/java/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/Solution.java)| Medium | Array, Two_Pointers | 0 | 100.00 -| 0189 |[Rotate Array](src/main/java/g0101_0200/s0189_rotate_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 -| 0075 |[Sort Colors](src/main/java/g0001_0100/s0075_sort_colors/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0066 |[Plus One](src/main/java/g0001_0100/s0066_plus_one/Solution.java)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 -| 0238 |[Product of Array Except Self](src/main/java/g0201_0300/s0238_product_of_array_except_self/Solution.java)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 1 | 99.66 -| 1291 |[Sequential Digits](src/main/java/g1201_1300/s1291_sequential_digits/Solution.java)| Medium | Enumeration | 0 | 100.00 -| 0448 |[Find All Numbers Disappeared in an Array](src/main/java/g0401_0500/s0448_find_all_numbers_disappeared_in_an_array/Solution.java)| Easy | Array, Hash_Table | 3 | 100.00 -| 0442 |[Find All Duplicates in an Array](src/main/java/g0401_0500/s0442_find_all_duplicates_in_an_array/Solution.java)| Medium | Array, Hash_Table | 5 | 98.83 -| 0041 |[First Missing Positive](src/main/java/g0001_0100/s0041_first_missing_positive/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 1 | 100.00 -| 0697 |[Degree of an Array](src/main/java/g0601_0700/s0697_degree_of_an_array/Solution.java)| Easy | Array, Hash_Table | 14 | 93.19 -| 0532 |[K-diff Pairs in an Array](src/main/java/g0501_0600/s0532_k_diff_pairs_in_an_array/Solution.java)| Medium | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 13 | 58.23 -| 0713 |[Subarray Product Less Than K](src/main/java/g0701_0800/s0713_subarray_product_less_than_k/Solution.java)| Medium | Array, Sliding_Window | 8 | 39.00 -| 1007 |[Minimum Domino Rotations For Equal Row](src/main/java/g1001_1100/s1007_minimum_domino_rotations_for_equal_row/Solution.java)| Medium | Array, Greedy | 5 | 79.64 -| 1306 |[Jump Game III](src/main/java/g1301_1400/s1306_jump_game_iii/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search | 2 | 96.23 -| 0456 |[132 Pattern](src/main/java/g0401_0500/s0456_132_pattern/Solution.java)| Medium | Array, Binary_Search, Stack, Ordered_Set, Monotonic_Stack | 16 | 82.41 -| 0239 |[Sliding Window Maximum](src/main/java/g0201_0300/s0239_sliding_window_maximum/Solution.java)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 95.89 +| 0069 |[Sqrt(x)](src/main/java/g0001_0100/s0069_sqrtx/Solution.java)| Easy | Top_Interview_Questions, Math, Binary_Search | 1 | 86.67 +| 0744 |[Find Smallest Letter Greater Than Target](src/main/java/g0701_0800/s0744_find_smallest_letter_greater_than_target/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 -#### Udemy Two Pointers +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 -| 0125 |[Valid Palindrome](src/main/java/g0101_0200/s0125_valid_palindrome/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers | 2 | 99.11 -| 0977 |[Squares of a Sorted Array](src/main/java/g0901_1000/s0977_squares_of_a_sorted_array/Solution.java)| Easy | Array, Sorting, Two_Pointers | 1 | 100.00 -| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 -| 0042 |[Trapping Rain Water](src/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 +| 0278 |[First Bad Version](src/main/java/g0201_0300/s0278_first_bad_version/Solution.java)| Easy | Binary_Search, Interactive | 15 | 87.89 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -#### Udemy Famous Algorithm +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 -| 0169 |[Majority Element](src/main/java/g0101_0200/s0169_majority_element/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.89 +| 0441 |[Arranging Coins](src/main/java/g0401_0500/s0441_arranging_coins/Solution.java)| Easy | Math, Binary_Search | 2 | 95.97 +| 1539 |[Kth Missing Positive Number](src/main/java/g1501_1600/s1539_kth_missing_positive_number/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 -#### Udemy Sorting Algorithms +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0912 |[Sort an Array](src/main/java/g0901_1000/s0912_sort_an_array/Solution.java)| Medium | Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Merge_Sort, Bucket_Sort, Counting_Sort, Radix_Sort | 25 | 38.15 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/java/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers | 2 | 92.62 +| 1608 |[Special Array With X Elements Greater Than or Equal X](src/main/java/g1601_1700/s1608_special_array_with_x_elements_greater_than_or_equal_x/Solution.java)| Easy | Array, Sorting, Binary_Search | 2 | 61.14 -#### Udemy 2D Arrays/Matrix +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0304 |[Range Sum Query 2D - Immutable](src/main/java/g0301_0400/s0304_range_sum_query_2d_immutable/NumMatrix.java)| Medium | Array, Matrix, Design, Prefix_Sum | 153 | 87.51 +| 1351 |[Count Negative Numbers in a Sorted Matrix](src/main/java/g1301_1400/s1351_count_negative_numbers_in_a_sorted_matrix/Solution.java)| Easy | Array, Binary_Search, Matrix | 1 | 49.66 | 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 -| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 -| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 -| 1572 |[Matrix Diagonal Sum](src/main/java/g1501_1600/s1572_matrix_diagonal_sum/Solution.java)| Easy | Array, Matrix | 0 | 100.00 -| 0073 |[Set Matrix Zeroes](src/main/java/g0001_0100/s0073_set_matrix_zeroes/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 0 | 100.00 -| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 -#### Udemy Linked List +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0114 |[Flatten Binary Tree to Linked List](src/main/java/g0101_0200/s0114_flatten_binary_tree_to_linked_list/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0445 |[Add Two Numbers II](src/main/java/g0401_0500/s0445_add_two_numbers_ii/Solution.java)| Medium | Math, Stack, Linked_List | 3 | 90.38 -| 0328 |[Odd Even Linked List](src/main/java/g0301_0400/s0328_odd_even_linked_list/Solution.java)| Medium | Linked_List, LeetCode_75_LinkedList | 0 | 100.00 -| 0061 |[Rotate List](src/main/java/g0001_0100/s0061_rotate_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 -| 0024 |[Swap Nodes in Pairs](src/main/java/g0001_0100/s0024_swap_nodes_in_pairs/Solution.java)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 -| 0142 |[Linked List Cycle II](src/main/java/g0101_0200/s0142_linked_list_cycle_ii/Solution.java)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0141 |[Linked List Cycle](src/main/java/g0101_0200/s0141_linked_list_cycle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 -| 0160 |[Intersection of Two Linked Lists](src/main/java/g0101_0200/s0160_intersection_of_two_linked_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 1 | 99.92 -| 0234 |[Palindrome Linked List](src/main/java/g0201_0300/s0234_palindrome_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 4 | 84.46 -| 0138 |[Copy List with Random Pointer](src/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0025 |[Reverse Nodes in k-Group](src/main/java/g0001_0100/s0025_reverse_nodes_in_k_group/Solution.java)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 -| 0146 |[LRU Cache](src/main/java/g0101_0200/s0146_lru_cache/LRUCache.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 40 | 98.20 -| 0707 |[Design Linked List](src/main/java/g0701_0800/s0707_design_linked_list/MyLinkedList.java)| Medium | Design, Linked_List | 10 | 70.60 +| 1337 |[The K Weakest Rows in a Matrix](src/main/java/g1301_1400/s1337_the_k_weakest_rows_in_a_matrix/Solution.java)| Easy | Array, Sorting, Binary_Search, Matrix, Heap_Priority_Queue | 1 | 99.77 +| 1346 |[Check If N and Its Double Exist](src/main/java/g1301_1400/s1346_check_if_n_and_its_double_exist/Solution.java)| Easy | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 1 | 99.64 -#### Udemy Tree Stack Queue +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0144 |[Binary Tree Preorder Traversal](src/main/java/g0101_0200/s0144_binary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 48.38 -| 0094 |[Binary Tree Inorder Traversal](src/main/java/g0001_0100/s0094_binary_tree_inorder_traversal/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0145 |[Binary Tree Postorder Traversal](src/main/java/g0101_0200/s0145_binary_tree_postorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 49.11 -| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 -| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/java/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/Solution.java)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 -| 1008 |[Construct Binary Search Tree from Preorder Traversal](src/main/java/g1001_1100/s1008_construct_binary_search_tree_from_preorder_traversal/Solution.java)| Medium | Array, Tree, Binary_Tree, Stack, Monotonic_Stack, Binary_Search_Tree | 0 | 100.00 -| 0543 |[Diameter of Binary Tree](src/main/java/g0501_0600/s0543_diameter_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0938 |[Range Sum of BST](src/main/java/g0901_1000/s0938_range_sum_of_bst/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 -| 0100 |[Same Tree](src/main/java/g0001_0100/s0100_same_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0111 |[Minimum Depth of Binary Tree](src/main/java/g0101_0200/s0111_minimum_depth_of_binary_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 1 | 97.49 -| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 -| 0110 |[Balanced Binary Tree](src/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree | 1 | 98.82 -| 0701 |[Insert into a Binary Search Tree](src/main/java/g0701_0800/s0701_insert_into_a_binary_search_tree/Solution.java)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 -| 0297 |[Serialize and Deserialize Binary Tree](src/main/java/g0201_0300/s0297_serialize_and_deserialize_binary_tree/Codec.java)| Hard | String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 7 | 98.13 -| 0124 |[Binary Tree Maximum Path Sum](src/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0337 |[House Robber III](src/main/java/g0301_0400/s0337_house_robber_iii/Solution.java)| Medium | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 1 | 91.77 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/java/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 6 | 100.00 -| 0968 |[Binary Tree Cameras](src/main/java/g0901_1000/s0968_binary_tree_cameras/Solution.java)| Hard | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0350 |[Intersection of Two Arrays II](src/main/java/g0301_0400/s0350_intersection_of_two_arrays_ii/Solution.java)| Easy | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 4 | 69.62 +| 0633 |[Sum of Square Numbers](src/main/java/g0601_0700/s0633_sum_of_square_numbers/Solution.java)| Medium | Math, Binary_Search, Two_Pointers | 4 | 82.92 -#### Udemy Trie and Heap +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/java/g0201_0300/s0208_implement_trie_prefix_tree/Trie.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 32 | 95.05 -| 0745 |[Prefix and Suffix Search](src/main/java/g0701_0800/s0745_prefix_and_suffix_search/WordFilter.java)| Hard | String, Design, Trie | 366 | 76.15 +| 1855 |[Maximum Distance Between a Pair of Values](src/main/java/g1801_1900/s1855_maximum_distance_between_a_pair_of_values/Solution.java)| Medium | Array, Greedy, Binary_Search, Two_Pointers | 4 | 62.20 +| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -#### Udemy Graph +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 -| 0133 |[Clone Graph](src/main/java/g0101_0200/s0133_clone_graph/Solution.java)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 25 | 68.87 -| 0417 |[Pacific Atlantic Water Flow](src/main/java/g0401_0500/s0417_pacific_atlantic_water_flow/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 5 | 92.62 - -#### Udemy Dynamic Programming +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 -| | | | | | -|-|-|-|-|-|- -| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 -| 0118 |[Pascal's Triangle](src/main/java/g0101_0200/s0118_pascals_triangle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 1 | 67.08 -| 0119 |[Pascal's Triangle II](src/main/java/g0101_0200/s0119_pascals_triangle_ii/Solution.java)| Easy | Array, Dynamic_Programming | 0 | 100.00 -| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 -| 0152 |[Maximum Product Subarray](src/main/java/g0101_0200/s0152_maximum_product_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 92.74 -| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0213 |[House Robber II](src/main/java/g0201_0300/s0213_house_robber_ii/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 -| 0509 |[Fibonacci Number](src/main/java/g0501_0600/s0509_fibonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 0 | 100.00 -| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0064 |[Minimum Path Sum](src/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 1 | 99.73 -| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 -| 1143 |[Longest Common Subsequence](src/main/java/g1101_1200/s1143_longest_common_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 19 | 89.05 -| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 -| 0044 |[Wildcard Matching](src/main/java/g0001_0100/s0044_wildcard_matching/Solution.java)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Greedy, Recursion | 2 | 99.87 -| 0010 |[Regular Expression Matching](src/main/java/g0001_0100/s0010_regular_expression_matching/Solution.java)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 1 | 100.00 +### Binary Search II -#### Udemy Backtracking/Recursion +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0022 |[Generate Parentheses](src/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 0 | 100.00 -| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 -| 0216 |[Combination Sum III](src/main/java/g0201_0300/s0216_combination_sum_iii/Solution.java)| Medium | Array, Backtracking, LeetCode_75_Backtracking | 1 | 81.35 -| 0078 |[Subsets](src/main/java/g0001_0100/s0078_subsets/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 -| 0017 |[Letter Combinations of a Phone Number](src/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 -| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 +| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 99.76 +| 0611 |[Valid Triangle Number](src/main/java/g0601_0700/s0611_valid_triangle_number/Solution.java)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 10 | 100.00 -#### Udemy Bit Manipulation +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 -| 0389 |[Find the Difference](src/main/java/g0301_0400/s0389_find_the_difference/Solution.java)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 1 | 100.00 -| 0190 |[Reverse Bits](src/main/java/g0101_0200/s0190_reverse_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 0 | 100.00 -| 0461 |[Hamming Distance](src/main/java/g0401_0500/s0461_hamming_distance/Solution.java)| Easy | Bit_Manipulation | 0 | 100.00 -| 1009 |[Complement of Base 10 Integer](src/main/java/g1001_1100/s1009_complement_of_base_10_integer/Solution.java)| Easy | Bit_Manipulation | 1 | 41.56 -| 0338 |[Counting Bits](src/main/java/g0301_0400/s0338_counting_bits/Solution.java)| Easy | Dynamic_Programming, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 2 | 96.37 -| 0371 |[Sum of Two Integers](src/main/java/g0301_0400/s0371_sum_of_two_integers/Solution.java)| Medium | Math, Bit_Manipulation | 0 | 100.00 -| 0029 |[Divide Two Integers](src/main/java/g0001_0100/s0029_divide_two_integers/Solution.java)| Medium | Top_Interview_Questions, Math, Bit_Manipulation | 1 | 97.44 +| 0658 |[Find K Closest Elements](src/main/java/g0601_0700/s0658_find_k_closest_elements/Solution.java)| Medium | Array, Sorting, Binary_Search, Two_Pointers, Heap_Priority_Queue | 3 | 99.20 +| 1894 |[Find the Student that Will Replace the Chalk](src/main/java/g1801_1900/s1894_find_the_student_that_will_replace_the_chalk/Solution.java)| Medium | Array, Binary_Search, Simulation, Prefix_Sum | 2 | 76.67 -#### Udemy Design +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 - -### Top Interview 150 +| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 +| 1760 |[Minimum Limit of Balls in a Bag](src/main/java/g1701_1800/s1760_minimum_limit_of_balls_in_a_bag/Solution.java)| Medium | Array, Binary_Search | 44 | 78.49 -#### Top Interview 150 Array/String +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0088 |[Merge Sorted Array](src/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 0 | 100.00 -| 0027 |[Remove Element](src/main/java/g0001_0100/s0027_remove_element/Solution.java)| Easy | Array, Two_Pointers | 0 | 100.00 -| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 -| 0080 |[Remove Duplicates from Sorted Array II](src/main/java/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/Solution.java)| Medium | Array, Two_Pointers | 0 | 100.00 -| 0169 |[Majority Element](src/main/java/g0101_0200/s0169_majority_element/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.89 -| 0189 |[Rotate Array](src/main/java/g0101_0200/s0189_rotate_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 -| 0122 |[Best Time to Buy and Sell Stock II](src/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 1 | 76.91 -| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 -| 0045 |[Jump Game II](src/main/java/g0001_0100/s0045_jump_game_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0274 |[H-Index](src/main/java/g0201_0300/s0274_h_index/Solution.java)| Medium | Array, Sorting, Counting_Sort | 0 | 100.00 -| 0380 |[Insert Delete GetRandom O(1)](src/main/java/g0301_0400/s0380_insert_delete_getrandom_o1/RandomizedSet.java)| Medium | Array, Hash_Table, Math, Design, Randomized | 27 | 93.44 -| 0238 |[Product of Array Except Self](src/main/java/g0201_0300/s0238_product_of_array_except_self/Solution.java)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 1 | 99.66 -| 0134 |[Gas Station](src/main/java/g0101_0200/s0134_gas_station/Solution.java)| Medium | Top_Interview_Questions, Array, Greedy | 2 | 97.52 -| 0135 |[Candy](src/main/java/g0101_0200/s0135_candy/Solution.java)| Hard | Array, Greedy | 3 | 83.95 -| 0042 |[Trapping Rain Water](src/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0013 |[Roman to Integer](src/main/java/g0001_0100/s0013_roman_to_integer/Solution.java)| Easy | Top_Interview_Questions, String, Hash_Table, Math, Big_O_Time_O(n)_Space_O(1) | 2 | 100.00 -| 0012 |[Integer to Roman](src/main/java/g0001_0100/s0012_integer_to_roman/Solution.java)| Medium | String, Hash_Table, Math, Big_O_Time_O(1)_Space_O(1) | 2 | 100.00 -| 0058 |[Length of Last Word](src/main/java/g0001_0100/s0058_length_of_last_word/Solution.java)| Easy | String | 0 | 100.00 -| 0014 |[Longest Common Prefix](src/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java)| Easy | Top_Interview_Questions, String, Big_O_Time_O(n\*m)_Space_O(m) | 0 | 100.00 -| 0151 |[Reverse Words in a String](src/main/java/g0101_0200/s0151_reverse_words_in_a_string/Solution.java)| Medium | String, Two_Pointers, LeetCode_75_Array/String | 2 | 99.69 -| 0006 |[Zigzag Conversion](src/main/java/g0001_0100/s0006_zigzag_conversion/Solution.java)| Medium | String, Big_O_Time_O(n)_Space_O(n) | 2 | 99.71 -| 0028 |[Find the Index of the First Occurrence in a String](src/main/java/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 -| 0068 |[Text Justification](src/main/java/g0001_0100/s0068_text_justification/Solution.java)| Hard | Array, String, Simulation | 0 | 100.00 +| 0875 |[Koko Eating Bananas](src/main/java/g0801_0900/s0875_koko_eating_bananas/Solution.java)| Medium | Array, Binary_Search, LeetCode_75_Binary_Search | 15 | 91.32 +| 1552 |[Magnetic Force Between Two Balls](src/main/java/g1501_1600/s1552_magnetic_force_between_two_balls/Solution.java)| Medium | Array, Sorting, Binary_Search | 39 | 99.65 -#### Top Interview 150 Two Pointers +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0125 |[Valid Palindrome](src/main/java/g0101_0200/s0125_valid_palindrome/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers | 2 | 99.11 -| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 -| 0167 |[Two Sum II - Input Array Is Sorted](src/main/java/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers | 2 | 92.62 -| 0011 |[Container With Most Water](src/main/java/g0001_0100/s0011_container_with_most_water/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 3 | 96.01 -| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 +| 0287 |[Find the Duplicate Number](src/main/java/g0201_0300/s0287_find_the_duplicate_number/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 2 | 97.52 +| 1283 |[Find the Smallest Divisor Given a Threshold](src/main/java/g1201_1300/s1283_find_the_smallest_divisor_given_a_threshold/Solution.java)| Medium | Array, Binary_Search | 9 | 95.49 -#### Top Interview 150 Sliding Window +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 99.76 -| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 -| 0030 |[Substring with Concatenation of All Words](src/main/java/g0001_0100/s0030_substring_with_concatenation_of_all_words/Solution.java)| Hard | String, Hash_Table, Sliding_Window | 11 | 97.43 -| 0076 |[Minimum Window Substring](src/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 2 | 99.83 +| 1898 |[Maximum Number of Removable Characters](src/main/java/g1801_1900/s1898_maximum_number_of_removable_characters/Solution.java)| Medium | Array, String, Binary_Search | 121 | 72.51 +| 1870 |[Minimum Speed to Arrive on Time](src/main/java/g1801_1900/s1870_minimum_speed_to_arrive_on_time/Solution.java)| Medium | Array, Binary_Search | 86 | 88.58 -#### Top Interview 150 Matrix +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0036 |[Valid Sudoku](src/main/java/g0001_0100/s0036_valid_sudoku/Solution.java)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 1 | 100.00 -| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 -| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 -| 0073 |[Set Matrix Zeroes](src/main/java/g0001_0100/s0073_set_matrix_zeroes/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 0 | 100.00 -| 0289 |[Game of Life](src/main/java/g0201_0300/s0289_game_of_life/Solution.java)| Medium | Array, Matrix, Simulation | 0 | 100.00 +| 1482 |[Minimum Number of Days to Make m Bouquets](src/main/java/g1401_1500/s1482_minimum_number_of_days_to_make_m_bouquets/Solution.java)| Medium | Array, Binary_Search | 25 | 69.18 +| 1818 |[Minimum Absolute Sum Difference](src/main/java/g1801_1900/s1818_minimum_absolute_sum_difference/Solution.java)| Medium | Array, Sorting, Binary_Search, Ordered_Set | 13 | 99.44 -#### Top Interview 150 Hashmap +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0383 |[Ransom Note](src/main/java/g0301_0400/s0383_ransom_note/Solution.java)| Easy | String, Hash_Table, Counting | 1 | 99.10 -| 0205 |[Isomorphic Strings](src/main/java/g0201_0300/s0205_isomorphic_strings/Solution.java)| Easy | String, Hash_Table | 2 | 99.18 -| 0290 |[Word Pattern](src/main/java/g0201_0300/s0290_word_pattern/Solution.java)| Easy | String, Hash_Table | 0 | 100.00 -| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 -| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 -| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 -| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 -| 0219 |[Contains Duplicate II](src/main/java/g0201_0300/s0219_contains_duplicate_ii/Solution.java)| Easy | Array, Hash_Table, Sliding_Window | 15 | 98.00 -| 0128 |[Longest Consecutive Sequence](src/main/java/g0101_0200/s0128_longest_consecutive_sequence/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 14 | 98.89 +| 0240 |[Search a 2D Matrix II](src/main/java/g0201_0300/s0240_search_a_2d_matrix_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 5 | 99.92 +| 0275 |[H-Index II](src/main/java/g0201_0300/s0275_h_index_ii/Solution.java)| Medium | Array, Binary_Search | 0 | 100.00 -#### Top Interview 150 Intervals +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0228 |[Summary Ranges](src/main/java/g0201_0300/s0228_summary_ranges/Solution.java)| Easy | Array | 0 | 100.00 -| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 -| 0057 |[Insert Interval](src/main/java/g0001_0100/s0057_insert_interval/Solution.java)| Medium | Array | 0 | 100.00 -| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/java/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/Solution.java)| Medium | Array, Sorting, Greedy, LeetCode_75_Intervals | 52 | 89.91 +| 1838 |[Frequency of the Most Frequent Element](src/main/java/g1801_1900/s1838_frequency_of_the_most_frequent_element/Solution.java)| Medium | Array, Sorting, Greedy, Binary_Search, Prefix_Sum, Sliding_Window | 11 | 100.00 +| 0540 |[Single Element in a Sorted Array](src/main/java/g0501_0600/s0540_single_element_in_a_sorted_array/Solution.java)| Medium | Array, Binary_Search | 0 | 100.00 -#### Top Interview 150 Stack +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/java/g0001_0100/s0020_valid_parentheses/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 2 | 97.19 -| 0071 |[Simplify Path](src/main/java/g0001_0100/s0071_simplify_path/Solution.java)| Medium | String, Stack | 2 | 99.86 -| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 -| 0150 |[Evaluate Reverse Polish Notation](src/main/java/g0101_0200/s0150_evaluate_reverse_polish_notation/Solution.java)| Medium | Top_Interview_Questions, Array, Math, Stack | 6 | 76.50 -| 0224 |[Basic Calculator](src/main/java/g0201_0300/s0224_basic_calculator/Solution.java)| Hard | String, Math, Stack, Recursion | 2 | 96.52 +| 0222 |[Count Complete Tree Nodes](src/main/java/g0201_0300/s0222_count_complete_tree_nodes/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree | 0 | 100.00 +| 1712 |[Ways to Split Array Into Three Subarrays](src/main/java/g1701_1800/s1712_ways_to_split_array_into_three_subarrays/Solution.java)| Medium | Array, Binary_Search, Two_Pointers, Prefix_Sum | 16 | 84.24 -#### Top Interview 150 Linked List +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/java/g0101_0200/s0141_linked_list_cycle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0002 |[Add Two Numbers](src/main/java/g0001_0100/s0002_add_two_numbers/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 1 | 100.00 -| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 -| 0138 |[Copy List with Random Pointer](src/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0092 |[Reverse Linked List II](src/main/java/g0001_0100/s0092_reverse_linked_list_ii/Solution.java)| Medium | Linked_List | 0 | 100.00 -| 0025 |[Reverse Nodes in k-Group](src/main/java/g0001_0100/s0025_reverse_nodes_in_k_group/Solution.java)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 -| 0019 |[Remove Nth Node From End of List](src/main/java/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 -| 0082 |[Remove Duplicates from Sorted List II](src/main/java/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 -| 0061 |[Rotate List](src/main/java/g0001_0100/s0061_rotate_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 -| 0086 |[Partition List](src/main/java/g0001_0100/s0086_partition_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 -| 0146 |[LRU Cache](src/main/java/g0101_0200/s0146_lru_cache/LRUCache.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 40 | 98.20 +| 0826 |[Most Profit Assigning Work](src/main/java/g0801_0900/s0826_most_profit_assigning_work/Solution.java)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 21 | 83.83 +| 0436 |[Find Right Interval](src/main/java/g0401_0500/s0436_find_right_interval/Solution.java)| Medium | Array, Sorting, Binary_Search | 20 | 81.51 -#### Top Interview 150 Binary Tree General +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 -| 0100 |[Same Tree](src/main/java/g0001_0100/s0100_same_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0101 |[Symmetric Tree](src/main/java/g0101_0200/s0101_symmetric_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/java/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 1 | 96.33 -| 0106 |[Construct Binary Tree from Inorder and Postorder Traversal](src/main/java/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/Solution.java)| Medium | Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer | 0 | 100.00 -| 0117 |[Populating Next Right Pointers in Each Node II](src/main/java/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 0 | 100.00 -| 0114 |[Flatten Binary Tree to Linked List](src/main/java/g0101_0200/s0114_flatten_binary_tree_to_linked_list/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0112 |[Path Sum](src/main/java/g0101_0200/s0112_path_sum/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -| 0129 |[Sum Root to Leaf Numbers](src/main/java/g0101_0200/s0129_sum_root_to_leaf_numbers/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree | 0 | 100.00 -| 0124 |[Binary Tree Maximum Path Sum](src/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 -| 0222 |[Count Complete Tree Nodes](src/main/java/g0201_0300/s0222_count_complete_tree_nodes/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree | 0 | 100.00 -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/java/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 6 | 100.00 +| 0081 |[Search in Rotated Sorted Array II](src/main/java/g0001_0100/s0081_search_in_rotated_sorted_array_ii/Solution.java)| Medium | Array, Binary_Search | 1 | 82.83 +| 0162 |[Find Peak Element](src/main/java/g0101_0200/s0162_find_peak_element/Solution.java)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 -#### Top Interview 150 Binary Tree BFS +#### Day 13 | | | | | | |-|-|-|-|-|- -| 0199 |[Binary Tree Right Side View](src/main/java/g0101_0200/s0199_binary_tree_right_side_view/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 -| 0637 |[Average of Levels in Binary Tree](src/main/java/g0601_0700/s0637_average_of_levels_in_binary_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 2 | 94.34 -| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 -| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/java/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/Solution.java)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0154 |[Find Minimum in Rotated Sorted Array II](src/main/java/g0101_0200/s0154_find_minimum_in_rotated_sorted_array_ii/Solution.java)| Hard | Array, Binary_Search | 1 | 77.09 +| 0528 |[Random Pick with Weight](src/main/java/g0501_0600/s0528_random_pick_with_weight/Solution.java)| Medium | Math, Binary_Search, Prefix_Sum, Randomized | 42 | 50.90 -#### Top Interview 150 Binary Search Tree +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0530 |[Minimum Absolute Difference in BST](src/main/java/g0501_0600/s0530_minimum_absolute_difference_in_bst/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 -| 0230 |[Kth Smallest Element in a BST](src/main/java/g0201_0300/s0230_kth_smallest_element_in_a_bst/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 1508 |[Range Sum of Sorted Subarray Sums](src/main/java/g1501_1600/s1508_range_sum_of_sorted_subarray_sums/Solution.java)| Medium | Array, Sorting, Binary_Search, Two_Pointers | 60 | 93.84 +| 1574 |[Shortest Subarray to be Removed to Make Array Sorted](src/main/java/g1501_1600/s1574_shortest_subarray_to_be_removed_to_make_array_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers, Stack, Monotonic_Stack | 2 | 84.97 -#### Top Interview 150 Graph General +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 -| 0130 |[Surrounded Regions](src/main/java/g0101_0200/s0130_surrounded_regions/Solution.java)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 2 | 84.66 -| 0133 |[Clone Graph](src/main/java/g0101_0200/s0133_clone_graph/Solution.java)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 25 | 68.87 -| 0399 |[Evaluate Division](src/main/java/g0301_0400/s0399_evaluate_division/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path, LeetCode_75_Graphs/DFS | 1 | 99.52 -| 0207 |[Course Schedule](src/main/java/g0201_0300/s0207_course_schedule/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 3 | 99.99 -| 0210 |[Course Schedule II](src/main/java/g0201_0300/s0210_course_schedule_ii/Solution.java)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 4 | 91.07 +| 1292 |[Maximum Side Length of a Square with Sum Less than or Equal to Threshold](src/main/java/g1201_1300/s1292_maximum_side_length_of_a_square_with_sum_less_than_or_equal_to_threshold/Solution.java)| Medium | Array, Binary_Search, Matrix, Prefix_Sum | 23 | 32.97 +| 1498 |[Number of Subsequences That Satisfy the Given Sum Condition](src/main/java/g1401_1500/s1498_number_of_subsequences_that_satisfy_the_given_sum_condition/Solution.java)| Medium | Array, Sorting, Binary_Search, Two_Pointers | 27 | 99.13 -#### Top Interview 150 Graph BFS +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0909 |[Snakes and Ladders](src/main/java/g0901_1000/s0909_snakes_and_ladders/Solution.java)| Medium | Array, Breadth_First_Search, Matrix | 4 | 95.81 -| 0433 |[Minimum Genetic Mutation](src/main/java/g0401_0500/s0433_minimum_genetic_mutation/Solution.java)| Medium | String, Hash_Table, Breadth_First_Search | 0 | 100.00 -| 0127 |[Word Ladder](src/main/java/g0101_0200/s0127_word_ladder/Solution.java)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 22 | 96.00 +| 0981 |[Time Based Key-Value Store](src/main/java/g0901_1000/s0981_time_based_key_value_store/TimeMap.java)| Medium | String, Hash_Table, Binary_Search, Design | 239 | 72.78 +| 1300 |[Sum of Mutated Array Closest to Target](src/main/java/g1201_1300/s1300_sum_of_mutated_array_closest_to_target/Solution.java)| Medium | Array, Sorting, Binary_Search | 7 | 33.33 -#### Top Interview 150 Trie +#### Day 17 | | | | | | |-|-|-|-|-|- -| 0208 |[Implement Trie (Prefix Tree)](src/main/java/g0201_0300/s0208_implement_trie_prefix_tree/Trie.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 32 | 95.05 -| 0211 |[Design Add and Search Words Data Structure](src/main/java/g0201_0300/s0211_design_add_and_search_words_data_structure/WordDictionary.java)| Medium | String, Depth_First_Search, Design, Trie | 156 | 99.85 -| 0212 |[Word Search II](src/main/java/g0201_0300/s0212_word_search_ii/Solution.java)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | 17 | 99.16 +| 1802 |[Maximum Value at a Given Index in a Bounded Array](src/main/java/g1801_1900/s1802_maximum_value_at_a_given_index_in_a_bounded_array/Solution.java)| Medium | Greedy, Binary_Search | 2 | 58.44 +| 1901 |[Find a Peak Element II](src/main/java/g1901_2000/s1901_find_a_peak_element_ii/Solution.java)| Medium | Array, Binary_Search, Matrix, Divide_and_Conquer | 0 | 100.00 -#### Top Interview 150 Backtracking +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 -| 0077 |[Combinations](src/main/java/g0001_0100/s0077_combinations/Solution.java)| Medium | Backtracking | 15 | 92.38 -| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 -| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 -| 0052 |[N-Queens II](src/main/java/g0001_0100/s0052_n_queens_ii/Solution.java)| Hard | Backtracking | 0 | 100.00 -| 0022 |[Generate Parentheses](src/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 0 | 100.00 -| 0079 |[Word Search](src/main/java/g0001_0100/s0079_word_search/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 64 | 98.51 +| 1146 |[Snapshot Array](src/main/java/g1101_1200/s1146_snapshot_array/SnapshotArray.java)| Medium | Array, Hash_Table, Binary_Search, Design | 68 | 45.86 +| 1488 |[Avoid Flood in The City](src/main/java/g1401_1500/s1488_avoid_flood_in_the_city/Solution.java)| Medium | Array, Hash_Table, Greedy, Binary_Search, Heap_Priority_Queue | 82 | 75.08 -#### Top Interview 150 Divide and Conquer +#### Day 19 | | | | | | |-|-|-|-|-|- -| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 -| 0148 |[Sort List](src/main/java/g0101_0200/s0148_sort_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 9 | 93.90 -| 0427 |[Construct Quad Tree](src/main/java/g0401_0500/s0427_construct_quad_tree/Solution.java)| Medium | Array, Tree, Matrix, Divide_and_Conquer | 0 | 100.00 -| 0023 |[Merge k Sorted Lists](src/main/java/g0001_0100/s0023_merge_k_sorted_lists/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 1 | 99.86 +| 1562 |[Find Latest Group of Size M](src/main/java/g1501_1600/s1562_find_latest_group_of_size_m/Solution.java)| Medium | Array, Binary_Search, Simulation | 8 | 90.00 +| 1648 |[Sell Diminishing-Valued Colored Balls](src/main/java/g1601_1700/s1648_sell_diminishing_valued_colored_balls/Solution.java)| Medium | Array, Math, Sorting, Greedy, Binary_Search, Heap_Priority_Queue | 27 | 80.64 -#### Top Interview 150 Kadane's Algorithm +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 -| 0918 |[Maximum Sum Circular Subarray](src/main/java/g0901_1000/s0918_maximum_sum_circular_subarray/Solution.java)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 99.34 +| 1201 |[Ugly Number III](src/main/java/g1201_1300/s1201_ugly_number_iii/Solution.java)| Medium | Math, Binary_Search, Number_Theory | 0 | 100.00 +| 0911 |[Online Election](src/main/java/g0901_1000/s0911_online_election/TopVotedCandidate.java)| Medium | Array, Hash_Table, Binary_Search, Design | 63 | 98.81 -#### Top Interview 150 Binary Search +### Dynamic Programming I + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/java/g0001_0100/s0035_search_insert_position/Solution.java)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 -| 0162 |[Find Peak Element](src/main/java/g0101_0200/s0162_find_peak_element/Solution.java)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 -| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 -| 0004 |[Median of Two Sorted Arrays](src/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 1 | 100.00 +| 0509 |[Fibonacci Number](src/main/java/g0501_0600/s0509_fibonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 0 | 100.00 +| 1137 |[N-th Tribonacci Number](src/main/java/g1101_1200/s1137_n_th_tribonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Memoization, LeetCode_75_DP/1D | 0 | 100.00 -#### Top Interview 150 Heap +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/java/g0201_0300/s0215_kth_largest_element_in_an_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, LeetCode_75_Heap/Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 5 | 70.82 -| 0502 |[IPO](src/main/java/g0501_0600/s0502_ipo/Solution.java)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue | 64 | 97.22 -| 0373 |[Find K Pairs with Smallest Sums](src/main/java/g0301_0400/s0373_find_k_pairs_with_smallest_sums/Solution.java)| Medium | Array, Heap_Priority_Queue | 27 | 90.23 -| 0295 |[Find Median from Data Stream](src/main/java/g0201_0300/s0295_find_median_from_data_stream/MedianFinder.java)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 83 | 99.56 +| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0746 |[Min Cost Climbing Stairs](src/main/java/g0701_0800/s0746_min_cost_climbing_stairs/Solution.java)| Easy | Array, Dynamic_Programming, LeetCode_75_DP/1D | 1 | 86.38 -#### Top Interview 150 Bit Manipulation +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0067 |[Add Binary](src/main/java/g0001_0100/s0067_add_binary/Solution.java)| Easy | String, Math, Bit_Manipulation, Simulation | 1 | 99.82 -| 0190 |[Reverse Bits](src/main/java/g0101_0200/s0190_reverse_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 0 | 100.00 -| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 -| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 -| 0137 |[Single Number II](src/main/java/g0101_0200/s0137_single_number_ii/Solution.java)| Medium | Array, Bit_Manipulation | 0 | 100.00 -| 0201 |[Bitwise AND of Numbers Range](src/main/java/g0201_0300/s0201_bitwise_and_of_numbers_range/Solution.java)| Medium | Bit_Manipulation | 3 | 100.00 +| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0213 |[House Robber II](src/main/java/g0201_0300/s0213_house_robber_ii/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 +| 0740 |[Delete and Earn](src/main/java/g0701_0800/s0740_delete_and_earn/Solution.java)| Medium | Array, Hash_Table, Dynamic_Programming | 4 | 77.68 -#### Top Interview 150 Math +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0009 |[Palindrome Number](src/main/java/g0001_0100/s0009_palindrome_number/Solution.java)| Easy | Math, Big_O_Time_O(log10(x))_Space_O(1) | 4 | 100.00 -| 0066 |[Plus One](src/main/java/g0001_0100/s0066_plus_one/Solution.java)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 -| 0172 |[Factorial Trailing Zeroes](src/main/java/g0101_0200/s0172_factorial_trailing_zeroes/Solution.java)| Medium | Top_Interview_Questions, Math | 0 | 100.00 -| 0069 |[Sqrt(x)](src/main/java/g0001_0100/s0069_sqrtx/Solution.java)| Easy | Top_Interview_Questions, Math, Binary_Search | 1 | 86.67 -| 0050 |[Pow(x, n)](src/main/java/g0001_0100/s0050_powx_n/Solution.java)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 -| 0149 |[Max Points on a Line](src/main/java/g0101_0200/s0149_max_points_on_a_line/Solution.java)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 7 | 99.18 +| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 +| 0045 |[Jump Game II](src/main/java/g0001_0100/s0045_jump_game_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -#### Top Interview 150 1D DP +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 -| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 -| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 +| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 +| 0918 |[Maximum Sum Circular Subarray](src/main/java/g0901_1000/s0918_maximum_sum_circular_subarray/Solution.java)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 99.34 -#### Top Interview 150 Multidimensional DP +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 -| 0064 |[Minimum Path Sum](src/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 1 | 99.73 -| 0063 |[Unique Paths II](src/main/java/g0001_0100/s0063_unique_paths_ii/Solution.java)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 -| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 -| 0097 |[Interleaving String](src/main/java/g0001_0100/s0097_interleaving_string/Solution.java)| Medium | String, Dynamic_Programming | 0 | 100.00 -| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 -| 0123 |[Best Time to Buy and Sell Stock III](src/main/java/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/Solution.java)| Hard | Array, Dynamic_Programming | 4 | 74.67 -| 0188 |[Best Time to Buy and Sell Stock IV](src/main/java/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/Solution.java)| Hard | Array, Dynamic_Programming | 1 | 99.73 -| 0221 |[Maximal Square](src/main/java/g0201_0300/s0221_maximal_square/Solution.java)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 6 | 97.07 +| 0152 |[Maximum Product Subarray](src/main/java/g0101_0200/s0152_maximum_product_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 92.74 +| 1567 |[Maximum Length of Subarray With Positive Product](src/main/java/g1501_1600/s1567_maximum_length_of_subarray_with_positive_product/Solution.java)| Medium | Array, Dynamic_Programming, Greedy | 4 | 80.86 -### Data Structure I +#### Day 7 -#### Day 1 Array +| | | | | | +|-|-|-|-|-|- +| 1014 |[Best Sightseeing Pair](src/main/java/g1001_1100/s1014_best_sightseeing_pair/Solution.java)| Medium | Array, Dynamic_Programming | 2 | 99.86 +| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 1 | 76.91 + +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0217 |[Contains Duplicate](src/main/java/g0201_0300/s0217_contains_duplicate/Solution.java)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 6 | 96.68 -| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 +| 0309 |[Best Time to Buy and Sell Stock with Cooldown](src/main/java/g0301_0400/s0309_best_time_to_buy_and_sell_stock_with_cooldown/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 +| 0714 |[Best Time to Buy and Sell Stock with Transaction Fee](src/main/java/g0701_0800/s0714_best_time_to_buy_and_sell_stock_with_transaction_fee/Solution.java)| Medium | Array, Dynamic_Programming, Greedy, LeetCode_75_DP/Multidimensional | 4 | 78.57 -#### Day 2 Array +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 -| 0088 |[Merge Sorted Array](src/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 0 | 100.00 +| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 +| 0042 |[Trapping Rain Water](src/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -#### Day 3 Array +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0350 |[Intersection of Two Arrays II](src/main/java/g0301_0400/s0350_intersection_of_two_arrays_ii/Solution.java)| Easy | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 4 | 69.62 -| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 +| 0413 |[Arithmetic Slices](src/main/java/g0401_0500/s0413_arithmetic_slices/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 +| 0091 |[Decode Ways](src/main/java/g0001_0100/s0091_decode_ways/Solution.java)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 2 | 66.37 -#### Day 4 Array +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0566 |[Reshape the Matrix](src/main/java/g0501_0600/s0566_reshape_the_matrix/Solution.java)| Easy | Array, Matrix, Simulation | 1 | 90.08 -| 0118 |[Pascal's Triangle](src/main/java/g0101_0200/s0118_pascals_triangle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 1 | 67.08 +| 0264 |[Ugly Number II](src/main/java/g0201_0300/s0264_ugly_number_ii/Solution.java)| Medium | Hash_Table, Dynamic_Programming, Math, Heap_Priority_Queue | 2 | 99.91 +| 0096 |[Unique Binary Search Trees](src/main/java/g0001_0100/s0096_unique_binary_search_trees/Solution.java)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -#### Day 5 Array +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0036 |[Valid Sudoku](src/main/java/g0001_0100/s0036_valid_sudoku/Solution.java)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 1 | 100.00 -| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0118 |[Pascal's Triangle](src/main/java/g0101_0200/s0118_pascals_triangle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 1 | 67.08 +| 0119 |[Pascal's Triangle II](src/main/java/g0101_0200/s0119_pascals_triangle_ii/Solution.java)| Easy | Array, Dynamic_Programming | 0 | 100.00 -#### Day 6 String +#### Day 13 | | | | | | |-|-|-|-|-|- -| 0387 |[First Unique Character in a String](src/main/java/g0301_0400/s0387_first_unique_character_in_a_string/Solution.java)| Easy | String, Hash_Table, Counting, Queue | 1 | 100.00 -| 0383 |[Ransom Note](src/main/java/g0301_0400/s0383_ransom_note/Solution.java)| Easy | String, Hash_Table, Counting | 1 | 99.10 -| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 +| 0931 |[Minimum Falling Path Sum](src/main/java/g0901_1000/s0931_minimum_falling_path_sum/Solution.java)| Medium | Array, Dynamic_Programming, Matrix | 4 | 72.19 +| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 -#### Day 7 Linked List +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0141 |[Linked List Cycle](src/main/java/g0101_0200/s0141_linked_list_cycle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 -| 0203 |[Remove Linked List Elements](src/main/java/g0201_0300/s0203_remove_linked_list_elements/Solution.java)| Easy | Linked_List, Recursion | 1 | 98.82 +| 1314 |[Matrix Block Sum](src/main/java/g1301_1400/s1314_matrix_block_sum/Solution.java)| Medium | Array, Matrix, Prefix_Sum | 5 | 67.46 +| 0304 |[Range Sum Query 2D - Immutable](src/main/java/g0301_0400/s0304_range_sum_query_2d_immutable/NumMatrix.java)| Medium | Array, Matrix, Design, Prefix_Sum | 153 | 87.51 -#### Day 8 Linked List +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -| 0083 |[Remove Duplicates from Sorted List](src/main/java/g0001_0100/s0083_remove_duplicates_from_sorted_list/Solution.java)| Easy | Linked_List | 0 | 100.00 +| 0062 |[Unique Paths](src/main/java/g0001_0100/s0062_unique_paths/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 0063 |[Unique Paths II](src/main/java/g0001_0100/s0063_unique_paths_ii/Solution.java)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 -#### Day 9 Stack Queue +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0020 |[Valid Parentheses](src/main/java/g0001_0100/s0020_valid_parentheses/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 2 | 97.19 -| 0232 |[Implement Queue using Stacks](src/main/java/g0201_0300/s0232_implement_queue_using_stacks/MyQueue.java)| Easy | Stack, Design, Queue | 1 | 67.21 +| 0064 |[Minimum Path Sum](src/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 1 | 99.73 +| 0221 |[Maximal Square](src/main/java/g0201_0300/s0221_maximal_square/Solution.java)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 6 | 97.07 -#### Day 10 Tree +#### Day 17 | | | | | | |-|-|-|-|-|- -| 0144 |[Binary Tree Preorder Traversal](src/main/java/g0101_0200/s0144_binary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 48.38 -| 0094 |[Binary Tree Inorder Traversal](src/main/java/g0001_0100/s0094_binary_tree_inorder_traversal/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0145 |[Binary Tree Postorder Traversal](src/main/java/g0101_0200/s0145_binary_tree_postorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 49.11 +| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 +| 0516 |[Longest Palindromic Subsequence](src/main/java/g0501_0600/s0516_longest_palindromic_subsequence/Solution.java)| Medium | String, Dynamic_Programming | 88 | 58.87 -#### Day 11 Tree +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 -| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 -| 0101 |[Symmetric Tree](src/main/java/g0101_0200/s0101_symmetric_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 +| 0376 |[Wiggle Subsequence](src/main/java/g0301_0400/s0376_wiggle_subsequence/Solution.java)| Medium | Array, Dynamic_Programming, Greedy | 0 | 100.00 -#### Day 12 Tree +#### Day 19 | | | | | | |-|-|-|-|-|- -| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0112 |[Path Sum](src/main/java/g0101_0200/s0112_path_sum/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 +| 1143 |[Longest Common Subsequence](src/main/java/g1101_1200/s1143_longest_common_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 19 | 89.05 +| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 -#### Day 13 Tree +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0700 |[Search in a Binary Search Tree](src/main/java/g0601_0700/s0700_search_in_a_binary_search_tree/Solution.java)| Easy | Tree, Binary_Tree, Binary_Search_Tree, LeetCode_75_Binary_Search_Tree | 0 | 100.00 -| 0701 |[Insert into a Binary Search Tree](src/main/java/g0701_0800/s0701_insert_into_a_binary_search_tree/Solution.java)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 +| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 +| 0518 |[Coin Change 2](src/main/java/g0501_0600/s0518_coin_change_2/Solution.java)| Medium | Array, Dynamic_Programming | 4 | 84.67 -#### Day 14 Tree +#### Day 21 | | | | | | |-|-|-|-|-|- -| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -| 0653 |[Two Sum IV - Input is a BST](src/main/java/g0601_0700/s0653_two_sum_iv_input_is_a_bst/Solution.java)| Easy | Hash_Table, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Two_Pointers, Binary_Search_Tree | 5 | 74.23 -| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/java/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 4 | 100.00 +| 0377 |[Combination Sum IV](src/main/java/g0301_0400/s0377_combination_sum_iv/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 92.54 +| 0343 |[Integer Break](src/main/java/g0301_0400/s0343_integer_break/Solution.java)| Medium | Dynamic_Programming, Math | 0 | 100.00 +| 0279 |[Perfect Squares](src/main/java/g0201_0300/s0279_perfect_squares/Solution.java)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Breadth_First_Search | 1 | 100.00 -### Data Structure II +### Programming Skills I -#### Day 1 Array +#### Day 1 Basic Data Type | | | | | | |-|-|-|-|-|- -| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 -| 0169 |[Majority Element](src/main/java/g0101_0200/s0169_majority_element/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.89 -| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 +| 1523 |[Count Odd Numbers in an Interval Range](src/main/java/g1501_1600/s1523_count_odd_numbers_in_an_interval_range/Solution.java)| Easy | Math | 0 | 100.00 +| 1491 |[Average Salary Excluding the Minimum and Maximum Salary](src/main/java/g1401_1500/s1491_average_salary_excluding_the_minimum_and_maximum_salary/Solution.java)| Easy | Array, Sorting | 0 | 100.00 -#### Day 2 Array +#### Day 2 Operator | | | | | | |-|-|-|-|-|- -| 0075 |[Sort Colors](src/main/java/g0001_0100/s0075_sort_colors/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 -| 0706 |[Design HashMap](src/main/java/g0701_0800/s0706_design_hashmap/MyHashMap.java)| Easy | Array, Hash_Table, Design, Linked_List, Hash_Function | 13 | 95.71 +| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 +| 1281 |[Subtract the Product and Sum of Digits of an Integer](src/main/java/g1201_1300/s1281_subtract_the_product_and_sum_of_digits_of_an_integer/Solution.java)| Easy | Math | 0 | 100.00 -#### Day 3 Array +#### Day 3 Conditional Statements | | | | | | |-|-|-|-|-|- -| 0119 |[Pascal's Triangle II](src/main/java/g0101_0200/s0119_pascals_triangle_ii/Solution.java)| Easy | Array, Dynamic_Programming | 0 | 100.00 -| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 -| 0059 |[Spiral Matrix II](src/main/java/g0001_0100/s0059_spiral_matrix_ii/Solution.java)| Medium | Array, Matrix, Simulation | 0 | 100.00 +| 0976 |[Largest Perimeter Triangle](src/main/java/g0901_1000/s0976_largest_perimeter_triangle/Solution.java)| Easy | Array, Math, Sorting, Greedy | 7 | 99.33 +| 1779 |[Find Nearest Point That Has the Same X or Y Coordinate](src/main/java/g1701_1800/s1779_find_nearest_point_that_has_the_same_x_or_y_coordinate/Solution.java)| Easy | Array | 1 | 100.00 -#### Day 4 Array +#### Day 4 Loop | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/java/g0201_0300/s0240_search_a_2d_matrix_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 5 | 99.92 -| 0435 |[Non-overlapping Intervals](src/main/java/g0401_0500/s0435_non_overlapping_intervals/Solution.java)| Medium | Array, Dynamic_Programming, Sorting, Greedy, LeetCode_75_Intervals | 96 | 47.37 +| 1822 |[Sign of the Product of an Array](src/main/java/g1801_1900/s1822_sign_of_the_product_of_an_array/Solution.java)| Easy | Array, Math | 1 | 58.05 +| 1502 |[Can Make Arithmetic Progression From Sequence](src/main/java/g1501_1600/s1502_can_make_arithmetic_progression_from_sequence/Solution.java)| Easy | Array, Sorting | 2 | 90.55 +| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 +| 1790 |[Check if One String Swap Can Make Strings Equal](src/main/java/g1701_1800/s1790_check_if_one_string_swap_can_make_strings_equal/Solution.java)| Easy | String, Hash_Table, Counting | 0 | 100.00 -#### Day 5 Array +#### Day 5 Function | | | | | | |-|-|-|-|-|- -| 0334 |[Increasing Triplet Subsequence](src/main/java/g0301_0400/s0334_increasing_triplet_subsequence/Solution.java)| Medium | Array, Greedy, LeetCode_75_Array/String | 2 | 99.33 -| 0238 |[Product of Array Except Self](src/main/java/g0201_0300/s0238_product_of_array_except_self/Solution.java)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 1 | 99.66 -| 0560 |[Subarray Sum Equals K](src/main/java/g0501_0600/s0560_subarray_sum_equals_k/Solution.java)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 22 | 95.17 +| 0589 |[N-ary Tree Preorder Traversal](src/main/java/g0501_0600/s0589_n_ary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Stack | 1 | 90.98 +| 0496 |[Next Greater Element I](src/main/java/g0401_0500/s0496_next_greater_element_i/Solution.java)| Easy | Array, Hash_Table, Stack, Monotonic_Stack | 4 | 81.18 +| 1232 |[Check If It Is a Straight Line](src/main/java/g1201_1300/s1232_check_if_it_is_a_straight_line/Solution.java)| Easy | Array, Math, Geometry | 0 | 100.00 -#### Day 6 String +#### Day 6 Array | | | | | | |-|-|-|-|-|- -| 0415 |[Add Strings](src/main/java/g0401_0500/s0415_add_strings/Solution.java)| Easy | String, Math, Simulation | 3 | 82.41 -| 0409 |[Longest Palindrome](src/main/java/g0401_0500/s0409_longest_palindrome/Solution.java)| Easy | String, Hash_Table, Greedy | 2 | 92.90 +| 1588 |[Sum of All Odd Length Subarrays](src/main/java/g1501_1600/s1588_sum_of_all_odd_length_subarrays/Solution.java)| Easy | Array, Math, Prefix_Sum | 0 | 100.00 +| 0283 |[Move Zeroes](src/main/java/g0201_0300/s0283_move_zeroes/Solution.java)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 83.99 +| 1672 |[Richest Customer Wealth](src/main/java/g1601_1700/s1672_richest_customer_wealth/Solution.java)| Easy | Array, Matrix | 0 | 100.00 -#### Day 7 String +#### Day 7 Array | | | | | | |-|-|-|-|-|- -| 0290 |[Word Pattern](src/main/java/g0201_0300/s0290_word_pattern/Solution.java)| Easy | String, Hash_Table | 0 | 100.00 -| 0763 |[Partition Labels](src/main/java/g0701_0800/s0763_partition_labels/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 100.00 +| 1572 |[Matrix Diagonal Sum](src/main/java/g1501_1600/s1572_matrix_diagonal_sum/Solution.java)| Easy | Array, Matrix | 0 | 100.00 +| 0566 |[Reshape the Matrix](src/main/java/g0501_0600/s0566_reshape_the_matrix/Solution.java)| Easy | Array, Matrix, Simulation | 1 | 90.08 #### Day 8 String | | | | | | |-|-|-|-|-|- -| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 -| 0043 |[Multiply Strings](src/main/java/g0001_0100/s0043_multiply_strings/Solution.java)| Medium | String, Math, Simulation | 1 | 100.00 +| 1768 |[Merge Strings Alternately](src/main/java/g1701_1800/s1768_merge_strings_alternately/Solution.java)| Easy | String, Two_Pointers, LeetCode_75_Array/String | 1 | 86.26 +| 1678 |[Goal Parser Interpretation](src/main/java/g1601_1700/s1678_goal_parser_interpretation/Solution.java)| Easy | String | 0 | 100.00 +| 0389 |[Find the Difference](src/main/java/g0301_0400/s0389_find_the_difference/Solution.java)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 1 | 100.00 #### Day 9 String | | | | | | |-|-|-|-|-|- -| 0187 |[Repeated DNA Sequences](src/main/java/g0101_0200/s0187_repeated_dna_sequences/Solution.java)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 29 | 77.11 -| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 +| 0709 |[To Lower Case](src/main/java/g0701_0800/s0709_to_lower_case/Solution.java)| Easy | String | 1 | 71.74 +| 1309 |[Decrypt String from Alphabet to Integer Mapping](src/main/java/g1301_1400/s1309_decrypt_string_from_alphabet_to_integer_mapping/Solution.java)| Easy | String | 0 | 100.00 +| 0953 |[Verifying an Alien Dictionary](src/main/java/g0901_1000/s0953_verifying_an_alien_dictionary/Solution.java)| Easy | Array, String, Hash_Table | 0 | 100.00 -#### Day 10 Linked List +#### Day 10 Linked List and Tree | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/java/g0001_0100/s0002_add_two_numbers/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 1 | 100.00 -| 0142 |[Linked List Cycle II](src/main/java/g0101_0200/s0142_linked_list_cycle_ii/Solution.java)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 1290 |[Convert Binary Number in a Linked List to Integer](src/main/java/g1201_1300/s1290_convert_binary_number_in_a_linked_list_to_integer/Solution.java)| Easy | Math, Linked_List | 0 | 100.00 +| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 +| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0404 |[Sum of Left Leaves](src/main/java/g0401_0500/s0404_sum_of_left_leaves/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 1 | 29.26 -#### Day 11 Linked List +#### Day 11 Containers and Libraries | | | | | | |-|-|-|-|-|- -| 0160 |[Intersection of Two Linked Lists](src/main/java/g0101_0200/s0160_intersection_of_two_linked_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 1 | 99.92 -| 0082 |[Remove Duplicates from Sorted List II](src/main/java/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 1356 |[Sort Integers by The Number of 1 Bits](src/main/java/g1301_1400/s1356_sort_integers_by_the_number_of_1_bits/Solution.java)| Easy | Array, Sorting, Bit_Manipulation, Counting | 10 | 65.50 +| 0232 |[Implement Queue using Stacks](src/main/java/g0201_0300/s0232_implement_queue_using_stacks/MyQueue.java)| Easy | Stack, Design, Queue | 1 | 67.21 +| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 +| 0217 |[Contains Duplicate](src/main/java/g0201_0300/s0217_contains_duplicate/Solution.java)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 6 | 96.68 -#### Day 12 Linked List +#### Day 12 Class and Object | | | | | | |-|-|-|-|-|- -| 0024 |[Swap Nodes in Pairs](src/main/java/g0001_0100/s0024_swap_nodes_in_pairs/Solution.java)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0707 |[Design Linked List](src/main/java/g0701_0800/s0707_design_linked_list/MyLinkedList.java)| Medium | Design, Linked_List | 10 | 70.60 +| 1603 |[Design Parking System](src/main/java/g1601_1700/s1603_design_parking_system/ParkingSystem.java)| Easy | Design, Simulation, Counting | 8 | 76.16 +| 0303 |[Range Sum Query - Immutable](src/main/java/g0301_0400/s0303_range_sum_query_immutable/NumArray.java)| Easy | Array, Design, Prefix_Sum | 7 | 100.00 -#### Day 13 Linked List +### Programming Skills II + +#### Day 1 | | | | | | |-|-|-|-|-|- -| 0025 |[Reverse Nodes in k-Group](src/main/java/g0001_0100/s0025_reverse_nodes_in_k_group/Solution.java)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 -| 0143 |[Reorder List](src/main/java/g0101_0200/s0143_reorder_list/Solution.java)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 2 | 72.59 +| 0896 |[Monotonic Array](src/main/java/g0801_0900/s0896_monotonic_array/Solution.java)| Easy | Array | 2 | 86.21 +| 0028 |[Find the Index of the First Occurrence in a String](src/main/java/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 -#### Day 14 Stack Queue +#### Day 2 | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 -| 1249 |[Minimum Remove to Make Valid Parentheses](src/main/java/g1201_1300/s1249_minimum_remove_to_make_valid_parentheses/Solution.java)| Medium | String, Stack | 13 | 94.62 -| 1823 |[Find the Winner of the Circular Game](src/main/java/g1801_1900/s1823_find_the_winner_of_the_circular_game/Solution.java)| Medium | Array, Math, Simulation, Recursion, Queue | 3 | 64.85 +| 0110 |[Balanced Binary Tree](src/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree | 1 | 98.82 +| 0459 |[Repeated Substring Pattern](src/main/java/g0401_0500/s0459_repeated_substring_pattern/Solution.java)| Easy | String, String_Matching | 8 | 96.64 -#### Day 15 Tree +#### Day 3 | | | | | | |-|-|-|-|-|- -| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 -| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/java/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 1 | 96.33 -| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/java/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/Solution.java)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0150 |[Evaluate Reverse Polish Notation](src/main/java/g0101_0200/s0150_evaluate_reverse_polish_notation/Solution.java)| Medium | Top_Interview_Questions, Array, Math, Stack | 6 | 76.50 +| 0066 |[Plus One](src/main/java/g0001_0100/s0066_plus_one/Solution.java)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 -#### Day 16 Tree +#### Day 4 | | | | | | |-|-|-|-|-|- -| 0199 |[Binary Tree Right Side View](src/main/java/g0101_0200/s0199_binary_tree_right_side_view/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 -| 0113 |[Path Sum II](src/main/java/g0101_0200/s0113_path_sum_ii/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree, Backtracking | 1 | 100.00 -| 0450 |[Delete Node in a BST](src/main/java/g0401_0500/s0450_delete_node_in_a_bst/Solution.java)| Medium | Tree, Binary_Tree, Binary_Search_Tree, LeetCode_75_Binary_Search_Tree | 0 | 100.00 +| 1367 |[Linked List in Binary Tree](src/main/java/g1301_1400/s1367_linked_list_in_binary_tree/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 2 | 61.23 +| 0043 |[Multiply Strings](src/main/java/g0001_0100/s0043_multiply_strings/Solution.java)| Medium | String, Math, Simulation | 1 | 100.00 -#### Day 17 Tree +#### Day 5 | | | | | | |-|-|-|-|-|- -| 0230 |[Kth Smallest Element in a BST](src/main/java/g0201_0300/s0230_kth_smallest_element_in_a_bst/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 +| 0067 |[Add Binary](src/main/java/g0001_0100/s0067_add_binary/Solution.java)| Easy | String, Math, Bit_Manipulation, Simulation | 1 | 99.82 +| 0989 |[Add to Array-Form of Integer](src/main/java/g0901_1000/s0989_add_to_array_form_of_integer/Solution.java)| Easy | Array, Math | 7 | 65.92 -#### Day 18 Tree +#### Day 6 | | | | | | |-|-|-|-|-|- -| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/java/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 6 | 100.00 -| 0297 |[Serialize and Deserialize Binary Tree](src/main/java/g0201_0300/s0297_serialize_and_deserialize_binary_tree/Codec.java)| Hard | String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 7 | 98.13 +| 0739 |[Daily Temperatures](src/main/java/g0701_0800/s0739_daily_temperatures/Solution.java)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, LeetCode_75_Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 8 | 96.83 +| 0058 |[Length of Last Word](src/main/java/g0001_0100/s0058_length_of_last_word/Solution.java)| Easy | String | 0 | 100.00 -#### Day 19 Graph +#### Day 7 | | | | | | |-|-|-|-|-|- -| 0997 |[Find the Town Judge](src/main/java/g0901_1000/s0997_find_the_town_judge/Solution.java)| Easy | Array, Hash_Table, Graph | 3 | 80.64 -| 1557 |[Minimum Number of Vertices to Reach All Nodes](src/main/java/g1501_1600/s1557_minimum_number_of_vertices_to_reach_all_nodes/Solution.java)| Medium | Graph | 8 | 99.94 -| 0841 |[Keys and Rooms](src/main/java/g0801_0900/s0841_keys_and_rooms/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, LeetCode_75_Graphs/DFS | 3 | 51.54 +| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 +| 1886 |[Determine Whether Matrix Can Be Obtained By Rotation](src/main/java/g1801_1900/s1886_determine_whether_matrix_can_be_obtained_by_rotation/Solution.java)| Easy | Array, Matrix | 1 | 78.38 -#### Day 20 Heap Priority Queue +#### Day 8 | | | | | | |-|-|-|-|-|- -| 0215 |[Kth Largest Element in an Array](src/main/java/g0201_0300/s0215_kth_largest_element_in_an_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, LeetCode_75_Heap/Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 5 | 70.82 -| 0347 |[Top K Frequent Elements](src/main/java/g0301_0400/s0347_top_k_frequent_elements/Solution.java)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 9 | 97.30 +| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 +| 0973 |[K Closest Points to Origin](src/main/java/g0901_1000/s0973_k_closest_points_to_origin/Solution.java)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 4 | 98.26 -#### Day 21 Heap Priority Queue +#### Day 9 | | | | | | |-|-|-|-|-|- -| 0451 |[Sort Characters By Frequency](src/main/java/g0401_0500/s0451_sort_characters_by_frequency/Solution.java)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Bucket_Sort | 13 | 89.63 -| 0973 |[K Closest Points to Origin](src/main/java/g0901_1000/s0973_k_closest_points_to_origin/Solution.java)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 4 | 98.26 - -### Algorithm I +| 1630 |[Arithmetic Subarrays](src/main/java/g1601_1700/s1630_arithmetic_subarrays/Solution.java)| Medium | Array, Sorting | 8 | 93.62 +| 0429 |[N-ary Tree Level Order Traversal](src/main/java/g0401_0500/s0429_n_ary_tree_level_order_traversal/Solution.java)| Medium | Breadth_First_Search, Tree | 3 | 80.26 -#### Day 1 Binary Search +#### Day 10 | | | | | | |-|-|-|-|-|- -| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 -| 0278 |[First Bad Version](src/main/java/g0201_0300/s0278_first_bad_version/Solution.java)| Easy | Binary_Search, Interactive | 15 | 87.89 -| 0035 |[Search Insert Position](src/main/java/g0001_0100/s0035_search_insert_position/Solution.java)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0503 |[Next Greater Element II](src/main/java/g0501_0600/s0503_next_greater_element_ii/Solution.java)| Medium | Array, Stack, Monotonic_Stack | 7 | 97.03 +| 0556 |[Next Greater Element III](src/main/java/g0501_0600/s0556_next_greater_element_iii/Solution.java)| Medium | String, Math, Two_Pointers | 0 | 100.00 -#### Day 2 Two Pointers +#### Day 11 | | | | | | |-|-|-|-|-|- -| 0977 |[Squares of a Sorted Array](src/main/java/g0901_1000/s0977_squares_of_a_sorted_array/Solution.java)| Easy | Array, Sorting, Two_Pointers | 1 | 100.00 -| 0189 |[Rotate Array](src/main/java/g0101_0200/s0189_rotate_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 1376 |[Time Needed to Inform All Employees](src/main/java/g1301_1400/s1376_time_needed_to_inform_all_employees/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree | 8 | 99.85 +| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 -#### Day 3 Two Pointers +#### Day 12 | | | | | | |-|-|-|-|-|- -| 0283 |[Move Zeroes](src/main/java/g0201_0300/s0283_move_zeroes/Solution.java)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 83.99 -| 0167 |[Two Sum II - Input Array Is Sorted](src/main/java/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers | 2 | 92.62 +| 0438 |[Find All Anagrams in a String](src/main/java/g0401_0500/s0438_find_all_anagrams_in_a_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 3 | 99.83 +| 0713 |[Subarray Product Less Than K](src/main/java/g0701_0800/s0713_subarray_product_less_than_k/Solution.java)| Medium | Array, Sliding_Window | 8 | 39.00 -#### Day 4 Two Pointers +#### Day 13 | | | | | | |-|-|-|-|-|- -| 0344 |[Reverse String](src/main/java/g0301_0400/s0344_reverse_string/Solution.java)| Easy | String, Two_Pointers, Recursion | 1 | 99.91 -| 0557 |[Reverse Words in a String III](src/main/java/g0501_0600/s0557_reverse_words_in_a_string_iii/Solution.java)| Easy | String, Two_Pointers | 4 | 97.75 +| 0304 |[Range Sum Query 2D - Immutable](src/main/java/g0301_0400/s0304_range_sum_query_2d_immutable/NumMatrix.java)| Medium | Array, Matrix, Design, Prefix_Sum | 153 | 87.51 +| 0910 |[Smallest Range II](src/main/java/g0901_1000/s0910_smallest_range_ii/Solution.java)| Medium | Array, Math, Sorting, Greedy | 10 | 73.16 -#### Day 5 Two Pointers +#### Day 14 | | | | | | |-|-|-|-|-|- -| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 -| 0019 |[Remove Nth Node From End of List](src/main/java/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 +| 0143 |[Reorder List](src/main/java/g0101_0200/s0143_reorder_list/Solution.java)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 2 | 72.59 +| 0138 |[Copy List with Random Pointer](src/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 -#### Day 6 Sliding Window +#### Day 15 | | | | | | |-|-|-|-|-|- -| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 -| 0567 |[Permutation in String](src/main/java/g0501_0600/s0567_permutation_in_string/Solution.java)| Medium | String, Hash_Table, Two_Pointers, Sliding_Window | 5 | 93.93 +| 0002 |[Add Two Numbers](src/main/java/g0001_0100/s0002_add_two_numbers/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 1 | 100.00 +| 0445 |[Add Two Numbers II](src/main/java/g0401_0500/s0445_add_two_numbers_ii/Solution.java)| Medium | Math, Stack, Linked_List | 3 | 90.38 -#### Day 7 Breadth First Search Depth First Search +#### Day 16 | | | | | | |-|-|-|-|-|- -| 0733 |[Flood Fill](src/main/java/g0701_0800/s0733_flood_fill/Solution.java)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 1 | 85.36 -| 0695 |[Max Area of Island](src/main/java/g0601_0700/s0695_max_area_of_island/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 3 | 76.79 +| 0061 |[Rotate List](src/main/java/g0001_0100/s0061_rotate_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 -#### Day 8 Breadth First Search Depth First Search +#### Day 17 | | | | | | |-|-|-|-|-|- -| 0617 |[Merge Two Binary Trees](src/main/java/g0601_0700/s0617_merge_two_binary_trees/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 1 | 72.47 -| 0116 |[Populating Next Right Pointers in Each Node](src/main/java/g0101_0200/s0116_populating_next_right_pointers_in_each_node/Solution.java)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 0 | 100.00 +| 1845 |[Seat Reservation Manager](src/main/java/g1801_1900/s1845_seat_reservation_manager/SeatManager.java)| Medium | Design, Heap_Priority_Queue | 47 | 87.63 +| 0860 |[Lemonade Change](src/main/java/g0801_0900/s0860_lemonade_change/Solution.java)| Easy | Array, Greedy | 2 | 90.84 -#### Day 9 Breadth First Search Depth First Search +#### Day 18 | | | | | | |-|-|-|-|-|- -| 0542 |[01 Matrix](src/main/java/g0501_0600/s0542_01_matrix/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 7 | 95.83 -| 0994 |[Rotting Oranges](src/main/java/g0901_1000/s0994_rotting_oranges/Solution.java)| Medium | Top_100_Liked_Questions, Array, Breadth_First_Search, Matrix, LeetCode_75_Graphs/BFS | 3 | 74.27 +| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 +| 0341 |[Flatten Nested List Iterator](src/main/java/g0301_0400/s0341_flatten_nested_list_iterator/NestedIterator.java)| Medium | Depth_First_Search, Tree, Stack, Design, Queue, Iterator | 2 | 99.95 -#### Day 10 Recursion Backtracking +#### Day 19 | | | | | | |-|-|-|-|-|- -| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 -| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 1797 |[Design Authentication Manager](src/main/java/g1701_1800/s1797_design_authentication_manager/AuthenticationManager.java)| Medium | Hash_Table, Design | 41 | 92.67 +| 0707 |[Design Linked List](src/main/java/g0701_0800/s0707_design_linked_list/MyLinkedList.java)| Medium | Design, Linked_List | 10 | 70.60 -#### Day 11 Recursion Backtracking +#### Day 20 | | | | | | |-|-|-|-|-|- -| 0077 |[Combinations](src/main/java/g0001_0100/s0077_combinations/Solution.java)| Medium | Backtracking | 15 | 92.38 -| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 -| 0784 |[Letter Case Permutation](src/main/java/g0701_0800/s0784_letter_case_permutation/Solution.java)| Medium | String, Bit_Manipulation, Backtracking | 10 | 40.38 +| 0380 |[Insert Delete GetRandom O(1)](src/main/java/g0301_0400/s0380_insert_delete_getrandom_o1/RandomizedSet.java)| Medium | Array, Hash_Table, Math, Design, Randomized | 27 | 93.44 +| 0622 |[Design Circular Queue](src/main/java/g0601_0700/s0622_design_circular_queue/MyCircularQueue.java)| Medium | Array, Design, Linked_List, Queue | 3 | 100.00 +| 0729 |[My Calendar I](src/main/java/g0701_0800/s0729_my_calendar_i/MyCalendar.java)| Medium | Binary_Search, Design, Ordered_Set, Segment_Tree | 17 | 97.23 -#### Day 12 Dynamic Programming +### Graph Theory I + +#### Day 1 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 +| 0733 |[Flood Fill](src/main/java/g0701_0800/s0733_flood_fill/Solution.java)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 1 | 85.36 +| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 -#### Day 13 Bit Manipulation +#### Day 2 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0231 |[Power of Two](src/main/java/g0201_0300/s0231_power_of_two/Solution.java)| Easy | Math, Bit_Manipulation, Recursion | 1 | 100.00 -| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 +| 0695 |[Max Area of Island](src/main/java/g0601_0700/s0695_max_area_of_island/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 3 | 76.79 +| 1254 |[Number of Closed Islands](src/main/java/g1201_1300/s1254_number_of_closed_islands/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 3 | 55.59 -#### Day 14 Bit Manipulation +#### Day 3 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0190 |[Reverse Bits](src/main/java/g0101_0200/s0190_reverse_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 0 | 100.00 -| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 - -### Algorithm II +| 1020 |[Number of Enclaves](src/main/java/g1001_1100/s1020_number_of_enclaves/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 6 | 68.24 +| 1905 |[Count Sub Islands](src/main/java/g1901_2000/s1905_count_sub_islands/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 24 | 85.54 -#### Day 1 Binary Search +#### Day 4 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 1162 |[As Far from Land as Possible](src/main/java/g1101_1200/s1162_as_far_from_land_as_possible/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 16 | 62.40 +| 0417 |[Pacific Atlantic Water Flow](src/main/java/g0401_0500/s0417_pacific_atlantic_water_flow/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 5 | 92.62 -#### Day 2 Binary Search +#### Day 5 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 -| 0162 |[Find Peak Element](src/main/java/g0101_0200/s0162_find_peak_element/Solution.java)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 +| 1091 |[Shortest Path in Binary Matrix](src/main/java/g1001_1100/s1091_shortest_path_in_binary_matrix/Solution.java)| Medium | Array, Breadth_First_Search, Matrix | 22 | 69.99 +| 0542 |[01 Matrix](src/main/java/g0501_0600/s0542_01_matrix/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 7 | 95.83 -#### Day 3 Two Pointers +#### Day 6 Matrix Related Problems | | | | | | |-|-|-|-|-|- -| 0082 |[Remove Duplicates from Sorted List II](src/main/java/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 -| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 +| 0934 |[Shortest Bridge](src/main/java/g0901_1000/s0934_shortest_bridge/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 6 | 97.87 +| 1926 |[Nearest Exit from Entrance in Maze](src/main/java/g1901_2000/s1926_nearest_exit_from_entrance_in_maze/Solution.java)| Medium | Array, Breadth_First_Search, Matrix, LeetCode_75_Graphs/BFS | 12 | 40.55 -#### Day 4 Two Pointers +#### Day 7 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0844 |[Backspace String Compare](src/main/java/g0801_0900/s0844_backspace_string_compare/Solution.java)| Easy | String, Two_Pointers, Stack, Simulation | 0 | 100.00 -| 0986 |[Interval List Intersections](src/main/java/g0901_1000/s0986_interval_list_intersections/Solution.java)| Medium | Array, Two_Pointers | 2 | 99.95 -| 0011 |[Container With Most Water](src/main/java/g0001_0100/s0011_container_with_most_water/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 3 | 96.01 +| 0797 |[All Paths From Source to Target](src/main/java/g0701_0800/s0797_all_paths_from_source_to_target/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 2 | 90.53 +| 0841 |[Keys and Rooms](src/main/java/g0801_0900/s0841_keys_and_rooms/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, LeetCode_75_Graphs/DFS | 3 | 51.54 -#### Day 5 Sliding Window +#### Day 8 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/java/g0401_0500/s0438_find_all_anagrams_in_a_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 3 | 99.83 -| 0713 |[Subarray Product Less Than K](src/main/java/g0701_0800/s0713_subarray_product_less_than_k/Solution.java)| Medium | Array, Sliding_Window | 8 | 39.00 -| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 99.76 +| 0547 |[Number of Provinces](src/main/java/g0501_0600/s0547_number_of_provinces/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find, LeetCode_75_Graphs/DFS | 2 | 69.51 +| 1319 |[Number of Operations to Make Network Connected](src/main/java/g1301_1400/s1319_number_of_operations_to_make_network_connected/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 9 | 67.64 -#### Day 6 Breadth First Search Depth First Search +#### Day 9 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 -| 0547 |[Number of Provinces](src/main/java/g0501_0600/s0547_number_of_provinces/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find, LeetCode_75_Graphs/DFS | 2 | 69.51 +| 1376 |[Time Needed to Inform All Employees](src/main/java/g1301_1400/s1376_time_needed_to_inform_all_employees/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree | 8 | 99.85 +| 0802 |[Find Eventual Safe States](src/main/java/g0801_0900/s0802_find_eventual_safe_states/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 7 | 74.93 -#### Day 7 Breadth First Search Depth First Search +#### Day 10 Standard Traversal | | | | | | |-|-|-|-|-|- -| 0117 |[Populating Next Right Pointers in Each Node II](src/main/java/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 0 | 100.00 -| 0572 |[Subtree of Another Tree](src/main/java/g0501_0600/s0572_subtree_of_another_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Hash_Function, String_Matching | 2 | 97.06 +| 1129 |[Shortest Path with Alternating Colors](src/main/java/g1101_1200/s1129_shortest_path_with_alternating_colors/Solution.java)| Medium | Breadth_First_Search, Graph | 4 | 96.63 +| 1466 |[Reorder Routes to Make All Paths Lead to the City Zero](src/main/java/g1401_1500/s1466_reorder_routes_to_make_all_paths_lead_to_the_city_zero/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, LeetCode_75_Graphs/DFS | 39 | 97.71 +| 0847 |[Shortest Path Visiting All Nodes](src/main/java/g0801_0900/s0847_shortest_path_visiting_all_nodes/Solution.java)| Hard | Dynamic_Programming, Breadth_First_Search, Bit_Manipulation, Graph, Bitmask | 14 | 78.72 -#### Day 8 Breadth First Search Depth First Search +#### Day 11 Breadth First Search | | | | | | |-|-|-|-|-|- -| 1091 |[Shortest Path in Binary Matrix](src/main/java/g1001_1100/s1091_shortest_path_in_binary_matrix/Solution.java)| Medium | Array, Breadth_First_Search, Matrix | 22 | 69.99 -| 0130 |[Surrounded Regions](src/main/java/g0101_0200/s0130_surrounded_regions/Solution.java)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 2 | 84.66 -| 0797 |[All Paths From Source to Target](src/main/java/g0701_0800/s0797_all_paths_from_source_to_target/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 2 | 90.53 +| 1306 |[Jump Game III](src/main/java/g1301_1400/s1306_jump_game_iii/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search | 2 | 96.23 +| 1654 |[Minimum Jumps to Reach Home](src/main/java/g1601_1700/s1654_minimum_jumps_to_reach_home/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search | 6 | 99.87 +| 0365 |[Water and Jug Problem](src/main/java/g0301_0400/s0365_water_and_jug_problem/Solution.java)| Medium | Math, Depth_First_Search, Breadth_First_Search | 0 | 100.00 -#### Day 9 Recursion Backtracking +#### Day 12 Breadth First Search | | | | | | |-|-|-|-|-|- -| 0078 |[Subsets](src/main/java/g0001_0100/s0078_subsets/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 -| 0090 |[Subsets II](src/main/java/g0001_0100/s0090_subsets_ii/Solution.java)| Medium | Array, Bit_Manipulation, Backtracking | 2 | 82.94 +| 0433 |[Minimum Genetic Mutation](src/main/java/g0401_0500/s0433_minimum_genetic_mutation/Solution.java)| Medium | String, Hash_Table, Breadth_First_Search | 0 | 100.00 +| 0752 |[Open the Lock](src/main/java/g0701_0800/s0752_open_the_lock/Solution.java)| Medium | Array, String, Hash_Table, Breadth_First_Search | 72 | 91.06 +| 0127 |[Word Ladder](src/main/java/g0101_0200/s0127_word_ladder/Solution.java)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 22 | 96.00 -#### Day 10 Recursion Backtracking +#### Day 13 Graph Theory | | | | | | |-|-|-|-|-|- -| 0047 |[Permutations II](src/main/java/g0001_0100/s0047_permutations_ii/Solution.java)| Medium | Array, Backtracking | 1 | 99.86 -| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 -| 0040 |[Combination Sum II](src/main/java/g0001_0100/s0040_combination_sum_ii/Solution.java)| Medium | Array, Backtracking | 2 | 99.75 +| 0997 |[Find the Town Judge](src/main/java/g0901_1000/s0997_find_the_town_judge/Solution.java)| Easy | Array, Hash_Table, Graph | 3 | 80.64 +| 1557 |[Minimum Number of Vertices to Reach All Nodes](src/main/java/g1501_1600/s1557_minimum_number_of_vertices_to_reach_all_nodes/Solution.java)| Medium | Graph | 8 | 99.94 -#### Day 11 Recursion Backtracking +#### Day 14 Graph Theory | | | | | | |-|-|-|-|-|- -| 0017 |[Letter Combinations of a Phone Number](src/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 -| 0022 |[Generate Parentheses](src/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 0 | 100.00 -| 0079 |[Word Search](src/main/java/g0001_0100/s0079_word_search/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 64 | 98.51 +| 1615 |[Maximal Network Rank](src/main/java/g1601_1700/s1615_maximal_network_rank/Solution.java)| Medium | Graph | 3 | 97.34 +| 0886 |[Possible Bipartition](src/main/java/g0801_0900/s0886_possible_bipartition/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 20 | 80.12 +| 0785 |[Is Graph Bipartite?](src/main/java/g0701_0800/s0785_is_graph_bipartite/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 0 | 100.00 -#### Day 12 Dynamic Programming +### SQL I + +#### Day 1 Select | | | | | | |-|-|-|-|-|- -| 0213 |[House Robber II](src/main/java/g0201_0300/s0213_house_robber_ii/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 -| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 +| 0595 |[Big Countries](src/main/java/g0501_0600/s0595_big_countries/script.sql)| Easy | Database | 262 | 84.64 +| 1757 |[Recyclable and Low Fat Products](src/main/java/g1701_1800/s1757_recyclable_and_low_fat_products/script.sql)| Easy | Database | 475 | 71.54 +| 0584 |[Find Customer Referee](src/main/java/g0501_0600/s0584_find_customer_referee/script.sql)| Easy | Database | 531 | 58.63 +| 0183 |[Customers Who Never Order](src/main/java/g0101_0200/s0183_customers_who_never_order/script.sql)| Easy | Database | 376 | 98.73 -#### Day 13 Dynamic Programming +#### Day 2 Select and Order | | | | | | |-|-|-|-|-|- -| 0045 |[Jump Game II](src/main/java/g0001_0100/s0045_jump_game_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 -| 0062 |[Unique Paths](src/main/java/g0001_0100/s0062_unique_paths/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 +| 1873 |[Calculate Special Bonus](src/main/java/g1801_1900/s1873_calculate_special_bonus/script.sql)| Easy | Database | 543 | 71.60 +| 0627 |[Swap Salary](src/main/java/g0601_0700/s0627_swap_salary/script.sql)| Easy | Database | 191 | 96.89 +| 0196 |[Delete Duplicate Emails](src/main/java/g0101_0200/s0196_delete_duplicate_emails/script.sql)| Easy | Database | 903 | 48.10 -#### Day 14 Dynamic Programming +#### Day 3 String Processing Functions | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 -| 0413 |[Arithmetic Slices](src/main/java/g0401_0500/s0413_arithmetic_slices/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 +| 1667 |[Fix Names in a Table](src/main/java/g1601_1700/s1667_fix_names_in_a_table/script.sql)| Easy | Database | 559 | 80.29 +| 1484 |[Group Sold Products By The Date](src/main/java/g1401_1500/s1484_group_sold_products_by_the_date/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 395 | 77.20 +| 1527 |[Patients With a Condition](src/main/java/g1501_1600/s1527_patients_with_a_condition/script.sql)| Easy | Database | 308 | 66.93 -#### Day 15 Dynamic Programming +#### Day 4 Union and Select | | | | | | |-|-|-|-|-|- -| 0091 |[Decode Ways](src/main/java/g0001_0100/s0091_decode_ways/Solution.java)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 2 | 66.37 -| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 +| 1965 |[Employees With Missing Information](src/main/java/g1901_2000/s1965_employees_with_missing_information/script.sql)| Easy | Database | 617 | 30.40 +| 1795 |[Rearrange Products Table](src/main/java/g1701_1800/s1795_rearrange_products_table/script.sql)| Easy | Database | 497 | 64.83 +| 0608 |[Tree Node](src/main/java/g0601_0700/s0608_tree_node/script.sql)| Medium | LeetCode_Curated_SQL_70, Database | 347 | 95.17 +| 0176 |[Second Highest Salary](src/main/java/g0101_0200/s0176_second_highest_salary/script.sql)| Medium | Database | 225 | 73.10 -#### Day 16 Dynamic Programming +#### Day 5 Union | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 -| 0673 |[Number of Longest Increasing Subsequence](src/main/java/g0601_0700/s0673_number_of_longest_increasing_subsequence/Solution.java)| Medium | Array, Dynamic_Programming, Segment_Tree, Binary_Indexed_Tree | 25 | 68.75 +| 0175 |[Combine Two Tables](src/main/java/g0101_0200/s0175_combine_two_tables/script.sql)| Easy | Database | 491 | 32.30 +| 1581 |[Customer Who Visited but Did Not Make Any Transactions](src/main/java/g1501_1600/s1581_customer_who_visited_but_did_not_make_any_transactions/script.sql)| Easy | Database | 1039 | 76.99 +| 1148 |[Article Views I](src/main/java/g1101_1200/s1148_article_views_i/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 783 | 64.09 -#### Day 17 Dynamic Programming +#### Day 6 Union | | | | | | |-|-|-|-|-|- -| 1143 |[Longest Common Subsequence](src/main/java/g1101_1200/s1143_longest_common_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 19 | 89.05 -| 0583 |[Delete Operation for Two Strings](src/main/java/g0501_0600/s0583_delete_operation_for_two_strings/Solution.java)| Medium | String, Dynamic_Programming | 12 | 79.10 +| 0197 |[Rising Temperature](src/main/java/g0101_0200/s0197_rising_temperature/script.sql)| Easy | Database | 342 | 93.76 +| 0607 |[Sales Person](src/main/java/g0601_0700/s0607_sales_person/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 1046 | 86.04 -#### Day 18 Dynamic Programming +#### Day 7 Function | | | | | | |-|-|-|-|-|- -| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 -| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 -| 0343 |[Integer Break](src/main/java/g0301_0400/s0343_integer_break/Solution.java)| Medium | Dynamic_Programming, Math | 0 | 100.00 +| 1141 |[User Activity for the Past 30 Days I](src/main/java/g1101_1200/s1141_user_activity_for_the_past_30_days_i/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 849 | 72.54 +| 1693 |[Daily Leads and Partners](src/main/java/g1601_1700/s1693_daily_leads_and_partners/script.sql)| Easy | Database | 463 | 78.98 +| 1729 |[Find Followers Count](src/main/java/g1701_1800/s1729_find_followers_count/script.sql)| Easy | Database | 456 | 88.39 -#### Day 19 Bit Manipulation +#### Day 8 Function | | | | | | |-|-|-|-|-|- -| 0201 |[Bitwise AND of Numbers Range](src/main/java/g0201_0300/s0201_bitwise_and_of_numbers_range/Solution.java)| Medium | Bit_Manipulation | 3 | 100.00 +| 0586 |[Customer Placing the Largest Number of Orders](src/main/java/g0501_0600/s0586_customer_placing_the_largest_number_of_orders/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 484 | 66.42 +| 0511 |[Game Play Analysis I](src/main/java/g0501_0600/s0511_game_play_analysis_i/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 586 | 56.94 +| 1890 |[The Latest Login in 2020](src/main/java/g1801_1900/s1890_the_latest_login_in_2020/script.sql)| Easy | Database | 571 | 73.59 +| 1741 |[Find Total Time Spent by Each Employee](src/main/java/g1701_1800/s1741_find_total_time_spent_by_each_employee/script.sql)| Easy | Database | 414 | 93.27 -#### Day 20 Others +#### Day 9 Control of Flow | | | | | | |-|-|-|-|-|- -| 0384 |[Shuffle an Array](src/main/java/g0301_0400/s0384_shuffle_an_array/Solution.java)| Medium | Array, Math, Randomized | 52 | 91.77 +| 1393 |[Capital Gain/Loss](src/main/java/g1301_1400/s1393_capital_gainloss/script.sql)| Medium | LeetCode_Curated_SQL_70, Database | 428 | 92.01 +| 1407 |[Top Travellers](src/main/java/g1401_1500/s1407_top_travellers/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 682 | 70.16 +| 1158 |[Market Analysis I](src/main/java/g1101_1200/s1158_market_analysis_i/script.sql)| Medium | Database | 2511 | 78.92 -#### Day 21 Others +#### Day 10 Where | | | | | | |-|-|-|-|-|- -| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 -| 0149 |[Max Points on a Line](src/main/java/g0101_0200/s0149_max_points_on_a_line/Solution.java)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 7 | 99.18 +| 0182 |[Duplicate Emails](src/main/java/g0101_0200/s0182_duplicate_emails/script.sql)| Easy | Database | 303 | 92.08 +| 1050 |[Actors and Directors Who Cooperated At Least Three Times](src/main/java/g1001_1100/s1050_actors_and_directors_who_cooperated_at_least_three_times/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 344 | 76.48 +| 1587 |[Bank Account Summary II](src/main/java/g1501_1600/s1587_bank_account_summary_ii/script.sql)| Easy | Database | 630 | 60.32 +| 1084 |[Sales Analysis III](src/main/java/g1001_1100/s1084_sales_analysis_iii/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 1066 | 69.71 -### Binary Search I +### Level 1 -#### Day 1 +#### Day 1 Prefix Sum | | | | | | |-|-|-|-|-|- -| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 -| 0374 |[Guess Number Higher or Lower](src/main/java/g0301_0400/s0374_guess_number_higher_or_lower/Solution.java)| Easy | Binary_Search, Interactive, LeetCode_75_Binary_Search | 0 | 100.00 +| 1480 |[Running Sum of 1d Array](src/main/java/g1401_1500/s1480_running_sum_of_1d_array/Solution.java)| Easy | Array, Prefix_Sum | 0 | 100.00 +| 0724 |[Find Pivot Index](src/main/java/g0701_0800/s0724_find_pivot_index/Solution.java)| Easy | Array, Prefix_Sum, LeetCode_75_Prefix_Sum | 2 | 69.67 -#### Day 2 +#### Day 2 String | | | | | | |-|-|-|-|-|- -| 0035 |[Search Insert Position](src/main/java/g0001_0100/s0035_search_insert_position/Solution.java)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -| 0852 |[Peak Index in a Mountain Array](src/main/java/g0801_0900/s0852_peak_index_in_a_mountain_array/Solution.java)| Medium | Array, Binary_Search | 0 | 100.00 +| 0205 |[Isomorphic Strings](src/main/java/g0201_0300/s0205_isomorphic_strings/Solution.java)| Easy | String, Hash_Table | 2 | 99.18 +| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 -#### Day 3 +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- -| 0367 |[Valid Perfect Square](src/main/java/g0301_0400/s0367_valid_perfect_square/Solution.java)| Easy | Math, Binary_Search | 0 | 100.00 -| 1385 |[Find the Distance Value Between Two Arrays](src/main/java/g1301_1400/s1385_find_the_distance_value_between_two_arrays/Solution.java)| Easy | Array, Sorting, Binary_Search, Two_Pointers | 5 | 65.78 +| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -#### Day 4 +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- -| 0069 |[Sqrt(x)](src/main/java/g0001_0100/s0069_sqrtx/Solution.java)| Easy | Top_Interview_Questions, Math, Binary_Search | 1 | 86.67 -| 0744 |[Find Smallest Letter Greater Than Target](src/main/java/g0701_0800/s0744_find_smallest_letter_greater_than_target/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 +| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 +| 0142 |[Linked List Cycle II](src/main/java/g0101_0200/s0142_linked_list_cycle_ii/Solution.java)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -#### Day 5 +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- -| 0278 |[First Bad Version](src/main/java/g0201_0300/s0278_first_bad_version/Solution.java)| Easy | Binary_Search, Interactive | 15 | 87.89 -| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 +| 0409 |[Longest Palindrome](src/main/java/g0401_0500/s0409_longest_palindrome/Solution.java)| Easy | String, Hash_Table, Greedy | 2 | 92.90 -#### Day 6 +#### Day 6 Tree | | | | | | |-|-|-|-|-|- -| 0441 |[Arranging Coins](src/main/java/g0401_0500/s0441_arranging_coins/Solution.java)| Easy | Math, Binary_Search | 2 | 95.97 -| 1539 |[Kth Missing Positive Number](src/main/java/g1501_1600/s1539_kth_missing_positive_number/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 +| 0589 |[N-ary Tree Preorder Traversal](src/main/java/g0501_0600/s0589_n_ary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Stack | 1 | 90.98 +| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 -#### Day 7 +#### Day 7 Binary Search | | | | | | |-|-|-|-|-|- -| 0167 |[Two Sum II - Input Array Is Sorted](src/main/java/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers | 2 | 92.62 -| 1608 |[Special Array With X Elements Greater Than or Equal X](src/main/java/g1601_1700/s1608_special_array_with_x_elements_greater_than_or_equal_x/Solution.java)| Easy | Array, Sorting, Binary_Search | 2 | 61.14 +| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 +| 0278 |[First Bad Version](src/main/java/g0201_0300/s0278_first_bad_version/Solution.java)| Easy | Binary_Search, Interactive | 15 | 87.89 -#### Day 8 +#### Day 8 Binary Search Tree | | | | | | |-|-|-|-|-|- -| 1351 |[Count Negative Numbers in a Sorted Matrix](src/main/java/g1301_1400/s1351_count_negative_numbers_in_a_sorted_matrix/Solution.java)| Easy | Array, Binary_Search, Matrix | 1 | 49.66 -| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/java/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 4 | 100.00 -#### Day 9 +#### Day 9 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 1337 |[The K Weakest Rows in a Matrix](src/main/java/g1301_1400/s1337_the_k_weakest_rows_in_a_matrix/Solution.java)| Easy | Array, Sorting, Binary_Search, Matrix, Heap_Priority_Queue | 1 | 99.77 -| 1346 |[Check If N and Its Double Exist](src/main/java/g1301_1400/s1346_check_if_n_and_its_double_exist/Solution.java)| Easy | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 1 | 99.64 +| 0733 |[Flood Fill](src/main/java/g0701_0800/s0733_flood_fill/Solution.java)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 1 | 85.36 +| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 -#### Day 10 +#### Day 10 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0350 |[Intersection of Two Arrays II](src/main/java/g0301_0400/s0350_intersection_of_two_arrays_ii/Solution.java)| Easy | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 4 | 69.62 -| 0633 |[Sum of Square Numbers](src/main/java/g0601_0700/s0633_sum_of_square_numbers/Solution.java)| Medium | Math, Binary_Search, Two_Pointers | 4 | 82.92 +| 0509 |[Fibonacci Number](src/main/java/g0501_0600/s0509_fibonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 0 | 100.00 +| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -#### Day 11 +#### Day 11 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 1855 |[Maximum Distance Between a Pair of Values](src/main/java/g1801_1900/s1855_maximum_distance_between_a_pair_of_values/Solution.java)| Medium | Array, Greedy, Binary_Search, Two_Pointers | 4 | 62.20 -| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0746 |[Min Cost Climbing Stairs](src/main/java/g0701_0800/s0746_min_cost_climbing_stairs/Solution.java)| Easy | Array, Dynamic_Programming, LeetCode_75_DP/1D | 1 | 86.38 +| 0062 |[Unique Paths](src/main/java/g0001_0100/s0062_unique_paths/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 -#### Day 12 +#### Day 12 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- -| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 - -### Binary Search II +| 0438 |[Find All Anagrams in a String](src/main/java/g0401_0500/s0438_find_all_anagrams_in_a_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 3 | 99.83 +| 0424 |[Longest Repeating Character Replacement](src/main/java/g0401_0500/s0424_longest_repeating_character_replacement/Solution.java)| Medium | String, Hash_Table, Sliding_Window | 5 | 95.15 -#### Day 1 +#### Day 13 Hashmap | | | | | | |-|-|-|-|-|- -| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 99.76 -| 0611 |[Valid Triangle Number](src/main/java/g0601_0700/s0611_valid_triangle_number/Solution.java)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 10 | 100.00 +| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 +| 0299 |[Bulls and Cows](src/main/java/g0201_0300/s0299_bulls_and_cows/Solution.java)| Medium | String, Hash_Table, Counting | 6 | 86.69 -#### Day 2 +#### Day 14 Stack | | | | | | |-|-|-|-|-|- -| 0658 |[Find K Closest Elements](src/main/java/g0601_0700/s0658_find_k_closest_elements/Solution.java)| Medium | Array, Sorting, Binary_Search, Two_Pointers, Heap_Priority_Queue | 3 | 99.20 -| 1894 |[Find the Student that Will Replace the Chalk](src/main/java/g1801_1900/s1894_find_the_student_that_will_replace_the_chalk/Solution.java)| Medium | Array, Binary_Search, Simulation, Prefix_Sum | 2 | 76.67 +| 0844 |[Backspace String Compare](src/main/java/g0801_0900/s0844_backspace_string_compare/Solution.java)| Easy | String, Two_Pointers, Stack, Simulation | 0 | 100.00 +| 0394 |[Decode String](src/main/java/g0301_0400/s0394_decode_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, LeetCode_75_Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -#### Day 3 +#### Day 15 Heap | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 -| 1760 |[Minimum Limit of Balls in a Bag](src/main/java/g1701_1800/s1760_minimum_limit_of_balls_in_a_bag/Solution.java)| Medium | Array, Binary_Search | 44 | 78.49 +| 1046 |[Last Stone Weight](src/main/java/g1001_1100/s1046_last_stone_weight/Solution.java)| Easy | Array, Heap_Priority_Queue | 2 | 73.81 +| 0692 |[Top K Frequent Words](src/main/java/g0601_0700/s0692_top_k_frequent_words/Solution.java)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Trie, Bucket_Sort | 11 | 38.54 -#### Day 4 +### Level 2 + +#### Day 1 Implementation/Simulation | | | | | | |-|-|-|-|-|- -| 0875 |[Koko Eating Bananas](src/main/java/g0801_0900/s0875_koko_eating_bananas/Solution.java)| Medium | Array, Binary_Search, LeetCode_75_Binary_Search | 15 | 91.32 -| 1552 |[Magnetic Force Between Two Balls](src/main/java/g1501_1600/s1552_magnetic_force_between_two_balls/Solution.java)| Medium | Array, Sorting, Binary_Search | 39 | 99.65 +| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 +| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 +| 1706 |[Where Will the Ball Fall](src/main/java/g1701_1800/s1706_where_will_the_ball_fall/Solution.java)| Medium | Array, Dynamic_Programming, Depth_First_Search, Matrix, Simulation | 2 | 64.55 -#### Day 5 +#### Day 2 String | | | | | | |-|-|-|-|-|- -| 0287 |[Find the Duplicate Number](src/main/java/g0201_0300/s0287_find_the_duplicate_number/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Two_Pointers, Bit_Manipulation, Big_O_Time_O(n)_Space_O(n) | 2 | 97.52 -| 1283 |[Find the Smallest Divisor Given a Threshold](src/main/java/g1201_1300/s1283_find_the_smallest_divisor_given_a_threshold/Solution.java)| Medium | Array, Binary_Search | 9 | 95.49 +| 0014 |[Longest Common Prefix](src/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java)| Easy | Top_Interview_Questions, String, Big_O_Time_O(n\*m)_Space_O(m) | 0 | 100.00 +| 0043 |[Multiply Strings](src/main/java/g0001_0100/s0043_multiply_strings/Solution.java)| Medium | String, Math, Simulation | 1 | 100.00 -#### Day 6 +#### Day 3 Linked List | | | | | | |-|-|-|-|-|- -| 1898 |[Maximum Number of Removable Characters](src/main/java/g1801_1900/s1898_maximum_number_of_removable_characters/Solution.java)| Medium | Array, String, Binary_Search | 121 | 72.51 -| 1870 |[Minimum Speed to Arrive on Time](src/main/java/g1801_1900/s1870_minimum_speed_to_arrive_on_time/Solution.java)| Medium | Array, Binary_Search | 86 | 88.58 +| 0019 |[Remove Nth Node From End of List](src/main/java/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 +| 0234 |[Palindrome Linked List](src/main/java/g0201_0300/s0234_palindrome_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 4 | 84.46 -#### Day 7 +#### Day 4 Linked List | | | | | | |-|-|-|-|-|- -| 1482 |[Minimum Number of Days to Make m Bouquets](src/main/java/g1401_1500/s1482_minimum_number_of_days_to_make_m_bouquets/Solution.java)| Medium | Array, Binary_Search | 25 | 69.18 -| 1818 |[Minimum Absolute Sum Difference](src/main/java/g1801_1900/s1818_minimum_absolute_sum_difference/Solution.java)| Medium | Array, Sorting, Binary_Search, Ordered_Set | 13 | 99.44 +| 0328 |[Odd Even Linked List](src/main/java/g0301_0400/s0328_odd_even_linked_list/Solution.java)| Medium | Linked_List, LeetCode_75_LinkedList | 0 | 100.00 +| 0148 |[Sort List](src/main/java/g0101_0200/s0148_sort_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 9 | 93.90 -#### Day 8 +#### Day 5 Greedy | | | | | | |-|-|-|-|-|- -| 0240 |[Search a 2D Matrix II](src/main/java/g0201_0300/s0240_search_a_2d_matrix_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 5 | 99.92 -| 0275 |[H-Index II](src/main/java/g0201_0300/s0275_h_index_ii/Solution.java)| Medium | Array, Binary_Search | 0 | 100.00 +| 2131 |[Longest Palindrome by Concatenating Two Letter Words](src/main/java/g2101_2200/s2131_longest_palindrome_by_concatenating_two_letter_words/Solution.java)| Medium | Array, String, Hash_Table, Greedy, Counting | 73 | 76.60 +| 0621 |[Task Scheduler](src/main/java/g0601_0700/s0621_task_scheduler/Solution.java)| Medium | Array, Hash_Table, Sorting, Greedy, Heap_Priority_Queue, Counting | 3 | 84.32 -#### Day 9 +#### Day 6 Tree | | | | | | |-|-|-|-|-|- -| 1838 |[Frequency of the Most Frequent Element](src/main/java/g1801_1900/s1838_frequency_of_the_most_frequent_element/Solution.java)| Medium | Array, Sorting, Greedy, Binary_Search, Prefix_Sum, Sliding_Window | 11 | 100.00 -| 0540 |[Single Element in a Sorted Array](src/main/java/g0501_0600/s0540_single_element_in_a_sorted_array/Solution.java)| Medium | Array, Binary_Search | 0 | 100.00 +| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0110 |[Balanced Binary Tree](src/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree | 1 | 98.82 -#### Day 10 +#### Day 7 Tree | | | | | | |-|-|-|-|-|- -| 0222 |[Count Complete Tree Nodes](src/main/java/g0201_0300/s0222_count_complete_tree_nodes/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree | 0 | 100.00 -| 1712 |[Ways to Split Array Into Three Subarrays](src/main/java/g1701_1800/s1712_ways_to_split_array_into_three_subarrays/Solution.java)| Medium | Array, Binary_Search, Two_Pointers, Prefix_Sum | 16 | 84.24 +| 0543 |[Diameter of Binary Tree](src/main/java/g0501_0600/s0543_diameter_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0437 |[Path Sum III](src/main/java/g0401_0500/s0437_path_sum_iii/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 2 | 100.00 -#### Day 11 +#### Day 8 Binary Search | | | | | | |-|-|-|-|-|- -| 0826 |[Most Profit Assigning Work](src/main/java/g0801_0900/s0826_most_profit_assigning_work/Solution.java)| Medium | Array, Sorting, Greedy, Binary_Search, Two_Pointers | 21 | 83.83 -| 0436 |[Find Right Interval](src/main/java/g0401_0500/s0436_find_right_interval/Solution.java)| Medium | Array, Sorting, Binary_Search | 20 | 81.51 +| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 -#### Day 12 +#### Day 9 Binary Search Tree | | | | | | |-|-|-|-|-|- -| 0081 |[Search in Rotated Sorted Array II](src/main/java/g0001_0100/s0081_search_in_rotated_sorted_array_ii/Solution.java)| Medium | Array, Binary_Search | 1 | 82.83 -| 0162 |[Find Peak Element](src/main/java/g0101_0200/s0162_find_peak_element/Solution.java)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 +| 0230 |[Kth Smallest Element in a BST](src/main/java/g0201_0300/s0230_kth_smallest_element_in_a_bst/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 -#### Day 13 +#### Day 10 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 0154 |[Find Minimum in Rotated Sorted Array II](src/main/java/g0101_0200/s0154_find_minimum_in_rotated_sorted_array_ii/Solution.java)| Hard | Array, Binary_Search | 1 | 77.09 -| 0528 |[Random Pick with Weight](src/main/java/g0501_0600/s0528_random_pick_with_weight/Solution.java)| Medium | Math, Binary_Search, Prefix_Sum, Randomized | 42 | 50.90 +| 0994 |[Rotting Oranges](src/main/java/g0901_1000/s0994_rotting_oranges/Solution.java)| Medium | Top_100_Liked_Questions, Array, Breadth_First_Search, Matrix, LeetCode_75_Graphs/BFS | 3 | 74.27 +| 0417 |[Pacific Atlantic Water Flow](src/main/java/g0401_0500/s0417_pacific_atlantic_water_flow/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 5 | 92.62 -#### Day 14 +#### Day 11 Graph/BFS/DFS | | | | | | |-|-|-|-|-|- -| 1508 |[Range Sum of Sorted Subarray Sums](src/main/java/g1501_1600/s1508_range_sum_of_sorted_subarray_sums/Solution.java)| Medium | Array, Sorting, Binary_Search, Two_Pointers | 60 | 93.84 -| 1574 |[Shortest Subarray to be Removed to Make Array Sorted](src/main/java/g1501_1600/s1574_shortest_subarray_to_be_removed_to_make_array_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers, Stack, Monotonic_Stack | 2 | 84.97 +| 0210 |[Course Schedule II](src/main/java/g0201_0300/s0210_course_schedule_ii/Solution.java)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 4 | 91.07 +| 0815 |[Bus Routes](src/main/java/g0801_0900/s0815_bus_routes/Solution.java)| Hard | Array, Hash_Table, Breadth_First_Search | 49 | 89.11 -#### Day 15 +#### Day 12 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 1292 |[Maximum Side Length of a Square with Sum Less than or Equal to Threshold](src/main/java/g1201_1300/s1292_maximum_side_length_of_a_square_with_sum_less_than_or_equal_to_threshold/Solution.java)| Medium | Array, Binary_Search, Matrix, Prefix_Sum | 23 | 32.97 -| 1498 |[Number of Subsequences That Satisfy the Given Sum Condition](src/main/java/g1401_1500/s1498_number_of_subsequences_that_satisfy_the_given_sum_condition/Solution.java)| Medium | Array, Sorting, Binary_Search, Two_Pointers | 27 | 99.13 +| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 -#### Day 16 +#### Day 13 Dynamic Programming | | | | | | |-|-|-|-|-|- -| 0981 |[Time Based Key-Value Store](src/main/java/g0901_1000/s0981_time_based_key_value_store/TimeMap.java)| Medium | String, Hash_Table, Binary_Search, Design | 239 | 72.78 -| 1300 |[Sum of Mutated Array Closest to Target](src/main/java/g1201_1300/s1300_sum_of_mutated_array_closest_to_target/Solution.java)| Medium | Array, Sorting, Binary_Search | 7 | 33.33 +| 0416 |[Partition Equal Subset Sum](src/main/java/g0401_0500/s0416_partition_equal_subset_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Big_O_Time_O(n\*sums)_Space_O(n\*sums) | 5 | 99.88 +| 0152 |[Maximum Product Subarray](src/main/java/g0101_0200/s0152_maximum_product_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 92.74 -#### Day 17 +#### Day 14 Sliding Window/Two Pointer | | | | | | |-|-|-|-|-|- -| 1802 |[Maximum Value at a Given Index in a Bounded Array](src/main/java/g1801_1900/s1802_maximum_value_at_a_given_index_in_a_bounded_array/Solution.java)| Medium | Greedy, Binary_Search | 2 | 58.44 -| 1901 |[Find a Peak Element II](src/main/java/g1901_2000/s1901_find_a_peak_element_ii/Solution.java)| Medium | Array, Binary_Search, Matrix, Divide_and_Conquer | 0 | 100.00 +| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 +| 0016 |[3Sum Closest](src/main/java/g0001_0100/s0016_3sum_closest/Solution.java)| Medium | Array, Sorting, Two_Pointers | 4 | 98.21 +| 0076 |[Minimum Window Substring](src/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 2 | 99.83 -#### Day 18 +#### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 1146 |[Snapshot Array](src/main/java/g1101_1200/s1146_snapshot_array/SnapshotArray.java)| Medium | Array, Hash_Table, Binary_Search, Design | 68 | 45.86 -| 1488 |[Avoid Flood in The City](src/main/java/g1401_1500/s1488_avoid_flood_in_the_city/Solution.java)| Medium | Array, Hash_Table, Greedy, Binary_Search, Heap_Priority_Queue | 82 | 75.08 +| 0100 |[Same Tree](src/main/java/g0001_0100/s0100_same_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0101 |[Symmetric Tree](src/main/java/g0101_0200/s0101_symmetric_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0199 |[Binary Tree Right Side View](src/main/java/g0101_0200/s0199_binary_tree_right_side_view/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 -#### Day 19 +#### Day 16 Design | | | | | | |-|-|-|-|-|- -| 1562 |[Find Latest Group of Size M](src/main/java/g1501_1600/s1562_find_latest_group_of_size_m/Solution.java)| Medium | Array, Binary_Search, Simulation | 8 | 90.00 -| 1648 |[Sell Diminishing-Valued Colored Balls](src/main/java/g1601_1700/s1648_sell_diminishing_valued_colored_balls/Solution.java)| Medium | Array, Math, Sorting, Greedy, Binary_Search, Heap_Priority_Queue | 27 | 80.64 +| 0232 |[Implement Queue using Stacks](src/main/java/g0201_0300/s0232_implement_queue_using_stacks/MyQueue.java)| Easy | Stack, Design, Queue | 1 | 67.21 +| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 +| 0208 |[Implement Trie (Prefix Tree)](src/main/java/g0201_0300/s0208_implement_trie_prefix_tree/Trie.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 32 | 95.05 -#### Day 20 +#### Day 17 Interval | | | | | | |-|-|-|-|-|- -| 1201 |[Ugly Number III](src/main/java/g1201_1300/s1201_ugly_number_iii/Solution.java)| Medium | Math, Binary_Search, Number_Theory | 0 | 100.00 -| 0911 |[Online Election](src/main/java/g0901_1000/s0911_online_election/TopVotedCandidate.java)| Medium | Array, Hash_Table, Binary_Search, Design | 63 | 98.81 - -### Dynamic Programming I +| 0057 |[Insert Interval](src/main/java/g0001_0100/s0057_insert_interval/Solution.java)| Medium | Array | 0 | 100.00 +| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 -#### Day 1 +#### Day 18 Stack | | | | | | |-|-|-|-|-|- -| 0509 |[Fibonacci Number](src/main/java/g0501_0600/s0509_fibonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 0 | 100.00 -| 1137 |[N-th Tribonacci Number](src/main/java/g1101_1200/s1137_n_th_tribonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Memoization, LeetCode_75_DP/1D | 0 | 100.00 +| 0735 |[Asteroid Collision](src/main/java/g0701_0800/s0735_asteroid_collision/Solution.java)| Medium | Array, Stack, LeetCode_75_Stack | 2 | 99.59 +| 0227 |[Basic Calculator II](src/main/java/g0201_0300/s0227_basic_calculator_ii/Solution.java)| Medium | String, Math, Stack | 8 | 95.32 -#### Day 2 +#### Day 19 Union Find | | | | | | |-|-|-|-|-|- -| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0746 |[Min Cost Climbing Stairs](src/main/java/g0701_0800/s0746_min_cost_climbing_stairs/Solution.java)| Easy | Array, Dynamic_Programming, LeetCode_75_DP/1D | 1 | 86.38 +| 0547 |[Number of Provinces](src/main/java/g0501_0600/s0547_number_of_provinces/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find, LeetCode_75_Graphs/DFS | 2 | 69.51 +| 0947 |[Most Stones Removed with Same Row or Column](src/main/java/g0901_1000/s0947_most_stones_removed_with_same_row_or_column/Solution.java)| Medium | Depth_First_Search, Graph, Union_Find | 7 | 98.83 -#### Day 3 +#### Day 20 Brute Force/Backtracking | | | | | | |-|-|-|-|-|- -| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 -| 0213 |[House Robber II](src/main/java/g0201_0300/s0213_house_robber_ii/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 -| 0740 |[Delete and Earn](src/main/java/g0701_0800/s0740_delete_and_earn/Solution.java)| Medium | Array, Hash_Table, Dynamic_Programming | 4 | 77.68 +| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 +| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 -#### Day 4 +### Udemy + +#### Udemy Integers | | | | | | |-|-|-|-|-|- -| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 -| 0045 |[Jump Game II](src/main/java/g0001_0100/s0045_jump_game_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0412 |[Fizz Buzz](src/main/java/g0401_0500/s0412_fizz_buzz/Solution.java)| Easy | String, Math, Simulation | 1 | 100.00 +| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 +| 0007 |[Reverse Integer](src/main/java/g0001_0100/s0007_reverse_integer/Solution.java)| Medium | Top_Interview_Questions, Math, Big_O_Time_O(log10(x))_Space_O(1) | 0 | 100.00 +| 0009 |[Palindrome Number](src/main/java/g0001_0100/s0009_palindrome_number/Solution.java)| Easy | Math, Big_O_Time_O(log10(x))_Space_O(1) | 4 | 100.00 +| 0172 |[Factorial Trailing Zeroes](src/main/java/g0101_0200/s0172_factorial_trailing_zeroes/Solution.java)| Medium | Top_Interview_Questions, Math | 0 | 100.00 +| 0050 |[Pow(x, n)](src/main/java/g0001_0100/s0050_powx_n/Solution.java)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 -#### Day 5 +#### Udemy Strings | | | | | | |-|-|-|-|-|- -| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 -| 0918 |[Maximum Sum Circular Subarray](src/main/java/g0901_1000/s0918_maximum_sum_circular_subarray/Solution.java)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 99.34 +| 0344 |[Reverse String](src/main/java/g0301_0400/s0344_reverse_string/Solution.java)| Easy | String, Two_Pointers, Recursion | 1 | 99.91 +| 0014 |[Longest Common Prefix](src/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java)| Easy | Top_Interview_Questions, String, Big_O_Time_O(n\*m)_Space_O(m) | 0 | 100.00 +| 0187 |[Repeated DNA Sequences](src/main/java/g0101_0200/s0187_repeated_dna_sequences/Solution.java)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 29 | 77.11 +| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 +| 0020 |[Valid Parentheses](src/main/java/g0001_0100/s0020_valid_parentheses/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 2 | 97.19 +| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 +| 0394 |[Decode String](src/main/java/g0301_0400/s0394_decode_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, LeetCode_75_Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 +| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 +| 0151 |[Reverse Words in a String](src/main/java/g0101_0200/s0151_reverse_words_in_a_string/Solution.java)| Medium | String, Two_Pointers, LeetCode_75_Array/String | 2 | 99.69 +| 0273 |[Integer to English Words](src/main/java/g0201_0300/s0273_integer_to_english_words/Solution.java)| Hard | String, Math, Recursion | 3 | 95.67 -#### Day 6 +#### Udemy Binary Search | | | | | | |-|-|-|-|-|- -| 0152 |[Maximum Product Subarray](src/main/java/g0101_0200/s0152_maximum_product_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 92.74 -| 1567 |[Maximum Length of Subarray With Positive Product](src/main/java/g1501_1600/s1567_maximum_length_of_subarray_with_positive_product/Solution.java)| Medium | Array, Dynamic_Programming, Greedy | 4 | 80.86 +| 0704 |[Binary Search](src/main/java/g0701_0800/s0704_binary_search/Solution.java)| Easy | Array, Binary_Search | 0 | 100.00 +| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 -#### Day 7 +#### Udemy Arrays | | | | | | |-|-|-|-|-|- -| 1014 |[Best Sightseeing Pair](src/main/java/g1001_1100/s1014_best_sightseeing_pair/Solution.java)| Medium | Array, Dynamic_Programming | 2 | 99.86 | 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 +| 0283 |[Move Zeroes](src/main/java/g0201_0300/s0283_move_zeroes/Solution.java)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 83.99 +| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 +| 0217 |[Contains Duplicate](src/main/java/g0201_0300/s0217_contains_duplicate/Solution.java)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 6 | 96.68 +| 0058 |[Length of Last Word](src/main/java/g0001_0100/s0058_length_of_last_word/Solution.java)| Easy | String | 0 | 100.00 +| 0605 |[Can Place Flowers](src/main/java/g0601_0700/s0605_can_place_flowers/Solution.java)| Easy | Array, Greedy, LeetCode_75_Array/String | 1 | 96.77 | 0122 |[Best Time to Buy and Sell Stock II](src/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 1 | 76.91 +| 0080 |[Remove Duplicates from Sorted Array II](src/main/java/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/Solution.java)| Medium | Array, Two_Pointers | 0 | 100.00 +| 0189 |[Rotate Array](src/main/java/g0101_0200/s0189_rotate_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 +| 0075 |[Sort Colors](src/main/java/g0001_0100/s0075_sort_colors/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0066 |[Plus One](src/main/java/g0001_0100/s0066_plus_one/Solution.java)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 +| 0238 |[Product of Array Except Self](src/main/java/g0201_0300/s0238_product_of_array_except_self/Solution.java)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 1 | 99.66 +| 1291 |[Sequential Digits](src/main/java/g1201_1300/s1291_sequential_digits/Solution.java)| Medium | Enumeration | 0 | 100.00 +| 0448 |[Find All Numbers Disappeared in an Array](src/main/java/g0401_0500/s0448_find_all_numbers_disappeared_in_an_array/Solution.java)| Easy | Array, Hash_Table | 3 | 100.00 +| 0442 |[Find All Duplicates in an Array](src/main/java/g0401_0500/s0442_find_all_duplicates_in_an_array/Solution.java)| Medium | Array, Hash_Table | 5 | 98.83 +| 0041 |[First Missing Positive](src/main/java/g0001_0100/s0041_first_missing_positive/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 1 | 100.00 +| 0697 |[Degree of an Array](src/main/java/g0601_0700/s0697_degree_of_an_array/Solution.java)| Easy | Array, Hash_Table | 14 | 93.19 +| 0532 |[K-diff Pairs in an Array](src/main/java/g0501_0600/s0532_k_diff_pairs_in_an_array/Solution.java)| Medium | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 13 | 58.23 +| 0713 |[Subarray Product Less Than K](src/main/java/g0701_0800/s0713_subarray_product_less_than_k/Solution.java)| Medium | Array, Sliding_Window | 8 | 39.00 +| 1007 |[Minimum Domino Rotations For Equal Row](src/main/java/g1001_1100/s1007_minimum_domino_rotations_for_equal_row/Solution.java)| Medium | Array, Greedy | 5 | 79.64 +| 1306 |[Jump Game III](src/main/java/g1301_1400/s1306_jump_game_iii/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search | 2 | 96.23 +| 0456 |[132 Pattern](src/main/java/g0401_0500/s0456_132_pattern/Solution.java)| Medium | Array, Binary_Search, Stack, Ordered_Set, Monotonic_Stack | 16 | 82.41 +| 0239 |[Sliding Window Maximum](src/main/java/g0201_0300/s0239_sliding_window_maximum/Solution.java)| Hard | Top_100_Liked_Questions, Array, Heap_Priority_Queue, Sliding_Window, Queue, Monotonic_Queue, Big_O_Time_O(n\*k)_Space_O(n+k) | 26 | 95.89 -#### Day 8 +#### Udemy Two Pointers | | | | | | |-|-|-|-|-|- -| 0309 |[Best Time to Buy and Sell Stock with Cooldown](src/main/java/g0301_0400/s0309_best_time_to_buy_and_sell_stock_with_cooldown/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 -| 0714 |[Best Time to Buy and Sell Stock with Transaction Fee](src/main/java/g0701_0800/s0714_best_time_to_buy_and_sell_stock_with_transaction_fee/Solution.java)| Medium | Array, Dynamic_Programming, Greedy, LeetCode_75_DP/Multidimensional | 4 | 78.57 +| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 +| 0125 |[Valid Palindrome](src/main/java/g0101_0200/s0125_valid_palindrome/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers | 2 | 99.11 +| 0977 |[Squares of a Sorted Array](src/main/java/g0901_1000/s0977_squares_of_a_sorted_array/Solution.java)| Easy | Array, Sorting, Two_Pointers | 1 | 100.00 +| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 +| 0042 |[Trapping Rain Water](src/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 -#### Day 9 +#### Udemy Famous Algorithm | | | | | | |-|-|-|-|-|- -| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 -| 0042 |[Trapping Rain Water](src/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 +| 0169 |[Majority Element](src/main/java/g0101_0200/s0169_majority_element/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.89 -#### Day 10 +#### Udemy Sorting Algorithms | | | | | | |-|-|-|-|-|- -| 0413 |[Arithmetic Slices](src/main/java/g0401_0500/s0413_arithmetic_slices/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 -| 0091 |[Decode Ways](src/main/java/g0001_0100/s0091_decode_ways/Solution.java)| Medium | Top_Interview_Questions, String, Dynamic_Programming | 2 | 66.37 +| 0912 |[Sort an Array](src/main/java/g0901_1000/s0912_sort_an_array/Solution.java)| Medium | Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Merge_Sort, Bucket_Sort, Counting_Sort, Radix_Sort | 25 | 38.15 -#### Day 11 +#### Udemy 2D Arrays/Matrix | | | | | | |-|-|-|-|-|- -| 0264 |[Ugly Number II](src/main/java/g0201_0300/s0264_ugly_number_ii/Solution.java)| Medium | Hash_Table, Dynamic_Programming, Math, Heap_Priority_Queue | 2 | 99.91 -| 0096 |[Unique Binary Search Trees](src/main/java/g0001_0100/s0096_unique_binary_search_trees/Solution.java)| Medium | Dynamic_Programming, Math, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0304 |[Range Sum Query 2D - Immutable](src/main/java/g0301_0400/s0304_range_sum_query_2d_immutable/NumMatrix.java)| Medium | Array, Matrix, Design, Prefix_Sum | 153 | 87.51 +| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 +| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 +| 1572 |[Matrix Diagonal Sum](src/main/java/g1501_1600/s1572_matrix_diagonal_sum/Solution.java)| Easy | Array, Matrix | 0 | 100.00 +| 0073 |[Set Matrix Zeroes](src/main/java/g0001_0100/s0073_set_matrix_zeroes/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 0 | 100.00 +| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 -#### Day 12 +#### Udemy Linked List | | | | | | |-|-|-|-|-|- -| 0118 |[Pascal's Triangle](src/main/java/g0101_0200/s0118_pascals_triangle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 1 | 67.08 -| 0119 |[Pascal's Triangle II](src/main/java/g0101_0200/s0119_pascals_triangle_ii/Solution.java)| Easy | Array, Dynamic_Programming | 0 | 100.00 +| 0114 |[Flatten Binary Tree to Linked List](src/main/java/g0101_0200/s0114_flatten_binary_tree_to_linked_list/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0445 |[Add Two Numbers II](src/main/java/g0401_0500/s0445_add_two_numbers_ii/Solution.java)| Medium | Math, Stack, Linked_List | 3 | 90.38 +| 0328 |[Odd Even Linked List](src/main/java/g0301_0400/s0328_odd_even_linked_list/Solution.java)| Medium | Linked_List, LeetCode_75_LinkedList | 0 | 100.00 +| 0061 |[Rotate List](src/main/java/g0001_0100/s0061_rotate_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0024 |[Swap Nodes in Pairs](src/main/java/g0001_0100/s0024_swap_nodes_in_pairs/Solution.java)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 +| 0142 |[Linked List Cycle II](src/main/java/g0101_0200/s0142_linked_list_cycle_ii/Solution.java)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0141 |[Linked List Cycle](src/main/java/g0101_0200/s0141_linked_list_cycle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 +| 0160 |[Intersection of Two Linked Lists](src/main/java/g0101_0200/s0160_intersection_of_two_linked_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 1 | 99.92 +| 0234 |[Palindrome Linked List](src/main/java/g0201_0300/s0234_palindrome_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Two_Pointers, Stack, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 4 | 84.46 +| 0138 |[Copy List with Random Pointer](src/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0025 |[Reverse Nodes in k-Group](src/main/java/g0001_0100/s0025_reverse_nodes_in_k_group/Solution.java)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 +| 0146 |[LRU Cache](src/main/java/g0101_0200/s0146_lru_cache/LRUCache.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 40 | 98.20 +| 0707 |[Design Linked List](src/main/java/g0701_0800/s0707_design_linked_list/MyLinkedList.java)| Medium | Design, Linked_List | 10 | 70.60 -#### Day 13 +#### Udemy Tree Stack Queue | | | | | | |-|-|-|-|-|- -| 0931 |[Minimum Falling Path Sum](src/main/java/g0901_1000/s0931_minimum_falling_path_sum/Solution.java)| Medium | Array, Dynamic_Programming, Matrix | 4 | 72.19 -| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 +| 0144 |[Binary Tree Preorder Traversal](src/main/java/g0101_0200/s0144_binary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 48.38 +| 0094 |[Binary Tree Inorder Traversal](src/main/java/g0001_0100/s0094_binary_tree_inorder_traversal/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0145 |[Binary Tree Postorder Traversal](src/main/java/g0101_0200/s0145_binary_tree_postorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 49.11 +| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/java/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/Solution.java)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 +| 1008 |[Construct Binary Search Tree from Preorder Traversal](src/main/java/g1001_1100/s1008_construct_binary_search_tree_from_preorder_traversal/Solution.java)| Medium | Array, Tree, Binary_Tree, Stack, Monotonic_Stack, Binary_Search_Tree | 0 | 100.00 +| 0543 |[Diameter of Binary Tree](src/main/java/g0501_0600/s0543_diameter_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0938 |[Range Sum of BST](src/main/java/g0901_1000/s0938_range_sum_of_bst/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 +| 0100 |[Same Tree](src/main/java/g0001_0100/s0100_same_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0111 |[Minimum Depth of Binary Tree](src/main/java/g0101_0200/s0111_minimum_depth_of_binary_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 1 | 97.49 +| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0110 |[Balanced Binary Tree](src/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree | 1 | 98.82 +| 0701 |[Insert into a Binary Search Tree](src/main/java/g0701_0800/s0701_insert_into_a_binary_search_tree/Solution.java)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 +| 0297 |[Serialize and Deserialize Binary Tree](src/main/java/g0201_0300/s0297_serialize_and_deserialize_binary_tree/Codec.java)| Hard | String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 7 | 98.13 +| 0124 |[Binary Tree Maximum Path Sum](src/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0337 |[House Robber III](src/main/java/g0301_0400/s0337_house_robber_iii/Solution.java)| Medium | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 1 | 91.77 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/java/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 6 | 100.00 +| 0968 |[Binary Tree Cameras](src/main/java/g0901_1000/s0968_binary_tree_cameras/Solution.java)| Hard | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 0 | 100.00 -#### Day 14 +#### Udemy Trie and Heap | | | | | | |-|-|-|-|-|- -| 1314 |[Matrix Block Sum](src/main/java/g1301_1400/s1314_matrix_block_sum/Solution.java)| Medium | Array, Matrix, Prefix_Sum | 5 | 67.46 -| 0304 |[Range Sum Query 2D - Immutable](src/main/java/g0301_0400/s0304_range_sum_query_2d_immutable/NumMatrix.java)| Medium | Array, Matrix, Design, Prefix_Sum | 153 | 87.51 +| 0208 |[Implement Trie (Prefix Tree)](src/main/java/g0201_0300/s0208_implement_trie_prefix_tree/Trie.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 32 | 95.05 +| 0745 |[Prefix and Suffix Search](src/main/java/g0701_0800/s0745_prefix_and_suffix_search/WordFilter.java)| Hard | String, Design, Trie | 366 | 76.15 -#### Day 15 +#### Udemy Graph | | | | | | |-|-|-|-|-|- -| 0062 |[Unique Paths](src/main/java/g0001_0100/s0062_unique_paths/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, LeetCode_75_DP/Multidimensional, Big_O_Time_O(m\*n)_Space_O(m\*n) | 0 | 100.00 -| 0063 |[Unique Paths II](src/main/java/g0001_0100/s0063_unique_paths_ii/Solution.java)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 +| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 +| 0133 |[Clone Graph](src/main/java/g0101_0200/s0133_clone_graph/Solution.java)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 25 | 68.87 +| 0417 |[Pacific Atlantic Water Flow](src/main/java/g0401_0500/s0417_pacific_atlantic_water_flow/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 5 | 92.62 -#### Day 16 +#### Udemy Dynamic Programming | | | | | | |-|-|-|-|-|- +| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 +| 0118 |[Pascal's Triangle](src/main/java/g0101_0200/s0118_pascals_triangle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 1 | 67.08 +| 0119 |[Pascal's Triangle II](src/main/java/g0101_0200/s0119_pascals_triangle_ii/Solution.java)| Easy | Array, Dynamic_Programming | 0 | 100.00 +| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 +| 0152 |[Maximum Product Subarray](src/main/java/g0101_0200/s0152_maximum_product_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 92.74 +| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0213 |[House Robber II](src/main/java/g0201_0300/s0213_house_robber_ii/Solution.java)| Medium | Array, Dynamic_Programming | 0 | 100.00 +| 0509 |[Fibonacci Number](src/main/java/g0501_0600/s0509_fibonacci_number/Solution.java)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 0 | 100.00 +| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 | 0064 |[Minimum Path Sum](src/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 1 | 99.73 -| 0221 |[Maximal Square](src/main/java/g0201_0300/s0221_maximal_square/Solution.java)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 6 | 97.07 +| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 +| 1143 |[Longest Common Subsequence](src/main/java/g1101_1200/s1143_longest_common_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 19 | 89.05 +| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 +| 0044 |[Wildcard Matching](src/main/java/g0001_0100/s0044_wildcard_matching/Solution.java)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Greedy, Recursion | 2 | 99.87 +| 0010 |[Regular Expression Matching](src/main/java/g0001_0100/s0010_regular_expression_matching/Solution.java)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Recursion, Big_O_Time_O(m\*n)_Space_O(m\*n) | 1 | 100.00 -#### Day 17 +#### Udemy Backtracking/Recursion | | | | | | |-|-|-|-|-|- -| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 -| 0516 |[Longest Palindromic Subsequence](src/main/java/g0501_0600/s0516_longest_palindromic_subsequence/Solution.java)| Medium | String, Dynamic_Programming | 88 | 58.87 +| 0022 |[Generate Parentheses](src/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 0 | 100.00 +| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 +| 0216 |[Combination Sum III](src/main/java/g0201_0300/s0216_combination_sum_iii/Solution.java)| Medium | Array, Backtracking, LeetCode_75_Backtracking | 1 | 81.35 +| 0078 |[Subsets](src/main/java/g0001_0100/s0078_subsets/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, Backtracking, Big_O_Time_O(2^n)_Space_O(n\*2^n) | 0 | 100.00 +| 0017 |[Letter Combinations of a Phone Number](src/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 -#### Day 18 +#### Udemy Bit Manipulation | | | | | | |-|-|-|-|-|- -| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 -| 0376 |[Wiggle Subsequence](src/main/java/g0301_0400/s0376_wiggle_subsequence/Solution.java)| Medium | Array, Dynamic_Programming, Greedy | 0 | 100.00 +| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 +| 0389 |[Find the Difference](src/main/java/g0301_0400/s0389_find_the_difference/Solution.java)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 1 | 100.00 +| 0190 |[Reverse Bits](src/main/java/g0101_0200/s0190_reverse_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 0 | 100.00 +| 0461 |[Hamming Distance](src/main/java/g0401_0500/s0461_hamming_distance/Solution.java)| Easy | Bit_Manipulation | 0 | 100.00 +| 1009 |[Complement of Base 10 Integer](src/main/java/g1001_1100/s1009_complement_of_base_10_integer/Solution.java)| Easy | Bit_Manipulation | 1 | 41.56 +| 0338 |[Counting Bits](src/main/java/g0301_0400/s0338_counting_bits/Solution.java)| Easy | Dynamic_Programming, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(num)_Space_O(num) | 2 | 96.37 +| 0371 |[Sum of Two Integers](src/main/java/g0301_0400/s0371_sum_of_two_integers/Solution.java)| Medium | Math, Bit_Manipulation | 0 | 100.00 +| 0029 |[Divide Two Integers](src/main/java/g0001_0100/s0029_divide_two_integers/Solution.java)| Medium | Top_Interview_Questions, Math, Bit_Manipulation | 1 | 97.44 + +#### Udemy Design + +| | | | | | +|-|-|-|-|-|- +| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 -#### Day 19 +### Top Interview 150 + +#### Top Interview 150 Array/String | | | | | | |-|-|-|-|-|- -| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 -| 1143 |[Longest Common Subsequence](src/main/java/g1101_1200/s1143_longest_common_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n\*m)_Space_O(n\*m) | 19 | 89.05 -| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 +| 0088 |[Merge Sorted Array](src/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 0 | 100.00 +| 0027 |[Remove Element](src/main/java/g0001_0100/s0027_remove_element/Solution.java)| Easy | Array, Two_Pointers | 0 | 100.00 +| 0026 |[Remove Duplicates from Sorted Array](src/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers | 0 | 100.00 +| 0080 |[Remove Duplicates from Sorted Array II](src/main/java/g0001_0100/s0080_remove_duplicates_from_sorted_array_ii/Solution.java)| Medium | Array, Two_Pointers | 0 | 100.00 +| 0169 |[Majority Element](src/main/java/g0101_0200/s0169_majority_element/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.89 +| 0189 |[Rotate Array](src/main/java/g0101_0200/s0189_rotate_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 +| 0122 |[Best Time to Buy and Sell Stock II](src/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java)| Medium | Top_Interview_Questions, Array, Dynamic_Programming, Greedy | 1 | 76.91 +| 0055 |[Jump Game](src/main/java/g0001_0100/s0055_jump_game/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 1 | 100.00 +| 0045 |[Jump Game II](src/main/java/g0001_0100/s0045_jump_game_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0274 |[H-Index](src/main/java/g0201_0300/s0274_h_index/Solution.java)| Medium | Array, Sorting, Counting_Sort | 0 | 100.00 +| 0380 |[Insert Delete GetRandom O(1)](src/main/java/g0301_0400/s0380_insert_delete_getrandom_o1/RandomizedSet.java)| Medium | Array, Hash_Table, Math, Design, Randomized | 27 | 93.44 +| 0238 |[Product of Array Except Self](src/main/java/g0201_0300/s0238_product_of_array_except_self/Solution.java)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 1 | 99.66 +| 0134 |[Gas Station](src/main/java/g0101_0200/s0134_gas_station/Solution.java)| Medium | Top_Interview_Questions, Array, Greedy | 2 | 97.52 +| 0135 |[Candy](src/main/java/g0101_0200/s0135_candy/Solution.java)| Hard | Array, Greedy | 3 | 83.95 +| 0042 |[Trapping Rain Water](src/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0013 |[Roman to Integer](src/main/java/g0001_0100/s0013_roman_to_integer/Solution.java)| Easy | Top_Interview_Questions, String, Hash_Table, Math, Big_O_Time_O(n)_Space_O(1) | 2 | 100.00 +| 0012 |[Integer to Roman](src/main/java/g0001_0100/s0012_integer_to_roman/Solution.java)| Medium | String, Hash_Table, Math, Big_O_Time_O(1)_Space_O(1) | 2 | 100.00 +| 0058 |[Length of Last Word](src/main/java/g0001_0100/s0058_length_of_last_word/Solution.java)| Easy | String | 0 | 100.00 +| 0014 |[Longest Common Prefix](src/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java)| Easy | Top_Interview_Questions, String, Big_O_Time_O(n\*m)_Space_O(m) | 0 | 100.00 +| 0151 |[Reverse Words in a String](src/main/java/g0101_0200/s0151_reverse_words_in_a_string/Solution.java)| Medium | String, Two_Pointers, LeetCode_75_Array/String | 2 | 99.69 +| 0006 |[Zigzag Conversion](src/main/java/g0001_0100/s0006_zigzag_conversion/Solution.java)| Medium | String, Big_O_Time_O(n)_Space_O(n) | 2 | 99.71 +| 0028 |[Find the Index of the First Occurrence in a String](src/main/java/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 +| 0068 |[Text Justification](src/main/java/g0001_0100/s0068_text_justification/Solution.java)| Hard | Array, String, Simulation | 0 | 100.00 -#### Day 20 +#### Top Interview 150 Two Pointers | | | | | | |-|-|-|-|-|- -| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 -| 0518 |[Coin Change 2](src/main/java/g0501_0600/s0518_coin_change_2/Solution.java)| Medium | Array, Dynamic_Programming | 4 | 84.67 +| 0125 |[Valid Palindrome](src/main/java/g0101_0200/s0125_valid_palindrome/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers | 2 | 99.11 +| 0392 |[Is Subsequence](src/main/java/g0301_0400/s0392_is_subsequence/Solution.java)| Easy | String, Dynamic_Programming, Two_Pointers, LeetCode_75_Two_Pointers | 1 | 93.13 +| 0167 |[Two Sum II - Input Array Is Sorted](src/main/java/g0101_0200/s0167_two_sum_ii_input_array_is_sorted/Solution.java)| Medium | Array, Binary_Search, Two_Pointers | 2 | 92.62 +| 0011 |[Container With Most Water](src/main/java/g0001_0100/s0011_container_with_most_water/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 3 | 96.01 +| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 -#### Day 21 +#### Top Interview 150 Sliding Window | | | | | | |-|-|-|-|-|- -| 0377 |[Combination Sum IV](src/main/java/g0301_0400/s0377_combination_sum_iv/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 92.54 -| 0343 |[Integer Break](src/main/java/g0301_0400/s0343_integer_break/Solution.java)| Medium | Dynamic_Programming, Math | 0 | 100.00 -| 0279 |[Perfect Squares](src/main/java/g0201_0300/s0279_perfect_squares/Solution.java)| Medium | Top_100_Liked_Questions, Dynamic_Programming, Math, Breadth_First_Search | 1 | 100.00 - -### Programming Skills I +| 0209 |[Minimum Size Subarray Sum](src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java)| Medium | Array, Binary_Search, Prefix_Sum, Sliding_Window | 1 | 99.76 +| 0003 |[Longest Substring Without Repeating Characters](src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n)_Space_O(1), AI_can_be_used_to_solve_the_task | 2 | 98.59 +| 0030 |[Substring with Concatenation of All Words](src/main/java/g0001_0100/s0030_substring_with_concatenation_of_all_words/Solution.java)| Hard | String, Hash_Table, Sliding_Window | 11 | 97.43 +| 0076 |[Minimum Window Substring](src/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(s.length())_Space_O(1) | 2 | 99.83 -#### Day 1 Basic Data Type +#### Top Interview 150 Matrix | | | | | | |-|-|-|-|-|- -| 1523 |[Count Odd Numbers in an Interval Range](src/main/java/g1501_1600/s1523_count_odd_numbers_in_an_interval_range/Solution.java)| Easy | Math | 0 | 100.00 -| 1491 |[Average Salary Excluding the Minimum and Maximum Salary](src/main/java/g1401_1500/s1491_average_salary_excluding_the_minimum_and_maximum_salary/Solution.java)| Easy | Array, Sorting | 0 | 100.00 +| 0036 |[Valid Sudoku](src/main/java/g0001_0100/s0036_valid_sudoku/Solution.java)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 1 | 100.00 +| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 +| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 +| 0073 |[Set Matrix Zeroes](src/main/java/g0001_0100/s0073_set_matrix_zeroes/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Matrix, Big_O_Time_O(m\*n)_Space_O(1) | 0 | 100.00 +| 0289 |[Game of Life](src/main/java/g0201_0300/s0289_game_of_life/Solution.java)| Medium | Array, Matrix, Simulation | 0 | 100.00 -#### Day 2 Operator +#### Top Interview 150 Hashmap | | | | | | |-|-|-|-|-|- -| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 -| 1281 |[Subtract the Product and Sum of Digits of an Integer](src/main/java/g1201_1300/s1281_subtract_the_product_and_sum_of_digits_of_an_integer/Solution.java)| Easy | Math | 0 | 100.00 +| 0383 |[Ransom Note](src/main/java/g0301_0400/s0383_ransom_note/Solution.java)| Easy | String, Hash_Table, Counting | 1 | 99.10 +| 0205 |[Isomorphic Strings](src/main/java/g0201_0300/s0205_isomorphic_strings/Solution.java)| Easy | String, Hash_Table | 2 | 99.18 +| 0290 |[Word Pattern](src/main/java/g0201_0300/s0290_word_pattern/Solution.java)| Easy | String, Hash_Table | 0 | 100.00 +| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 +| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 +| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 +| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 +| 0219 |[Contains Duplicate II](src/main/java/g0201_0300/s0219_contains_duplicate_ii/Solution.java)| Easy | Array, Hash_Table, Sliding_Window | 15 | 98.00 +| 0128 |[Longest Consecutive Sequence](src/main/java/g0101_0200/s0128_longest_consecutive_sequence/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Union_Find, Big_O_Time_O(N_log_N)_Space_O(1) | 14 | 98.89 -#### Day 3 Conditional Statements +#### Top Interview 150 Intervals | | | | | | |-|-|-|-|-|- -| 0976 |[Largest Perimeter Triangle](src/main/java/g0901_1000/s0976_largest_perimeter_triangle/Solution.java)| Easy | Array, Math, Sorting, Greedy | 7 | 99.33 -| 1779 |[Find Nearest Point That Has the Same X or Y Coordinate](src/main/java/g1701_1800/s1779_find_nearest_point_that_has_the_same_x_or_y_coordinate/Solution.java)| Easy | Array | 1 | 100.00 +| 0228 |[Summary Ranges](src/main/java/g0201_0300/s0228_summary_ranges/Solution.java)| Easy | Array | 0 | 100.00 +| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 +| 0057 |[Insert Interval](src/main/java/g0001_0100/s0057_insert_interval/Solution.java)| Medium | Array | 0 | 100.00 +| 0452 |[Minimum Number of Arrows to Burst Balloons](src/main/java/g0401_0500/s0452_minimum_number_of_arrows_to_burst_balloons/Solution.java)| Medium | Array, Sorting, Greedy, LeetCode_75_Intervals | 52 | 89.91 -#### Day 4 Loop +#### Top Interview 150 Stack | | | | | | |-|-|-|-|-|- -| 1822 |[Sign of the Product of an Array](src/main/java/g1801_1900/s1822_sign_of_the_product_of_an_array/Solution.java)| Easy | Array, Math | 1 | 58.05 -| 1502 |[Can Make Arithmetic Progression From Sequence](src/main/java/g1501_1600/s1502_can_make_arithmetic_progression_from_sequence/Solution.java)| Easy | Array, Sorting | 2 | 90.55 -| 0202 |[Happy Number](src/main/java/g0201_0300/s0202_happy_number/Solution.java)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 0 | 100.00 -| 1790 |[Check if One String Swap Can Make Strings Equal](src/main/java/g1701_1800/s1790_check_if_one_string_swap_can_make_strings_equal/Solution.java)| Easy | String, Hash_Table, Counting | 0 | 100.00 +| 0020 |[Valid Parentheses](src/main/java/g0001_0100/s0020_valid_parentheses/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 2 | 97.19 +| 0071 |[Simplify Path](src/main/java/g0001_0100/s0071_simplify_path/Solution.java)| Medium | String, Stack | 2 | 99.86 +| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 +| 0150 |[Evaluate Reverse Polish Notation](src/main/java/g0101_0200/s0150_evaluate_reverse_polish_notation/Solution.java)| Medium | Top_Interview_Questions, Array, Math, Stack | 6 | 76.50 +| 0224 |[Basic Calculator](src/main/java/g0201_0300/s0224_basic_calculator/Solution.java)| Hard | String, Math, Stack, Recursion | 2 | 96.52 -#### Day 5 Function +#### Top Interview 150 Linked List | | | | | | |-|-|-|-|-|- -| 0589 |[N-ary Tree Preorder Traversal](src/main/java/g0501_0600/s0589_n_ary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Stack | 1 | 90.98 -| 0496 |[Next Greater Element I](src/main/java/g0401_0500/s0496_next_greater_element_i/Solution.java)| Easy | Array, Hash_Table, Stack, Monotonic_Stack | 4 | 81.18 -| 1232 |[Check If It Is a Straight Line](src/main/java/g1201_1300/s1232_check_if_it_is_a_straight_line/Solution.java)| Easy | Array, Math, Geometry | 0 | 100.00 +| 0141 |[Linked List Cycle](src/main/java/g0101_0200/s0141_linked_list_cycle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0002 |[Add Two Numbers](src/main/java/g0001_0100/s0002_add_two_numbers/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 1 | 100.00 +| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 +| 0138 |[Copy List with Random Pointer](src/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0092 |[Reverse Linked List II](src/main/java/g0001_0100/s0092_reverse_linked_list_ii/Solution.java)| Medium | Linked_List | 0 | 100.00 +| 0025 |[Reverse Nodes in k-Group](src/main/java/g0001_0100/s0025_reverse_nodes_in_k_group/Solution.java)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 +| 0019 |[Remove Nth Node From End of List](src/main/java/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Big_O_Time_O(L)_Space_O(L) | 0 | 100.00 +| 0082 |[Remove Duplicates from Sorted List II](src/main/java/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0061 |[Rotate List](src/main/java/g0001_0100/s0061_rotate_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0086 |[Partition List](src/main/java/g0001_0100/s0086_partition_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 +| 0146 |[LRU Cache](src/main/java/g0101_0200/s0146_lru_cache/LRUCache.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Design, Linked_List, Doubly_Linked_List, Big_O_Time_O(1)_Space_O(capacity) | 40 | 98.20 -#### Day 6 Array +#### Top Interview 150 Binary Tree General | | | | | | |-|-|-|-|-|- -| 1588 |[Sum of All Odd Length Subarrays](src/main/java/g1501_1600/s1588_sum_of_all_odd_length_subarrays/Solution.java)| Easy | Array, Math, Prefix_Sum | 0 | 100.00 -| 0283 |[Move Zeroes](src/main/java/g0201_0300/s0283_move_zeroes/Solution.java)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, LeetCode_75_Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 83.99 -| 1672 |[Richest Customer Wealth](src/main/java/g1601_1700/s1672_richest_customer_wealth/Solution.java)| Easy | Array, Matrix | 0 | 100.00 +| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0100 |[Same Tree](src/main/java/g0001_0100/s0100_same_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0101 |[Symmetric Tree](src/main/java/g0101_0200/s0101_symmetric_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/java/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 1 | 96.33 +| 0106 |[Construct Binary Tree from Inorder and Postorder Traversal](src/main/java/g0101_0200/s0106_construct_binary_tree_from_inorder_and_postorder_traversal/Solution.java)| Medium | Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer | 0 | 100.00 +| 0117 |[Populating Next Right Pointers in Each Node II](src/main/java/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 0 | 100.00 +| 0114 |[Flatten Binary Tree to Linked List](src/main/java/g0101_0200/s0114_flatten_binary_tree_to_linked_list/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0112 |[Path Sum](src/main/java/g0101_0200/s0112_path_sum/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0129 |[Sum Root to Leaf Numbers](src/main/java/g0101_0200/s0129_sum_root_to_leaf_numbers/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree | 0 | 100.00 +| 0124 |[Binary Tree Maximum Path Sum](src/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 +| 0222 |[Count Complete Tree Nodes](src/main/java/g0201_0300/s0222_count_complete_tree_nodes/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Search, Binary_Tree | 0 | 100.00 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/java/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 6 | 100.00 -#### Day 7 Array +#### Top Interview 150 Binary Tree BFS | | | | | | |-|-|-|-|-|- -| 1572 |[Matrix Diagonal Sum](src/main/java/g1501_1600/s1572_matrix_diagonal_sum/Solution.java)| Easy | Array, Matrix | 0 | 100.00 -| 0566 |[Reshape the Matrix](src/main/java/g0501_0600/s0566_reshape_the_matrix/Solution.java)| Easy | Array, Matrix, Simulation | 1 | 90.08 +| 0199 |[Binary Tree Right Side View](src/main/java/g0101_0200/s0199_binary_tree_right_side_view/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 +| 0637 |[Average of Levels in Binary Tree](src/main/java/g0601_0700/s0637_average_of_levels_in_binary_tree/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 2 | 94.34 +| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/java/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/Solution.java)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -#### Day 8 String +#### Top Interview 150 Binary Search Tree | | | | | | |-|-|-|-|-|- -| 1768 |[Merge Strings Alternately](src/main/java/g1701_1800/s1768_merge_strings_alternately/Solution.java)| Easy | String, Two_Pointers, LeetCode_75_Array/String | 1 | 86.26 -| 1678 |[Goal Parser Interpretation](src/main/java/g1601_1700/s1678_goal_parser_interpretation/Solution.java)| Easy | String | 0 | 100.00 -| 0389 |[Find the Difference](src/main/java/g0301_0400/s0389_find_the_difference/Solution.java)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 1 | 100.00 +| 0530 |[Minimum Absolute Difference in BST](src/main/java/g0501_0600/s0530_minimum_absolute_difference_in_bst/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 +| 0230 |[Kth Smallest Element in a BST](src/main/java/g0201_0300/s0230_kth_smallest_element_in_a_bst/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -#### Day 9 String +#### Top Interview 150 Graph General | | | | | | |-|-|-|-|-|- -| 0709 |[To Lower Case](src/main/java/g0701_0800/s0709_to_lower_case/Solution.java)| Easy | String | 1 | 71.74 -| 1309 |[Decrypt String from Alphabet to Integer Mapping](src/main/java/g1301_1400/s1309_decrypt_string_from_alphabet_to_integer_mapping/Solution.java)| Easy | String | 0 | 100.00 -| 0953 |[Verifying an Alien Dictionary](src/main/java/g0901_1000/s0953_verifying_an_alien_dictionary/Solution.java)| Easy | Array, String, Hash_Table | 0 | 100.00 +| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 +| 0130 |[Surrounded Regions](src/main/java/g0101_0200/s0130_surrounded_regions/Solution.java)| Medium | Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 2 | 84.66 +| 0133 |[Clone Graph](src/main/java/g0101_0200/s0133_clone_graph/Solution.java)| Medium | Hash_Table, Depth_First_Search, Breadth_First_Search, Graph | 25 | 68.87 +| 0399 |[Evaluate Division](src/main/java/g0301_0400/s0399_evaluate_division/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Graph, Union_Find, Shortest_Path, LeetCode_75_Graphs/DFS | 1 | 99.52 +| 0207 |[Course Schedule](src/main/java/g0201_0300/s0207_course_schedule/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort, Big_O_Time_O(N)_Space_O(N) | 3 | 99.99 +| 0210 |[Course Schedule II](src/main/java/g0201_0300/s0210_course_schedule_ii/Solution.java)| Medium | Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 4 | 91.07 -#### Day 10 Linked List and Tree +#### Top Interview 150 Graph BFS | | | | | | |-|-|-|-|-|- -| 1290 |[Convert Binary Number in a Linked List to Integer](src/main/java/g1201_1300/s1290_convert_binary_number_in_a_linked_list_to_integer/Solution.java)| Easy | Math, Linked_List | 0 | 100.00 -| 0876 |[Middle of the Linked List](src/main/java/g0801_0900/s0876_middle_of_the_linked_list/Solution.java)| Easy | Two_Pointers, Linked_List | 0 | 100.00 -| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 -| 0404 |[Sum of Left Leaves](src/main/java/g0401_0500/s0404_sum_of_left_leaves/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 1 | 29.26 +| 0909 |[Snakes and Ladders](src/main/java/g0901_1000/s0909_snakes_and_ladders/Solution.java)| Medium | Array, Breadth_First_Search, Matrix | 4 | 95.81 +| 0433 |[Minimum Genetic Mutation](src/main/java/g0401_0500/s0433_minimum_genetic_mutation/Solution.java)| Medium | String, Hash_Table, Breadth_First_Search | 0 | 100.00 +| 0127 |[Word Ladder](src/main/java/g0101_0200/s0127_word_ladder/Solution.java)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 22 | 96.00 -#### Day 11 Containers and Libraries +#### Top Interview 150 Trie | | | | | | |-|-|-|-|-|- -| 1356 |[Sort Integers by The Number of 1 Bits](src/main/java/g1301_1400/s1356_sort_integers_by_the_number_of_1_bits/Solution.java)| Easy | Array, Sorting, Bit_Manipulation, Counting | 10 | 65.50 -| 0232 |[Implement Queue using Stacks](src/main/java/g0201_0300/s0232_implement_queue_using_stacks/MyQueue.java)| Easy | Stack, Design, Queue | 1 | 67.21 -| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 -| 0217 |[Contains Duplicate](src/main/java/g0201_0300/s0217_contains_duplicate/Solution.java)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 6 | 96.68 +| 0208 |[Implement Trie (Prefix Tree)](src/main/java/g0201_0300/s0208_implement_trie_prefix_tree/Trie.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Design, Trie, LeetCode_75_Trie, Big_O_Time_O(word.length())_or_O(prefix.length())_Space_O(N) | 32 | 95.05 +| 0211 |[Design Add and Search Words Data Structure](src/main/java/g0201_0300/s0211_design_add_and_search_words_data_structure/WordDictionary.java)| Medium | String, Depth_First_Search, Design, Trie | 156 | 99.85 +| 0212 |[Word Search II](src/main/java/g0201_0300/s0212_word_search_ii/Solution.java)| Hard | Top_Interview_Questions, Array, String, Matrix, Backtracking, Trie | 17 | 99.16 -#### Day 12 Class and Object +#### Top Interview 150 Backtracking | | | | | | |-|-|-|-|-|- -| 1603 |[Design Parking System](src/main/java/g1601_1700/s1603_design_parking_system/ParkingSystem.java)| Easy | Design, Simulation, Counting | 8 | 76.16 -| 0303 |[Range Sum Query - Immutable](src/main/java/g0301_0400/s0303_range_sum_query_immutable/NumArray.java)| Easy | Array, Design, Prefix_Sum | 7 | 100.00 - -### Programming Skills II +| 0017 |[Letter Combinations of a Phone Number](src/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, LeetCode_75_Backtracking, Big_O_Time_O(4^n)_Space_O(n) | 0 | 100.00 +| 0077 |[Combinations](src/main/java/g0001_0100/s0077_combinations/Solution.java)| Medium | Backtracking | 15 | 92.38 +| 0046 |[Permutations](src/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Big_O_Time_O(n\*n!)_Space_O(n+n!) | 1 | 94.08 +| 0039 |[Combination Sum](src/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Big_O_Time_O(2^n)_Space_O(n+2^n) | 1 | 99.99 +| 0052 |[N-Queens II](src/main/java/g0001_0100/s0052_n_queens_ii/Solution.java)| Hard | Backtracking | 0 | 100.00 +| 0022 |[Generate Parentheses](src/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Big_O_Time_O(2^n)_Space_O(n) | 0 | 100.00 +| 0079 |[Word Search](src/main/java/g0001_0100/s0079_word_search/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Backtracking, Big_O_Time_O(4^(m\*n))_Space_O(m\*n) | 64 | 98.51 -#### Day 1 +#### Top Interview 150 Divide and Conquer | | | | | | |-|-|-|-|-|- -| 0896 |[Monotonic Array](src/main/java/g0801_0900/s0896_monotonic_array/Solution.java)| Easy | Array | 2 | 86.21 -| 0028 |[Find the Index of the First Occurrence in a String](src/main/java/g0001_0100/s0028_find_the_index_of_the_first_occurrence_in_a_string/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching | 0 | 100.00 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 +| 0148 |[Sort List](src/main/java/g0101_0200/s0148_sort_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Sorting, Two_Pointers, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(log(N))_Space_O(log(N)) | 9 | 93.90 +| 0427 |[Construct Quad Tree](src/main/java/g0401_0500/s0427_construct_quad_tree/Solution.java)| Medium | Array, Tree, Matrix, Divide_and_Conquer | 0 | 100.00 +| 0023 |[Merge k Sorted Lists](src/main/java/g0001_0100/s0023_merge_k_sorted_lists/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort, Big_O_Time_O(k\*n\*log(k))_Space_O(log(k)) | 1 | 99.86 -#### Day 2 +#### Top Interview 150 Kadane's Algorithm | | | | | | |-|-|-|-|-|- -| 0110 |[Balanced Binary Tree](src/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree | 1 | 98.82 -| 0459 |[Repeated Substring Pattern](src/main/java/g0401_0500/s0459_repeated_substring_pattern/Solution.java)| Easy | String, String_Matching | 8 | 96.64 +| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 +| 0918 |[Maximum Sum Circular Subarray](src/main/java/g0901_1000/s0918_maximum_sum_circular_subarray/Solution.java)| Medium | Array, Dynamic_Programming, Divide_and_Conquer, Queue, Monotonic_Queue | 2 | 99.34 -#### Day 3 +#### Top Interview 150 Binary Search | | | | | | |-|-|-|-|-|- -| 0150 |[Evaluate Reverse Polish Notation](src/main/java/g0101_0200/s0150_evaluate_reverse_polish_notation/Solution.java)| Medium | Top_Interview_Questions, Array, Math, Stack | 6 | 76.50 -| 0066 |[Plus One](src/main/java/g0001_0100/s0066_plus_one/Solution.java)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 +| 0035 |[Search Insert Position](src/main/java/g0001_0100/s0035_search_insert_position/Solution.java)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 +| 0162 |[Find Peak Element](src/main/java/g0101_0200/s0162_find_peak_element/Solution.java)| Medium | Top_Interview_Questions, Array, Binary_Search, LeetCode_75_Binary_Search | 0 | 100.00 +| 0033 |[Search in Rotated Sorted Array](src/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0034 |[Find First and Last Position of Element in Sorted Array](src/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Big_O_Time_O(log_n)_Space_O(1) | 0 | 100.00 +| 0153 |[Find Minimum in Rotated Sorted Array](src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Big_O_Time_O(log_N)_Space_O(log_N) | 0 | 100.00 +| 0004 |[Median of Two Sorted Arrays](src/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer, Big_O_Time_O(log(min(N,M)))_Space_O(1), AI_can_be_used_to_solve_the_task | 1 | 100.00 -#### Day 4 +#### Top Interview 150 Heap | | | | | | |-|-|-|-|-|- -| 1367 |[Linked List in Binary Tree](src/main/java/g1301_1400/s1367_linked_list_in_binary_tree/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 2 | 61.23 -| 0043 |[Multiply Strings](src/main/java/g0001_0100/s0043_multiply_strings/Solution.java)| Medium | String, Math, Simulation | 1 | 100.00 +| 0215 |[Kth Largest Element in an Array](src/main/java/g0201_0300/s0215_kth_largest_element_in_an_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, LeetCode_75_Heap/Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 5 | 70.82 +| 0502 |[IPO](src/main/java/g0501_0600/s0502_ipo/Solution.java)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue | 64 | 97.22 +| 0373 |[Find K Pairs with Smallest Sums](src/main/java/g0301_0400/s0373_find_k_pairs_with_smallest_sums/Solution.java)| Medium | Array, Heap_Priority_Queue | 27 | 90.23 +| 0295 |[Find Median from Data Stream](src/main/java/g0201_0300/s0295_find_median_from_data_stream/MedianFinder.java)| Hard | Top_100_Liked_Questions, Sorting, Two_Pointers, Design, Heap_Priority_Queue, Data_Stream, Big_O_Time_O(n\*log_n)_Space_O(n) | 83 | 99.56 -#### Day 5 +#### Top Interview 150 Bit Manipulation | | | | | | |-|-|-|-|-|- | 0067 |[Add Binary](src/main/java/g0001_0100/s0067_add_binary/Solution.java)| Easy | String, Math, Bit_Manipulation, Simulation | 1 | 99.82 -| 0989 |[Add to Array-Form of Integer](src/main/java/g0901_1000/s0989_add_to_array_form_of_integer/Solution.java)| Easy | Array, Math | 7 | 65.92 +| 0190 |[Reverse Bits](src/main/java/g0101_0200/s0190_reverse_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation, Divide_and_Conquer | 0 | 100.00 +| 0191 |[Number of 1 Bits](src/main/java/g0101_0200/s0191_number_of_1_bits/Solution.java)| Easy | Top_Interview_Questions, Bit_Manipulation | 0 | 100.00 +| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 +| 0137 |[Single Number II](src/main/java/g0101_0200/s0137_single_number_ii/Solution.java)| Medium | Array, Bit_Manipulation | 0 | 100.00 +| 0201 |[Bitwise AND of Numbers Range](src/main/java/g0201_0300/s0201_bitwise_and_of_numbers_range/Solution.java)| Medium | Bit_Manipulation | 3 | 100.00 -#### Day 6 +#### Top Interview 150 Math | | | | | | |-|-|-|-|-|- -| 0739 |[Daily Temperatures](src/main/java/g0701_0800/s0739_daily_temperatures/Solution.java)| Medium | Top_100_Liked_Questions, Array, Stack, Monotonic_Stack, LeetCode_75_Monotonic_Stack, Big_O_Time_O(n)_Space_O(n) | 8 | 96.83 -| 0058 |[Length of Last Word](src/main/java/g0001_0100/s0058_length_of_last_word/Solution.java)| Easy | String | 0 | 100.00 +| 0009 |[Palindrome Number](src/main/java/g0001_0100/s0009_palindrome_number/Solution.java)| Easy | Math, Big_O_Time_O(log10(x))_Space_O(1) | 4 | 100.00 +| 0066 |[Plus One](src/main/java/g0001_0100/s0066_plus_one/Solution.java)| Easy | Top_Interview_Questions, Array, Math | 0 | 100.00 +| 0172 |[Factorial Trailing Zeroes](src/main/java/g0101_0200/s0172_factorial_trailing_zeroes/Solution.java)| Medium | Top_Interview_Questions, Math | 0 | 100.00 +| 0069 |[Sqrt(x)](src/main/java/g0001_0100/s0069_sqrtx/Solution.java)| Easy | Top_Interview_Questions, Math, Binary_Search | 1 | 86.67 +| 0050 |[Pow(x, n)](src/main/java/g0001_0100/s0050_powx_n/Solution.java)| Medium | Top_Interview_Questions, Math, Recursion | 0 | 100.00 +| 0149 |[Max Points on a Line](src/main/java/g0101_0200/s0149_max_points_on_a_line/Solution.java)| Hard | Top_Interview_Questions, Array, Hash_Table, Math, Geometry | 7 | 99.18 -#### Day 7 +#### Top Interview 150 1D DP | | | | | | |-|-|-|-|-|- -| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 -| 1886 |[Determine Whether Matrix Can Be Obtained By Rotation](src/main/java/g1801_1900/s1886_determine_whether_matrix_can_be_obtained_by_rotation/Solution.java)| Easy | Array, Matrix | 1 | 78.38 +| 0070 |[Climbing Stairs](src/main/java/g0001_0100/s0070_climbing_stairs/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0198 |[House Robber](src/main/java/g0101_0200/s0198_house_robber/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, LeetCode_75_DP/1D, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0139 |[Word Break](src/main/java/g0101_0200/s0139_word_break/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Dynamic_Programming, Trie, Memoization, Big_O_Time_O(M+max\*N)_Space_O(M+N+max) | 1 | 99.42 +| 0322 |[Coin Change](src/main/java/g0301_0400/s0322_coin_change/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Breadth_First_Search, Big_O_Time_O(m\*n)_Space_O(amount) | 12 | 92.59 +| 0300 |[Longest Increasing Subsequence](src/main/java/g0201_0300/s0300_longest_increasing_subsequence/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Binary_Search, Big_O_Time_O(n\*log_n)_Space_O(n) | 3 | 95.75 -#### Day 8 +#### Top Interview 150 Multidimensional DP | | | | | | |-|-|-|-|-|- -| 0054 |[Spiral Matrix](src/main/java/g0001_0100/s0054_spiral_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Matrix, Simulation | 0 | 100.00 -| 0973 |[K Closest Points to Origin](src/main/java/g0901_1000/s0973_k_closest_points_to_origin/Solution.java)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 4 | 98.26 - -#### Day 9 +| 0120 |[Triangle](src/main/java/g0101_0200/s0120_triangle/Solution.java)| Medium | Array, Dynamic_Programming | 1 | 99.79 +| 0064 |[Minimum Path Sum](src/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 1 | 99.73 +| 0063 |[Unique Paths II](src/main/java/g0001_0100/s0063_unique_paths_ii/Solution.java)| Medium | Array, Dynamic_Programming, Matrix | 0 | 100.00 +| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 +| 0097 |[Interleaving String](src/main/java/g0001_0100/s0097_interleaving_string/Solution.java)| Medium | String, Dynamic_Programming | 0 | 100.00 +| 0072 |[Edit Distance](src/main/java/g0001_0100/s0072_edit_distance/Solution.java)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, LeetCode_75_DP/Multidimensional, Big_O_Time_O(n^2)_Space_O(n2) | 3 | 97.19 +| 0123 |[Best Time to Buy and Sell Stock III](src/main/java/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/Solution.java)| Hard | Array, Dynamic_Programming | 4 | 74.67 +| 0188 |[Best Time to Buy and Sell Stock IV](src/main/java/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/Solution.java)| Hard | Array, Dynamic_Programming | 1 | 99.73 +| 0221 |[Maximal Square](src/main/java/g0201_0300/s0221_maximal_square/Solution.java)| Medium | Array, Dynamic_Programming, Matrix, Big_O_Time_O(m\*n)_Space_O(m\*n) | 6 | 97.07 -| | | | | | -|-|-|-|-|-|- -| 1630 |[Arithmetic Subarrays](src/main/java/g1601_1700/s1630_arithmetic_subarrays/Solution.java)| Medium | Array, Sorting | 8 | 93.62 -| 0429 |[N-ary Tree Level Order Traversal](src/main/java/g0401_0500/s0429_n_ary_tree_level_order_traversal/Solution.java)| Medium | Breadth_First_Search, Tree | 3 | 80.26 +### Data Structure I -#### Day 10 +#### Day 1 Array | | | | | | |-|-|-|-|-|- -| 0503 |[Next Greater Element II](src/main/java/g0501_0600/s0503_next_greater_element_ii/Solution.java)| Medium | Array, Stack, Monotonic_Stack | 7 | 97.03 -| 0556 |[Next Greater Element III](src/main/java/g0501_0600/s0556_next_greater_element_iii/Solution.java)| Medium | String, Math, Two_Pointers | 0 | 100.00 +| 0217 |[Contains Duplicate](src/main/java/g0201_0300/s0217_contains_duplicate/Solution.java)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 6 | 96.68 +| 0053 |[Maximum Subarray](src/main/java/g0001_0100/s0053_maximum_subarray/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.32 -#### Day 11 +#### Day 2 Array | | | | | | |-|-|-|-|-|- -| 1376 |[Time Needed to Inform All Employees](src/main/java/g1301_1400/s1376_time_needed_to_inform_all_employees/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree | 8 | 99.85 -| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 +| 0001 |[Two Sum](src/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n), AI_can_be_used_to_solve_the_task | 2 | 98.90 +| 0088 |[Merge Sorted Array](src/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Sorting, Two_Pointers | 0 | 100.00 -#### Day 12 +#### Day 3 Array | | | | | | |-|-|-|-|-|- -| 0438 |[Find All Anagrams in a String](src/main/java/g0401_0500/s0438_find_all_anagrams_in_a_string/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 3 | 99.83 -| 0713 |[Subarray Product Less Than K](src/main/java/g0701_0800/s0713_subarray_product_less_than_k/Solution.java)| Medium | Array, Sliding_Window | 8 | 39.00 +| 0350 |[Intersection of Two Arrays II](src/main/java/g0301_0400/s0350_intersection_of_two_arrays_ii/Solution.java)| Easy | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 4 | 69.62 +| 0121 |[Best Time to Buy and Sell Stock](src/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 1 | 99.78 -#### Day 13 +#### Day 4 Array | | | | | | |-|-|-|-|-|- -| 0304 |[Range Sum Query 2D - Immutable](src/main/java/g0301_0400/s0304_range_sum_query_2d_immutable/NumMatrix.java)| Medium | Array, Matrix, Design, Prefix_Sum | 153 | 87.51 -| 0910 |[Smallest Range II](src/main/java/g0901_1000/s0910_smallest_range_ii/Solution.java)| Medium | Array, Math, Sorting, Greedy | 10 | 73.16 +| 0566 |[Reshape the Matrix](src/main/java/g0501_0600/s0566_reshape_the_matrix/Solution.java)| Easy | Array, Matrix, Simulation | 1 | 90.08 +| 0118 |[Pascal's Triangle](src/main/java/g0101_0200/s0118_pascals_triangle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 1 | 67.08 -#### Day 14 +#### Day 5 Array | | | | | | |-|-|-|-|-|- -| 0143 |[Reorder List](src/main/java/g0101_0200/s0143_reorder_list/Solution.java)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 2 | 72.59 -| 0138 |[Copy List with Random Pointer](src/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00 +| 0036 |[Valid Sudoku](src/main/java/g0001_0100/s0036_valid_sudoku/Solution.java)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix | 1 | 100.00 +| 0074 |[Search a 2D Matrix](src/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Big_O_Time_O(endRow+endCol)_Space_O(1) | 0 | 100.00 -#### Day 15 +#### Day 6 String | | | | | | |-|-|-|-|-|- -| 0002 |[Add Two Numbers](src/main/java/g0001_0100/s0002_add_two_numbers/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 1 | 100.00 -| 0445 |[Add Two Numbers II](src/main/java/g0401_0500/s0445_add_two_numbers_ii/Solution.java)| Medium | Math, Stack, Linked_List | 3 | 90.38 +| 0387 |[First Unique Character in a String](src/main/java/g0301_0400/s0387_first_unique_character_in_a_string/Solution.java)| Easy | String, Hash_Table, Counting, Queue | 1 | 100.00 +| 0383 |[Ransom Note](src/main/java/g0301_0400/s0383_ransom_note/Solution.java)| Easy | String, Hash_Table, Counting | 1 | 99.10 +| 0242 |[Valid Anagram](src/main/java/g0201_0300/s0242_valid_anagram/Solution.java)| Easy | String, Hash_Table, Sorting | 2 | 97.76 -#### Day 16 +#### Day 7 Linked List | | | | | | |-|-|-|-|-|- -| 0061 |[Rotate List](src/main/java/g0001_0100/s0061_rotate_list/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 -| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 +| 0141 |[Linked List Cycle](src/main/java/g0101_0200/s0141_linked_list_cycle/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0021 |[Merge Two Sorted Lists](src/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 0 | 100.00 +| 0203 |[Remove Linked List Elements](src/main/java/g0201_0300/s0203_remove_linked_list_elements/Solution.java)| Easy | Linked_List, Recursion | 1 | 98.82 -#### Day 17 +#### Day 8 Linked List | | | | | | |-|-|-|-|-|- -| 1845 |[Seat Reservation Manager](src/main/java/g1801_1900/s1845_seat_reservation_manager/SeatManager.java)| Medium | Design, Heap_Priority_Queue | 47 | 87.63 -| 0860 |[Lemonade Change](src/main/java/g0801_0900/s0860_lemonade_change/Solution.java)| Easy | Array, Greedy | 2 | 90.84 +| 0206 |[Reverse Linked List](src/main/java/g0201_0300/s0206_reverse_linked_list/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, LeetCode_75_LinkedList, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 +| 0083 |[Remove Duplicates from Sorted List](src/main/java/g0001_0100/s0083_remove_duplicates_from_sorted_list/Solution.java)| Easy | Linked_List | 0 | 100.00 -#### Day 18 +#### Day 9 Stack Queue | | | | | | |-|-|-|-|-|- -| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 -| 0341 |[Flatten Nested List Iterator](src/main/java/g0301_0400/s0341_flatten_nested_list_iterator/NestedIterator.java)| Medium | Depth_First_Search, Tree, Stack, Design, Queue, Iterator | 2 | 99.95 +| 0020 |[Valid Parentheses](src/main/java/g0001_0100/s0020_valid_parentheses/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Big_O_Time_O(n)_Space_O(n) | 2 | 97.19 +| 0232 |[Implement Queue using Stacks](src/main/java/g0201_0300/s0232_implement_queue_using_stacks/MyQueue.java)| Easy | Stack, Design, Queue | 1 | 67.21 -#### Day 19 +#### Day 10 Tree | | | | | | |-|-|-|-|-|- -| 1797 |[Design Authentication Manager](src/main/java/g1701_1800/s1797_design_authentication_manager/AuthenticationManager.java)| Medium | Hash_Table, Design | 41 | 92.67 -| 0707 |[Design Linked List](src/main/java/g0701_0800/s0707_design_linked_list/MyLinkedList.java)| Medium | Design, Linked_List | 10 | 70.60 +| 0144 |[Binary Tree Preorder Traversal](src/main/java/g0101_0200/s0144_binary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 48.38 +| 0094 |[Binary Tree Inorder Traversal](src/main/java/g0001_0100/s0094_binary_tree_inorder_traversal/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0145 |[Binary Tree Postorder Traversal](src/main/java/g0101_0200/s0145_binary_tree_postorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Stack | 1 | 49.11 -#### Day 20 +#### Day 11 Tree | | | | | | |-|-|-|-|-|- -| 0380 |[Insert Delete GetRandom O(1)](src/main/java/g0301_0400/s0380_insert_delete_getrandom_o1/RandomizedSet.java)| Medium | Array, Hash_Table, Math, Design, Randomized | 27 | 93.44 -| 0622 |[Design Circular Queue](src/main/java/g0601_0700/s0622_design_circular_queue/MyCircularQueue.java)| Medium | Array, Design, Linked_List, Queue | 3 | 100.00 -| 0729 |[My Calendar I](src/main/java/g0701_0800/s0729_my_calendar_i/MyCalendar.java)| Medium | Binary_Search, Design, Ordered_Set, Segment_Tree | 17 | 97.23 - -### Graph Theory I +| 0102 |[Binary Tree Level Order Traversal](src/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 1 | 91.19 +| 0104 |[Maximum Depth of Binary Tree](src/main/java/g0101_0200/s0104_maximum_depth_of_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(N)_Space_O(H) | 0 | 100.00 +| 0101 |[Symmetric Tree](src/main/java/g0101_0200/s0101_symmetric_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 -#### Day 1 Matrix Related Problems +#### Day 12 Tree | | | | | | |-|-|-|-|-|- -| 0733 |[Flood Fill](src/main/java/g0701_0800/s0733_flood_fill/Solution.java)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 1 | 85.36 -| 0200 |[Number of Islands](src/main/java/g0101_0200/s0200_number_of_islands/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 3 | 87.24 +| 0226 |[Invert Binary Tree](src/main/java/g0201_0300/s0226_invert_binary_tree/Solution.java)| Easy | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0112 |[Path Sum](src/main/java/g0101_0200/s0112_path_sum/Solution.java)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -#### Day 2 Matrix Related Problems +#### Day 13 Tree | | | | | | |-|-|-|-|-|- -| 0695 |[Max Area of Island](src/main/java/g0601_0700/s0695_max_area_of_island/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 3 | 76.79 -| 1254 |[Number of Closed Islands](src/main/java/g1201_1300/s1254_number_of_closed_islands/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 3 | 55.59 +| 0700 |[Search in a Binary Search Tree](src/main/java/g0601_0700/s0700_search_in_a_binary_search_tree/Solution.java)| Easy | Tree, Binary_Tree, Binary_Search_Tree, LeetCode_75_Binary_Search_Tree | 0 | 100.00 +| 0701 |[Insert into a Binary Search Tree](src/main/java/g0701_0800/s0701_insert_into_a_binary_search_tree/Solution.java)| Medium | Tree, Binary_Tree, Binary_Search_Tree | 0 | 100.00 -#### Day 3 Matrix Related Problems +#### Day 14 Tree | | | | | | |-|-|-|-|-|- -| 1020 |[Number of Enclaves](src/main/java/g1001_1100/s1020_number_of_enclaves/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 6 | 68.24 -| 1905 |[Count Sub Islands](src/main/java/g1901_2000/s1905_count_sub_islands/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find | 24 | 85.54 +| 0098 |[Validate Binary Search Tree](src/main/java/g0001_0100/s0098_validate_binary_search_tree/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 0 | 100.00 +| 0653 |[Two Sum IV - Input is a BST](src/main/java/g0601_0700/s0653_two_sum_iv_input_is_a_bst/Solution.java)| Easy | Hash_Table, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Two_Pointers, Binary_Search_Tree | 5 | 74.23 +| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/java/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 4 | 100.00 -#### Day 4 Matrix Related Problems +### Data Structure II + +#### Day 1 Array | | | | | | |-|-|-|-|-|- -| 1162 |[As Far from Land as Possible](src/main/java/g1101_1200/s1162_as_far_from_land_as_possible/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 16 | 62.40 -| 0417 |[Pacific Atlantic Water Flow](src/main/java/g0401_0500/s0417_pacific_atlantic_water_flow/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 5 | 92.62 +| 0136 |[Single Number](src/main/java/g0101_0200/s0136_single_number/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Bit_Manipulation, LeetCode_75_Bit_Manipulation, Big_O_Time_O(N)_Space_O(1) | 1 | 99.86 +| 0169 |[Majority Element](src/main/java/g0101_0200/s0169_majority_element/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Counting, Divide_and_Conquer, Big_O_Time_O(n)_Space_O(1) | 1 | 99.89 +| 0015 |[3Sum](src/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n\*log(n))_Space_O(n^2) | 29 | 72.02 -#### Day 5 Matrix Related Problems +#### Day 2 Array | | | | | | |-|-|-|-|-|- -| 1091 |[Shortest Path in Binary Matrix](src/main/java/g1001_1100/s1091_shortest_path_in_binary_matrix/Solution.java)| Medium | Array, Breadth_First_Search, Matrix | 22 | 69.99 -| 0542 |[01 Matrix](src/main/java/g0501_0600/s0542_01_matrix/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search, Matrix | 7 | 95.83 +| 0075 |[Sort Colors](src/main/java/g0001_0100/s0075_sort_colors/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0056 |[Merge Intervals](src/main/java/g0001_0100/s0056_merge_intervals/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Big_O_Time_O(n_log_n)_Space_O(n) | 7 | 98.37 +| 0706 |[Design HashMap](src/main/java/g0701_0800/s0706_design_hashmap/MyHashMap.java)| Easy | Array, Hash_Table, Design, Linked_List, Hash_Function | 13 | 95.71 -#### Day 6 Matrix Related Problems +#### Day 3 Array | | | | | | |-|-|-|-|-|- -| 0934 |[Shortest Bridge](src/main/java/g0901_1000/s0934_shortest_bridge/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search, Matrix | 6 | 97.87 -| 1926 |[Nearest Exit from Entrance in Maze](src/main/java/g1901_2000/s1926_nearest_exit_from_entrance_in_maze/Solution.java)| Medium | Array, Breadth_First_Search, Matrix, LeetCode_75_Graphs/BFS | 12 | 40.55 +| 0119 |[Pascal's Triangle II](src/main/java/g0101_0200/s0119_pascals_triangle_ii/Solution.java)| Easy | Array, Dynamic_Programming | 0 | 100.00 +| 0048 |[Rotate Image](src/main/java/g0001_0100/s0048_rotate_image/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Math, Matrix, Big_O_Time_O(n^2)_Space_O(1) | 0 | 100.00 +| 0059 |[Spiral Matrix II](src/main/java/g0001_0100/s0059_spiral_matrix_ii/Solution.java)| Medium | Array, Matrix, Simulation | 0 | 100.00 -#### Day 7 Standard Traversal +#### Day 4 Array | | | | | | |-|-|-|-|-|- -| 0797 |[All Paths From Source to Target](src/main/java/g0701_0800/s0797_all_paths_from_source_to_target/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Backtracking | 2 | 90.53 -| 0841 |[Keys and Rooms](src/main/java/g0801_0900/s0841_keys_and_rooms/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, LeetCode_75_Graphs/DFS | 3 | 51.54 +| 0240 |[Search a 2D Matrix II](src/main/java/g0201_0300/s0240_search_a_2d_matrix_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Binary_Search, Matrix, Divide_and_Conquer, Big_O_Time_O(n+m)_Space_O(1) | 5 | 99.92 +| 0435 |[Non-overlapping Intervals](src/main/java/g0401_0500/s0435_non_overlapping_intervals/Solution.java)| Medium | Array, Dynamic_Programming, Sorting, Greedy, LeetCode_75_Intervals | 96 | 47.37 -#### Day 8 Standard Traversal +#### Day 5 Array | | | | | | |-|-|-|-|-|- -| 0547 |[Number of Provinces](src/main/java/g0501_0600/s0547_number_of_provinces/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find, LeetCode_75_Graphs/DFS | 2 | 69.51 -| 1319 |[Number of Operations to Make Network Connected](src/main/java/g1301_1400/s1319_number_of_operations_to_make_network_connected/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 9 | 67.64 +| 0334 |[Increasing Triplet Subsequence](src/main/java/g0301_0400/s0334_increasing_triplet_subsequence/Solution.java)| Medium | Array, Greedy, LeetCode_75_Array/String | 2 | 99.33 +| 0238 |[Product of Array Except Self](src/main/java/g0201_0300/s0238_product_of_array_except_self/Solution.java)| Medium | Top_100_Liked_Questions, Array, Prefix_Sum, LeetCode_75_Array/String, Big_O_Time_O(n^2)_Space_O(n) | 1 | 99.66 +| 0560 |[Subarray Sum Equals K](src/main/java/g0501_0600/s0560_subarray_sum_equals_k/Solution.java)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum, Big_O_Time_O(n)_Space_O(n) | 22 | 95.17 -#### Day 9 Standard Traversal +#### Day 6 String | | | | | | |-|-|-|-|-|- -| 1376 |[Time Needed to Inform All Employees](src/main/java/g1301_1400/s1376_time_needed_to_inform_all_employees/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Tree | 8 | 99.85 -| 0802 |[Find Eventual Safe States](src/main/java/g0801_0900/s0802_find_eventual_safe_states/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Topological_Sort | 7 | 74.93 +| 0415 |[Add Strings](src/main/java/g0401_0500/s0415_add_strings/Solution.java)| Easy | String, Math, Simulation | 3 | 82.41 +| 0409 |[Longest Palindrome](src/main/java/g0401_0500/s0409_longest_palindrome/Solution.java)| Easy | String, Hash_Table, Greedy | 2 | 92.90 -#### Day 10 Standard Traversal +#### Day 7 String | | | | | | |-|-|-|-|-|- -| 1129 |[Shortest Path with Alternating Colors](src/main/java/g1101_1200/s1129_shortest_path_with_alternating_colors/Solution.java)| Medium | Breadth_First_Search, Graph | 4 | 96.63 -| 1466 |[Reorder Routes to Make All Paths Lead to the City Zero](src/main/java/g1401_1500/s1466_reorder_routes_to_make_all_paths_lead_to_the_city_zero/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, LeetCode_75_Graphs/DFS | 39 | 97.71 -| 0847 |[Shortest Path Visiting All Nodes](src/main/java/g0801_0900/s0847_shortest_path_visiting_all_nodes/Solution.java)| Hard | Dynamic_Programming, Breadth_First_Search, Bit_Manipulation, Graph, Bitmask | 14 | 78.72 +| 0290 |[Word Pattern](src/main/java/g0201_0300/s0290_word_pattern/Solution.java)| Easy | String, Hash_Table | 0 | 100.00 +| 0763 |[Partition Labels](src/main/java/g0701_0800/s0763_partition_labels/Solution.java)| Medium | Top_100_Liked_Questions, String, Hash_Table, Greedy, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 2 | 100.00 -#### Day 11 Breadth First Search +#### Day 8 String | | | | | | |-|-|-|-|-|- -| 1306 |[Jump Game III](src/main/java/g1301_1400/s1306_jump_game_iii/Solution.java)| Medium | Array, Depth_First_Search, Breadth_First_Search | 2 | 96.23 -| 1654 |[Minimum Jumps to Reach Home](src/main/java/g1601_1700/s1654_minimum_jumps_to_reach_home/Solution.java)| Medium | Array, Dynamic_Programming, Breadth_First_Search | 6 | 99.87 -| 0365 |[Water and Jug Problem](src/main/java/g0301_0400/s0365_water_and_jug_problem/Solution.java)| Medium | Math, Depth_First_Search, Breadth_First_Search | 0 | 100.00 +| 0049 |[Group Anagrams](src/main/java/g0001_0100/s0049_group_anagrams/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, String, Hash_Table, Sorting, Big_O_Time_O(n\*k_log_k)_Space_O(n) | 6 | 97.61 +| 0043 |[Multiply Strings](src/main/java/g0001_0100/s0043_multiply_strings/Solution.java)| Medium | String, Math, Simulation | 1 | 100.00 -#### Day 12 Breadth First Search +#### Day 9 String | | | | | | |-|-|-|-|-|- -| 0433 |[Minimum Genetic Mutation](src/main/java/g0401_0500/s0433_minimum_genetic_mutation/Solution.java)| Medium | String, Hash_Table, Breadth_First_Search | 0 | 100.00 -| 0752 |[Open the Lock](src/main/java/g0701_0800/s0752_open_the_lock/Solution.java)| Medium | Array, String, Hash_Table, Breadth_First_Search | 72 | 91.06 -| 0127 |[Word Ladder](src/main/java/g0101_0200/s0127_word_ladder/Solution.java)| Hard | Top_Interview_Questions, String, Hash_Table, Breadth_First_Search | 22 | 96.00 +| 0187 |[Repeated DNA Sequences](src/main/java/g0101_0200/s0187_repeated_dna_sequences/Solution.java)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 29 | 77.11 +| 0005 |[Longest Palindromic Substring](src/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Big_O_Time_O(n)_Space_O(n) | 7 | 97.82 -#### Day 13 Graph Theory +#### Day 10 Linked List | | | | | | |-|-|-|-|-|- -| 0997 |[Find the Town Judge](src/main/java/g0901_1000/s0997_find_the_town_judge/Solution.java)| Easy | Array, Hash_Table, Graph | 3 | 80.64 -| 1557 |[Minimum Number of Vertices to Reach All Nodes](src/main/java/g1501_1600/s1557_minimum_number_of_vertices_to_reach_all_nodes/Solution.java)| Medium | Graph | 8 | 99.94 +| 0002 |[Add Two Numbers](src/main/java/g0001_0100/s0002_add_two_numbers/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Big_O_Time_O(max(N,M))_Space_O(max(N,M)), AI_can_be_used_to_solve_the_task | 1 | 100.00 +| 0142 |[Linked List Cycle II](src/main/java/g0101_0200/s0142_linked_list_cycle_ii/Solution.java)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 0 | 100.00 -#### Day 14 Graph Theory +#### Day 11 Linked List | | | | | | |-|-|-|-|-|- -| 1615 |[Maximal Network Rank](src/main/java/g1601_1700/s1615_maximal_network_rank/Solution.java)| Medium | Graph | 3 | 97.34 -| 0886 |[Possible Bipartition](src/main/java/g0801_0900/s0886_possible_bipartition/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 20 | 80.12 -| 0785 |[Is Graph Bipartite?](src/main/java/g0701_0800/s0785_is_graph_bipartite/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 0 | 100.00 - -### SQL I +| 0160 |[Intersection of Two Linked Lists](src/main/java/g0101_0200/s0160_intersection_of_two_linked_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(M+N)_Space_O(1) | 1 | 99.92 +| 0082 |[Remove Duplicates from Sorted List II](src/main/java/g0001_0100/s0082_remove_duplicates_from_sorted_list_ii/Solution.java)| Medium | Two_Pointers, Linked_List | 0 | 100.00 -#### Day 1 Select +#### Day 12 Linked List | | | | | | |-|-|-|-|-|- -| 0595 |[Big Countries](src/main/java/g0501_0600/s0595_big_countries/script.sql)| Easy | Database | 262 | 84.64 -| 1757 |[Recyclable and Low Fat Products](src/main/java/g1701_1800/s1757_recyclable_and_low_fat_products/script.sql)| Easy | Database | 475 | 71.54 -| 0584 |[Find Customer Referee](src/main/java/g0501_0600/s0584_find_customer_referee/script.sql)| Easy | Database | 531 | 58.63 -| 0183 |[Customers Who Never Order](src/main/java/g0101_0200/s0183_customers_who_never_order/script.sql)| Easy | Database | 376 | 98.73 +| 0024 |[Swap Nodes in Pairs](src/main/java/g0001_0100/s0024_swap_nodes_in_pairs/Solution.java)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(1) | 0 | 100.00 +| 0707 |[Design Linked List](src/main/java/g0701_0800/s0707_design_linked_list/MyLinkedList.java)| Medium | Design, Linked_List | 10 | 70.60 -#### Day 2 Select and Order +#### Day 13 Linked List | | | | | | |-|-|-|-|-|- -| 1873 |[Calculate Special Bonus](src/main/java/g1801_1900/s1873_calculate_special_bonus/script.sql)| Easy | Database | 543 | 71.60 -| 0627 |[Swap Salary](src/main/java/g0601_0700/s0627_swap_salary/script.sql)| Easy | Database | 191 | 96.89 -| 0196 |[Delete Duplicate Emails](src/main/java/g0101_0200/s0196_delete_duplicate_emails/script.sql)| Easy | Database | 903 | 48.10 +| 0025 |[Reverse Nodes in k-Group](src/main/java/g0001_0100/s0025_reverse_nodes_in_k_group/Solution.java)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Big_O_Time_O(n)_Space_O(k) | 0 | 100.00 +| 0143 |[Reorder List](src/main/java/g0101_0200/s0143_reorder_list/Solution.java)| Medium | Two_Pointers, Stack, Linked_List, Recursion | 2 | 72.59 -#### Day 3 String Processing Functions +#### Day 14 Stack Queue | | | | | | |-|-|-|-|-|- -| 1667 |[Fix Names in a Table](src/main/java/g1601_1700/s1667_fix_names_in_a_table/script.sql)| Easy | Database | 559 | 80.29 -| 1484 |[Group Sold Products By The Date](src/main/java/g1401_1500/s1484_group_sold_products_by_the_date/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 395 | 77.20 -| 1527 |[Patients With a Condition](src/main/java/g1501_1600/s1527_patients_with_a_condition/script.sql)| Easy | Database | 308 | 66.93 +| 0155 |[Min Stack](src/main/java/g0101_0200/s0155_min_stack/MinStack.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Stack, Design, Big_O_Time_O(1)_Space_O(N) | 4 | 96.54 +| 1249 |[Minimum Remove to Make Valid Parentheses](src/main/java/g1201_1300/s1249_minimum_remove_to_make_valid_parentheses/Solution.java)| Medium | String, Stack | 13 | 94.62 +| 1823 |[Find the Winner of the Circular Game](src/main/java/g1801_1900/s1823_find_the_winner_of_the_circular_game/Solution.java)| Medium | Array, Math, Simulation, Recursion, Queue | 3 | 64.85 -#### Day 4 Union and Select +#### Day 15 Tree | | | | | | |-|-|-|-|-|- -| 1965 |[Employees With Missing Information](src/main/java/g1901_2000/s1965_employees_with_missing_information/script.sql)| Easy | Database | 617 | 30.40 -| 1795 |[Rearrange Products Table](src/main/java/g1701_1800/s1795_rearrange_products_table/script.sql)| Easy | Database | 497 | 64.83 -| 0608 |[Tree Node](src/main/java/g0601_0700/s0608_tree_node/script.sql)| Medium | LeetCode_Curated_SQL_70, Database | 347 | 95.17 -| 0176 |[Second Highest Salary](src/main/java/g0101_0200/s0176_second_highest_salary/script.sql)| Medium | Database | 225 | 73.10 +| 0108 |[Convert Sorted Array to Binary Search Tree](src/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Tree, Binary_Tree, Binary_Search_Tree, Divide_and_Conquer | 0 | 100.00 +| 0105 |[Construct Binary Tree from Preorder and Inorder Traversal](src/main/java/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Tree, Binary_Tree, Divide_and_Conquer, Big_O_Time_O(N)_Space_O(N) | 1 | 96.33 +| 0103 |[Binary Tree Zigzag Level Order Traversal](src/main/java/g0101_0200/s0103_binary_tree_zigzag_level_order_traversal/Solution.java)| Medium | Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree | 0 | 100.00 -#### Day 5 Union +#### Day 16 Tree | | | | | | |-|-|-|-|-|- -| 0175 |[Combine Two Tables](src/main/java/g0101_0200/s0175_combine_two_tables/script.sql)| Easy | Database | 491 | 32.30 -| 1581 |[Customer Who Visited but Did Not Make Any Transactions](src/main/java/g1501_1600/s1581_customer_who_visited_but_did_not_make_any_transactions/script.sql)| Easy | Database | 1039 | 76.99 -| 1148 |[Article Views I](src/main/java/g1101_1200/s1148_article_views_i/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 783 | 64.09 +| 0199 |[Binary Tree Right Side View](src/main/java/g0101_0200/s0199_binary_tree_right_side_view/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/BFS | 0 | 100.00 +| 0113 |[Path Sum II](src/main/java/g0101_0200/s0113_path_sum_ii/Solution.java)| Medium | Depth_First_Search, Tree, Binary_Tree, Backtracking | 1 | 100.00 +| 0450 |[Delete Node in a BST](src/main/java/g0401_0500/s0450_delete_node_in_a_bst/Solution.java)| Medium | Tree, Binary_Tree, Binary_Search_Tree, LeetCode_75_Binary_Search_Tree | 0 | 100.00 -#### Day 6 Union +#### Day 17 Tree | | | | | | |-|-|-|-|-|- -| 0197 |[Rising Temperature](src/main/java/g0101_0200/s0197_rising_temperature/script.sql)| Easy | Database | 342 | 93.76 -| 0607 |[Sales Person](src/main/java/g0601_0700/s0607_sales_person/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 1046 | 86.04 +| 0230 |[Kth Smallest Element in a BST](src/main/java/g0201_0300/s0230_kth_smallest_element_in_a_bst/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(n)_Space_O(n) | 0 | 100.00 +| 0173 |[Binary Search Tree Iterator](src/main/java/g0101_0200/s0173_binary_search_tree_iterator/BSTIterator.java)| Medium | Tree, Binary_Tree, Stack, Design, Binary_Search_Tree, Iterator | 15 | 100.00 -#### Day 7 Function +#### Day 18 Tree | | | | | | |-|-|-|-|-|- -| 1141 |[User Activity for the Past 30 Days I](src/main/java/g1101_1200/s1141_user_activity_for_the_past_30_days_i/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 849 | 72.54 -| 1693 |[Daily Leads and Partners](src/main/java/g1601_1700/s1693_daily_leads_and_partners/script.sql)| Easy | Database | 463 | 78.98 -| 1729 |[Find Followers Count](src/main/java/g1701_1800/s1729_find_followers_count/script.sql)| Easy | Database | 456 | 88.39 +| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/java/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution.java)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, LeetCode_75_Binary_Tree/DFS, Big_O_Time_O(n)_Space_O(n) | 6 | 100.00 +| 0297 |[Serialize and Deserialize Binary Tree](src/main/java/g0201_0300/s0297_serialize_and_deserialize_binary_tree/Codec.java)| Hard | String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 7 | 98.13 -#### Day 8 Function +#### Day 19 Graph | | | | | | |-|-|-|-|-|- -| 0586 |[Customer Placing the Largest Number of Orders](src/main/java/g0501_0600/s0586_customer_placing_the_largest_number_of_orders/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 484 | 66.42 -| 0511 |[Game Play Analysis I](src/main/java/g0501_0600/s0511_game_play_analysis_i/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 586 | 56.94 -| 1890 |[The Latest Login in 2020](src/main/java/g1801_1900/s1890_the_latest_login_in_2020/script.sql)| Easy | Database | 571 | 73.59 -| 1741 |[Find Total Time Spent by Each Employee](src/main/java/g1701_1800/s1741_find_total_time_spent_by_each_employee/script.sql)| Easy | Database | 414 | 93.27 +| 0997 |[Find the Town Judge](src/main/java/g0901_1000/s0997_find_the_town_judge/Solution.java)| Easy | Array, Hash_Table, Graph | 3 | 80.64 +| 1557 |[Minimum Number of Vertices to Reach All Nodes](src/main/java/g1501_1600/s1557_minimum_number_of_vertices_to_reach_all_nodes/Solution.java)| Medium | Graph | 8 | 99.94 +| 0841 |[Keys and Rooms](src/main/java/g0801_0900/s0841_keys_and_rooms/Solution.java)| Medium | Depth_First_Search, Breadth_First_Search, Graph, LeetCode_75_Graphs/DFS | 3 | 51.54 -#### Day 9 Control of Flow +#### Day 20 Heap Priority Queue | | | | | | |-|-|-|-|-|- -| 1393 |[Capital Gain/Loss](src/main/java/g1301_1400/s1393_capital_gainloss/script.sql)| Medium | LeetCode_Curated_SQL_70, Database | 428 | 92.01 -| 1407 |[Top Travellers](src/main/java/g1401_1500/s1407_top_travellers/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 682 | 70.16 -| 1158 |[Market Analysis I](src/main/java/g1101_1200/s1158_market_analysis_i/script.sql)| Medium | Database | 2511 | 78.92 +| 0215 |[Kth Largest Element in an Array](src/main/java/g0201_0300/s0215_kth_largest_element_in_an_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Quickselect, LeetCode_75_Heap/Priority_Queue, Big_O_Time_O(n\*log(n))_Space_O(log(n)) | 5 | 70.82 +| 0347 |[Top K Frequent Elements](src/main/java/g0301_0400/s0347_top_k_frequent_elements/Solution.java)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Big_O_Time_O(n\*log(n))_Space_O(k) | 9 | 97.30 -#### Day 10 Where +#### Day 21 Heap Priority Queue | | | | | | |-|-|-|-|-|- -| 0182 |[Duplicate Emails](src/main/java/g0101_0200/s0182_duplicate_emails/script.sql)| Easy | Database | 303 | 92.08 -| 1050 |[Actors and Directors Who Cooperated At Least Three Times](src/main/java/g1001_1100/s1050_actors_and_directors_who_cooperated_at_least_three_times/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 344 | 76.48 -| 1587 |[Bank Account Summary II](src/main/java/g1501_1600/s1587_bank_account_summary_ii/script.sql)| Easy | Database | 630 | 60.32 -| 1084 |[Sales Analysis III](src/main/java/g1001_1100/s1084_sales_analysis_iii/script.sql)| Easy | LeetCode_Curated_SQL_70, Database | 1066 | 69.71 +| 0451 |[Sort Characters By Frequency](src/main/java/g0401_0500/s0451_sort_characters_by_frequency/Solution.java)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Bucket_Sort | 13 | 89.63 +| 0973 |[K Closest Points to Origin](src/main/java/g0901_1000/s0973_k_closest_points_to_origin/Solution.java)| Medium | Array, Math, Sorting, Heap_Priority_Queue, Divide_and_Conquer, Geometry, Quickselect | 4 | 98.26 ## Contributing Your ideas/fixes/algorithms are more than welcome! diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60c7..b1b8ef56b 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bad7c2462..b52fb7e71 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,9 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip networkTimeout=10000 +retries=0 +retryBackOffMs=500 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index adff685a0..b9bb139f7 100644 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/gradlew.bat b/gradlew.bat index c4bdd3ab8..24c62d56f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -23,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -51,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -65,7 +65,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line @@ -73,21 +73,10 @@ goto fail @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/pom.xml b/pom.xml index a0c540658..bb231698f 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.1 + 3.15.0 17 17 @@ -55,7 +55,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.4 + 3.5.5 org.junit.jupiter @@ -123,7 +123,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.1 + 3.4.0 attach-sources diff --git a/src/main/java/g1901_2000/s1968_array_with_elements_not_equal_to_average_of_neighbors/Solution.java b/src/main/java/g1901_2000/s1968_array_with_elements_not_equal_to_average_of_neighbors/Solution.java index 946ce8d8e..b1cf4d977 100644 --- a/src/main/java/g1901_2000/s1968_array_with_elements_not_equal_to_average_of_neighbors/Solution.java +++ b/src/main/java/g1901_2000/s1968_array_with_elements_not_equal_to_average_of_neighbors/Solution.java @@ -5,6 +5,7 @@ import java.security.SecureRandom; import java.util.Random; +@SuppressWarnings("java:S2119") public class Solution { public int[] rearrangeArray(int[] nums) { Random random = new SecureRandom(); diff --git a/src/main/java/g2001_2100/s2086_minimum_number_of_buckets_required_to_collect_rainwater_from_houses/readme.md b/src/main/java/g2001_2100/s2086_minimum_number_of_buckets_required_to_collect_rainwater_from_houses/readme.md index 7bf087d94..8eaaf30b7 100644 --- a/src/main/java/g2001_2100/s2086_minimum_number_of_buckets_required_to_collect_rainwater_from_houses/readme.md +++ b/src/main/java/g2001_2100/s2086_minimum_number_of_buckets_required_to_collect_rainwater_from_houses/readme.md @@ -2,7 +2,7 @@ Medium -You are given a **0-index****ed** string `street`. Each character in `street` is either `'H'` representing a house or `'.'` representing an empty space. +You are given a **0-indexed** string `street`. Each character in `street` is either `'H'` representing a house or `'.'` representing an empty space. You can place buckets on the **empty spaces** to collect rainwater that falls from the adjacent houses. The rainwater from a house at index `i` is collected if a bucket is placed at index `i - 1` **and/or** index `i + 1`. A single bucket, if placed adjacent to two houses, can collect the rainwater from **both** houses. diff --git a/src/main/java/g2801_2900/s2862_maximum_element_sum_of_a_complete_subset_of_indices/readme.md b/src/main/java/g2801_2900/s2862_maximum_element_sum_of_a_complete_subset_of_indices/readme.md index ceae0b536..f13c5d4a1 100644 --- a/src/main/java/g2801_2900/s2862_maximum_element_sum_of_a_complete_subset_of_indices/readme.md +++ b/src/main/java/g2801_2900/s2862_maximum_element_sum_of_a_complete_subset_of_indices/readme.md @@ -2,7 +2,7 @@ Hard -You are given a **1****\-indexed** array `nums` of `n` integers. +You are given a **1\-indexed** array `nums` of `n` integers. A set of numbers is **complete** if the product of every pair of its elements is a perfect square. diff --git a/src/main/java/g2801_2900/s2871_split_array_into_maximum_number_of_subarrays/readme.md b/src/main/java/g2801_2900/s2871_split_array_into_maximum_number_of_subarrays/readme.md index 2aa845374..30b80a2b8 100644 --- a/src/main/java/g2801_2900/s2871_split_array_into_maximum_number_of_subarrays/readme.md +++ b/src/main/java/g2801_2900/s2871_split_array_into_maximum_number_of_subarrays/readme.md @@ -8,7 +8,7 @@ We define the score of subarray `nums[l..r]` such that `l <= r` as `nums[l] AND Consider splitting the array into one or more subarrays such that the following conditions are satisfied: -* **E****ach** element of the array belongs to **exactly** one subarray. +* **Each** element of the array belongs to **exactly** one subarray. * The sum of scores of the subarrays is the **minimum** possible. Return _the **maximum** number of subarrays in a split that satisfies the conditions above._ diff --git a/src/main/java/g3501_3600/s3509_maximum_product_of_subsequences_with_an_alternating_sum_equal_to_k/readme.md b/src/main/java/g3501_3600/s3509_maximum_product_of_subsequences_with_an_alternating_sum_equal_to_k/readme.md index 31ec68f81..8b99b69fa 100644 --- a/src/main/java/g3501_3600/s3509_maximum_product_of_subsequences_with_an_alternating_sum_equal_to_k/readme.md +++ b/src/main/java/g3501_3600/s3509_maximum_product_of_subsequences_with_an_alternating_sum_equal_to_k/readme.md @@ -2,7 +2,7 @@ Hard -You are given an integer array `nums` and two integers, `k` and `limit`. Your task is to find a non-empty ****subsequences**** of `nums` that: +You are given an integer array `nums` and two integers, `k` and `limit`. Your task is to find a non-empty **subsequences** of `nums` that: * Has an **alternating sum** equal to `k`. * **Maximizes** the product of all its numbers _without the product exceeding_ `limit`. diff --git a/src/main/java/g3501_3600/s3547_maximum_sum_of_edge_values_in_a_graph/readme.md b/src/main/java/g3501_3600/s3547_maximum_sum_of_edge_values_in_a_graph/readme.md index f182f4a87..9e863ce2f 100644 --- a/src/main/java/g3501_3600/s3547_maximum_sum_of_edge_values_in_a_graph/readme.md +++ b/src/main/java/g3501_3600/s3547_maximum_sum_of_edge_values_in_a_graph/readme.md @@ -2,7 +2,7 @@ Hard -You are given an **und****irected** graph of `n` nodes, numbered from `0` to `n - 1`. Each node is connected to **at most** 2 other nodes. +You are given an **undirected** graph of `n` nodes, numbered from `0` to `n - 1`. Each node is connected to **at most** 2 other nodes. The graph consists of `m` edges, represented by a 2D array `edges`, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi. diff --git a/src/main/java/g3501_3600/s3556_sum_of_largest_prime_substrings/readme.md b/src/main/java/g3501_3600/s3556_sum_of_largest_prime_substrings/readme.md index c719d6374..9c21f6b99 100644 --- a/src/main/java/g3501_3600/s3556_sum_of_largest_prime_substrings/readme.md +++ b/src/main/java/g3501_3600/s3556_sum_of_largest_prime_substrings/readme.md @@ -2,7 +2,7 @@ Medium -Given a string `s`, find the sum of the **3 largest unique prime numbers** that can be formed using any of its ****substring****. +Given a string `s`, find the sum of the **3 largest unique prime numbers** that can be formed using any of its **substring**. Return the **sum** of the three largest unique prime numbers that can be formed. If fewer than three exist, return the sum of **all** available primes. If no prime numbers can be formed, return 0. diff --git a/src/main/java/g3501_3600/s3557_find_maximum_number_of_non_intersecting_substrings/readme.md b/src/main/java/g3501_3600/s3557_find_maximum_number_of_non_intersecting_substrings/readme.md index 6ba4e1b08..d419545af 100644 --- a/src/main/java/g3501_3600/s3557_find_maximum_number_of_non_intersecting_substrings/readme.md +++ b/src/main/java/g3501_3600/s3557_find_maximum_number_of_non_intersecting_substrings/readme.md @@ -4,7 +4,7 @@ Medium You are given a string `word`. -Return the **maximum** number of non-intersecting ****substring**** of word that are at **least** four characters long and start and end with the same letter. +Return the **maximum** number of non-intersecting **substring** of word that are at **least** four characters long and start and end with the same letter. **Example 1:** diff --git a/src/main/java/g3501_3600/s3579_minimum_steps_to_convert_string_with_operations/readme.md b/src/main/java/g3501_3600/s3579_minimum_steps_to_convert_string_with_operations/readme.md index daca34910..d5b602d88 100644 --- a/src/main/java/g3501_3600/s3579_minimum_steps_to_convert_string_with_operations/readme.md +++ b/src/main/java/g3501_3600/s3579_minimum_steps_to_convert_string_with_operations/readme.md @@ -4,7 +4,7 @@ Hard You are given two strings, `word1` and `word2`, of equal length. You need to transform `word1` into `word2`. -For this, divide `word1` into one or more **contiguous **substring****. For each substring `substr` you can perform the following operations: +For this, divide `word1` into one or more **contiguous substring**. For each substring `substr` you can perform the following operations: 1. **Replace:** Replace the character at any one index of `substr` with another lowercase English letter. diff --git a/src/main/java/g3501_3600/s3584_maximum_product_of_first_and_last_elements_of_a_subsequence/readme.md b/src/main/java/g3501_3600/s3584_maximum_product_of_first_and_last_elements_of_a_subsequence/readme.md index 45bcb13ad..00c6f7335 100644 --- a/src/main/java/g3501_3600/s3584_maximum_product_of_first_and_last_elements_of_a_subsequence/readme.md +++ b/src/main/java/g3501_3600/s3584_maximum_product_of_first_and_last_elements_of_a_subsequence/readme.md @@ -4,7 +4,7 @@ Medium You are given an integer array `nums` and an integer `m`. -Return the **maximum** product of the first and last elements of any ****subsequences**** of `nums` of size `m`. +Return the **maximum** product of the first and last elements of any **subsequences** of `nums` of size `m`. **Example 1:** diff --git a/src/main/java/g3501_3600/s3585_find_weighted_median_node_in_tree/readme.md b/src/main/java/g3501_3600/s3585_find_weighted_median_node_in_tree/readme.md index 69a344aa8..f0f50f109 100644 --- a/src/main/java/g3501_3600/s3585_find_weighted_median_node_in_tree/readme.md +++ b/src/main/java/g3501_3600/s3585_find_weighted_median_node_in_tree/readme.md @@ -32,7 +32,7 @@ Return an array `ans`, where `ans[j]` is the node index of the weighted median f **Output:** [1,0,2] -**E****xplanation:** +**Explanation:** ![](https://assets.leetcode.com/uploads/2025/05/26/screenshot-2025-05-26-at-193610.png) diff --git a/src/main/java/g3501_3600/s3599_partition_array_to_minimize_xor/readme.md b/src/main/java/g3501_3600/s3599_partition_array_to_minimize_xor/readme.md index baa25d57f..1970dbd8d 100644 --- a/src/main/java/g3501_3600/s3599_partition_array_to_minimize_xor/readme.md +++ b/src/main/java/g3501_3600/s3599_partition_array_to_minimize_xor/readme.md @@ -4,7 +4,7 @@ Medium You are given an integer array `nums` and an integer `k`. -Your task is to partition `nums` into `k` non-empty ****non-empty subarrays****. For each subarray, compute the bitwise **XOR** of all its elements. +Your task is to partition `nums` into `k` non-empty **non-empty subarrays**. For each subarray, compute the bitwise **XOR** of all its elements. Return the **minimum** possible value of the **maximum XOR** among these `k` subarrays. diff --git a/src/main/java/g3601_3700/s3615_longest_palindromic_path_in_graph/readme.md b/src/main/java/g3601_3700/s3615_longest_palindromic_path_in_graph/readme.md index b97e4d8dd..8f08afca3 100644 --- a/src/main/java/g3601_3700/s3615_longest_palindromic_path_in_graph/readme.md +++ b/src/main/java/g3601_3700/s3615_longest_palindromic_path_in_graph/readme.md @@ -16,7 +16,7 @@ Return the **maximum** possible length of a **palindrome** that can be formed by **Output:** 3 -**Exp****lanation:** +**Explanation:** ![](https://assets.leetcode.com/uploads/2025/06/13/screenshot-2025-06-13-at-230714.png) diff --git a/src/main/java/g3701_3800/s3703_remove_k_balanced_substrings/readme.md b/src/main/java/g3701_3800/s3703_remove_k_balanced_substrings/readme.md index 38de2746a..20a41ed5d 100644 --- a/src/main/java/g3701_3800/s3703_remove_k_balanced_substrings/readme.md +++ b/src/main/java/g3701_3800/s3703_remove_k_balanced_substrings/readme.md @@ -8,7 +8,7 @@ A **string** is **k-balanced** if it is **exactly** `k` **consecutive** `'('` fo For example, if `k = 3`, k-balanced is `"((()))"`. -You must **repeatedly** remove all **non-overlapping k-balanced **substring**** from `s`, and then join the remaining parts. Continue this process until no k-balanced **substring** exists. +You must **repeatedly** remove all **non-overlapping k-balanced substring** from `s`, and then join the remaining parts. Continue this process until no k-balanced **substring** exists. Return the final string after all possible removals. diff --git a/src/main/java/g3701_3800/s3729_count_distinct_subarrays_divisible_by_k_in_sorted_array/readme.md b/src/main/java/g3701_3800/s3729_count_distinct_subarrays_divisible_by_k_in_sorted_array/readme.md index 00d7143a4..59475dfc6 100644 --- a/src/main/java/g3701_3800/s3729_count_distinct_subarrays_divisible_by_k_in_sorted_array/readme.md +++ b/src/main/java/g3701_3800/s3729_count_distinct_subarrays_divisible_by_k_in_sorted_array/readme.md @@ -4,7 +4,7 @@ Hard You are given an integer array `nums` **sorted** in **non-descending** order and a positive integer `k`. -A ****non-empty subarrays**** of `nums` is **good** if the sum of its elements is **divisible** by `k`. +A **non-empty subarrays** of `nums` is **good** if the sum of its elements is **divisible** by `k`. Return an integer denoting the number of **distinct** **good** subarrays of `nums`. diff --git a/src/main/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/Solution.java b/src/main/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/Solution.java new file mode 100644 index 000000000..3fd69621d --- /dev/null +++ b/src/main/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/Solution.java @@ -0,0 +1,17 @@ +package g3701_3800.s3736_minimum_moves_to_equal_array_elements_iii; + +// #Easy #Array #Math #Biweekly_Contest_169 #2026_04_15_Time_1_ms_(99.59%)_Space_46.18_MB_(89.25%) + +public class Solution { + public int minMoves(int[] nums) { + int max = Integer.MIN_VALUE; + int sum = 0; + for (int num : nums) { + sum += num; + if (num > max) { + max = num; + } + } + return max * nums.length - sum; + } +} diff --git a/src/main/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/readme.md b/src/main/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/readme.md new file mode 100644 index 000000000..a24bf08d8 --- /dev/null +++ b/src/main/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/readme.md @@ -0,0 +1,45 @@ +3736\. Minimum Moves to Equal Array Elements III + +Easy + +You are given an integer array `nums`. + +In one move, you may **increase** the value of any single element `nums[i]` by 1. + +Return the **minimum total** number of **moves** required so that all elements in `nums` become **equal**. + +**Example 1:** + +**Input:** nums = [2,1,3] + +**Output:** 3 + +**Explanation:** + +To make all elements equal: + +* Increase `nums[0] = 2` by 1 to make it 3. +* Increase `nums[1] = 1` by 1 to make it 2. +* Increase `nums[1] = 2` by 1 to make it 3. + +Now, all elements of `nums` are equal to 3. The minimum total moves is `3`. + +**Example 2:** + +**Input:** nums = [4,4,5] + +**Output:** 2 + +**Explanation:** + +To make all elements equal: + +* Increase `nums[0] = 4` by 1 to make it 5. +* Increase `nums[1] = 4` by 1 to make it 5. + +Now, all elements of `nums` are equal to 5. The minimum total moves is `2`. + +**Constraints:** + +* `1 <= nums.length <= 100` +* `1 <= nums[i] <= 100` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/Solution.java b/src/main/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/Solution.java new file mode 100644 index 000000000..1c4cda309 --- /dev/null +++ b/src/main/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/Solution.java @@ -0,0 +1,22 @@ +package g3701_3800.s3737_count_subarrays_with_majority_element_i; + +// #Medium #Array #Hash_Table #Prefix_Sum #Counting #Divide_and_Conquer #Segment_Tree #Merge_Sort +// #Senior #Biweekly_Contest_169 #2026_04_26_Time_1_ms_(100.00%)_Space_46.96_MB_(57.62%) + +public class Solution { + public int countMajoritySubarrays(int[] a, int target) { + int n = a.length; + int pre = n + 1; + int res = 0; + int[] count = new int[2 * n + 2]; + int[] acc = new int[2 * n + 2]; + count[pre] = acc[pre] = 1; + for (int i : a) { + pre += (i == target ? 1 : -1); + count[pre]++; + acc[pre] = acc[pre - 1] + count[pre]; + res += acc[pre - 1]; + } + return res; + } +} diff --git a/src/main/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/readme.md b/src/main/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/readme.md new file mode 100644 index 000000000..1006f055a --- /dev/null +++ b/src/main/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/readme.md @@ -0,0 +1,53 @@ +3737\. Count Subarrays With Majority Element I + +Medium + +You are given an integer array `nums` and an integer `target`. + +Return the number of **non-empty subarrays** of `nums` in which `target` is the **majority element**. + +The **majority element** of a subarray is the element that appears **strictly** **more than half** of the times in that subarray. + +**Example 1:** + +**Input:** nums = [1,2,2,3], target = 2 + +**Output:** 5 + +**Explanation:** + +Valid subarrays with `target = 2` as the majority element: + +* `nums[1..1] = [2]` +* `nums[2..2] = [2]` +* `nums[1..2] = [2,2]` +* `nums[0..2] = [1,2,2]` +* `nums[1..3] = [2,2,3]` + +So there are 5 such subarrays. + +**Example 2:** + +**Input:** nums = [1,1,1,1], target = 1 + +**Output:** 10 + +**Explanation:** + +All 10 subarrays have 1 as the majority element. + +**Example 3:** + +**Input:** nums = [1,2,3], target = 4 + +**Output:** 0 + +**Explanation:** + +`target = 4` does not appear in `nums` at all. Therefore, there cannot be any subarray where 4 is the majority element. Hence the answer is 0. + +**Constraints:** + +* `1 <= nums.length <= 1000` +* 1 <= nums[i] <= 109 +* 1 <= target <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/Solution.java b/src/main/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/Solution.java new file mode 100644 index 000000000..24cf3ea96 --- /dev/null +++ b/src/main/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/Solution.java @@ -0,0 +1,42 @@ +package g3701_3800.s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element; + +// #Medium #Array #Dynamic_Programming #Staff #Biweekly_Contest_169 +// #2026_04_26_Time_7_ms_(99.28%)_Space_123.88_MB_(5.07%) + +public class Solution { + public int longestSubarray(int[] nums) { + int n = nums.length; + if (n < 3) { + return n; + } + int i = 0; + int len1 = 0; + int len2 = 0; + int ans = 2; + while (i < n) { + int l = (i == 0) ? -1000 * 1000 * 10 : nums[i - 1]; + int r = (i == n - 1) ? 1000 * 1000 * 10 : nums[i + 1]; + if (l <= nums[i]) { + len2++; + ans = Math.max(len2 + 1, ans); + } else if (r >= nums[i]) { + int j = i; + len1 = len2; + while (j < n - 1 && nums[j] <= nums[j + 1]) { + j++; + } + len2 = j - i + 1; + ans = Math.max(len2 + 1, ans); + if (l <= r || (len1 > 1 && nums[i - 2] <= nums[i])) { + ans = Math.max(len1 + len2, ans); + } + i = j; + } else { + len2 = 0; + } + i++; + } + ans = Math.min(ans, n); + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/readme.md b/src/main/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/readme.md new file mode 100644 index 000000000..d0542bca3 --- /dev/null +++ b/src/main/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/readme.md @@ -0,0 +1,38 @@ +3738\. Longest Non-Decreasing Subarray After Replacing at Most One Element + +Medium + +You are given an integer array `nums`. + +You are allowed to replace **at most** one element in the array with any other integer value of your choice. + +Return the length of the **longest non-decreasing subarray** that can be obtained after performing at most one replacement. + +An array is said to be **non-decreasing** if each element is greater than or equal to its previous one (if it exists). + +**Example 1:** + +**Input:** nums = [1,2,3,1,2] + +**Output:** 4 + +**Explanation:** + +Replacing `nums[3] = 1` with 3 gives the array [1, 2, 3, 3, 2]. + +The longest non-decreasing subarray is [1, 2, 3, 3], which has a length of 4. + +**Example 2:** + +**Input:** nums = [2,2,2,2,2] + +**Output:** 5 + +**Explanation:** + +All elements in `nums` are equal, so it is already non-decreasing and the entire `nums` forms a subarray of length 5. + +**Constraints:** + +* 1 <= nums.length <= 105 +* -109 <= nums[i] <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/Solution.java b/src/main/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/Solution.java new file mode 100644 index 000000000..0c7ca8923 --- /dev/null +++ b/src/main/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/Solution.java @@ -0,0 +1,21 @@ +package g3701_3800.s3739_count_subarrays_with_majority_element_ii; + +// #Hard #Array #Hash_Table #Prefix_Sum #Divide_and_Conquer #Segment_Tree #Merge_Sort #Senior_Staff +// #Biweekly_Contest_169 #2026_04_26_Time_3_ms_(100.00%)_Space_90.94_MB_(36.19%) + +public class Solution { + public long countMajoritySubarrays(int[] nums, int target) { + int n = nums.length; + int pre = n + 1; + long[] count = new long[2 * n + 2]; + long[] acc = new long[2 * n + 2]; + long res = 0; + count[pre] = acc[pre] = 1; + for (int a : nums) { + pre += (a == target ? 1 : -1); + acc[pre] = ++count[pre] + acc[pre - 1]; + res += acc[pre - 1]; + } + return res; + } +} diff --git a/src/main/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/readme.md b/src/main/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/readme.md new file mode 100644 index 000000000..f8da05e77 --- /dev/null +++ b/src/main/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/readme.md @@ -0,0 +1,53 @@ +3739\. Count Subarrays With Majority Element II + +Hard + +You are given an integer array `nums` and an integer `target`. + +Return the number of **non-empty subarrays** of `nums` in which `target` is the **majority element**. + +The **majority element** of a subarray is the element that appears **strictly more than half** of the times in that subarray. + +**Example 1:** + +**Input:** nums = [1,2,2,3], target = 2 + +**Output:** 5 + +**Explanation:** + +Valid subarrays with `target = 2` as the majority element: + +* `nums[1..1] = [2]` +* `nums[2..2] = [2]` +* `nums[1..2] = [2,2]` +* `nums[0..2] = [1,2,2]` +* `nums[1..3] = [2,2,3]` + +So there are 5 such subarrays. + +**Example 2:** + +**Input:** nums = [1,1,1,1], target = 1 + +**Output:** 10 + +**Explanation:** + +All 10 subarrays have 1 as the majority element. + +**Example 3:** + +**Input:** nums = [1,2,3], target = 4 + +**Output:** 0 + +**Explanation:** + +`target = 4` does not appear in `nums` at all. Therefore, there cannot be any subarray where 4 is the majority element. Hence the answer is 0. + +**Constraints:** + +* 1 <= nums.length <= 105 +* 1 <= nums[i] <= 109 +* 1 <= target <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/Solution.java b/src/main/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/Solution.java new file mode 100644 index 000000000..9aa0d85bd --- /dev/null +++ b/src/main/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/Solution.java @@ -0,0 +1,24 @@ +package g3701_3800.s3740_minimum_distance_between_three_equal_elements_i; + +// #Easy #Array #Hash_Table #Mid_Level #Weekly_Contest_475 +// #2026_04_26_Time_1_ms_(99.99%)_Space_44.21_MB_(75.36%) + +public class Solution { + public int minimumDistance(int[] nums) { + int len = nums.length; + int[] last2 = new int[len]; + int res = 200; + for (int i = 0; i < len; i++) { + int val = nums[i] - 1; + int pos = i + 1; + int pack = last2[val]; + int old = pack & 255; + int cur = pack >> 8; + last2[val] = cur | (pos << 8); + if (old > 0) { + res = Math.min(res, (pos - old) << 1); + } + } + return res == 200 ? -1 : res; + } +} diff --git a/src/main/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/readme.md b/src/main/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/readme.md new file mode 100644 index 000000000..28e3b80ac --- /dev/null +++ b/src/main/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/readme.md @@ -0,0 +1,50 @@ +3740\. Minimum Distance Between Three Equal Elements I + +Easy + +You are given an integer array `nums`. + +A tuple `(i, j, k)` of 3 **distinct** indices is **good** if `nums[i] == nums[j] == nums[k]`. + +The **distance** of a **good** tuple is `abs(i - j) + abs(j - k) + abs(k - i)`, where `abs(x)` denotes the **absolute value** of `x`. + +Return an integer denoting the **minimum** possible **distance** of a **good** tuple. If no **good** tuples exist, return `-1`. + +**Example 1:** + +**Input:** nums = [1,2,1,1,3] + +**Output:** 6 + +**Explanation:** + +The minimum distance is achieved by the good tuple `(0, 2, 3)`. + +`(0, 2, 3)` is a good tuple because `nums[0] == nums[2] == nums[3] == 1`. Its distance is `abs(0 - 2) + abs(2 - 3) + abs(3 - 0) = 2 + 1 + 3 = 6`. + +**Example 2:** + +**Input:** nums = [1,1,2,3,2,1,2] + +**Output:** 8 + +**Explanation:** + +The minimum distance is achieved by the good tuple `(2, 4, 6)`. + +`(2, 4, 6)` is a good tuple because `nums[2] == nums[4] == nums[6] == 2`. Its distance is `abs(2 - 4) + abs(4 - 6) + abs(6 - 2) = 2 + 2 + 4 = 8`. + +**Example 3:** + +**Input:** nums = [1] + +**Output:** \-1 + +**Explanation:** + +There are no good tuples. Therefore, the answer is -1. + +**Constraints:** + +* `1 <= n == nums.length <= 100` +* `1 <= nums[i] <= n` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/Solution.java b/src/main/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/Solution.java new file mode 100644 index 000000000..0140d2aa4 --- /dev/null +++ b/src/main/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/Solution.java @@ -0,0 +1,28 @@ +package g3701_3800.s3741_minimum_distance_between_three_equal_elements_ii; + +// #Medium #Array #Hash_Table #Senior #Weekly_Contest_475 +// #2026_04_26_Time_6_ms_(99.60%)_Space_161.24_MB_(96.23%) + +public class Solution { + public int minimumDistance(int[] nums) { + int n = nums.length; + int ans = Integer.MAX_VALUE; + int[] prev1 = new int[n + 1]; + int[] prev2 = new int[n + 1]; + for (int i = 0; i < n + 1; i++) { + prev1[i] = prev2[i] = -1; + } + for (int i = 0; i < n; i++) { + int value = nums[i]; + if (prev2[value] != -1) { + ans = Math.min(ans, (i - prev2[value])); + } + prev2[value] = prev1[value]; + prev1[value] = i; + } + if (ans < 100002) { + return ans * 2; + } + return -1; + } +} diff --git a/src/main/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/readme.md b/src/main/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/readme.md new file mode 100644 index 000000000..d3aee5aa3 --- /dev/null +++ b/src/main/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/readme.md @@ -0,0 +1,50 @@ +3741\. Minimum Distance Between Three Equal Elements II + +Medium + +You are given an integer array `nums`. + +A tuple `(i, j, k)` of 3 **distinct** indices is **good** if `nums[i] == nums[j] == nums[k]`. + +The **distance** of a **good** tuple is `abs(i - j) + abs(j - k) + abs(k - i)`, where `abs(x)` denotes the **absolute value** of `x`. + +Return an integer denoting the **minimum** possible **distance** of a **good** tuple. If no **good** tuples exist, return `-1`. + +**Example 1:** + +**Input:** nums = [1,2,1,1,3] + +**Output:** 6 + +**Explanation:** + +The minimum distance is achieved by the good tuple `(0, 2, 3)`. + +`(0, 2, 3)` is a good tuple because `nums[0] == nums[2] == nums[3] == 1`. Its distance is `abs(0 - 2) + abs(2 - 3) + abs(3 - 0) = 2 + 1 + 3 = 6`. + +**Example 2:** + +**Input:** nums = [1,1,2,3,2,1,2] + +**Output:** 8 + +**Explanation:** + +The minimum distance is achieved by the good tuple `(2, 4, 6)`. + +`(2, 4, 6)` is a good tuple because `nums[2] == nums[4] == nums[6] == 2`. Its distance is `abs(2 - 4) + abs(4 - 6) + abs(6 - 2) = 2 + 2 + 4 = 8`. + +**Example 3:** + +**Input:** nums = [1] + +**Output:** \-1 + +**Explanation:** + +There are no good tuples. Therefore, the answer is -1. + +**Constraints:** + +* 1 <= n == nums.length <= 105 +* `1 <= nums[i] <= n` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3742_maximum_path_score_in_a_grid/Solution.java b/src/main/java/g3701_3800/s3742_maximum_path_score_in_a_grid/Solution.java new file mode 100644 index 000000000..f13cf823e --- /dev/null +++ b/src/main/java/g3701_3800/s3742_maximum_path_score_in_a_grid/Solution.java @@ -0,0 +1,51 @@ +package g3701_3800.s3742_maximum_path_score_in_a_grid; + +// #Medium #Array #Dynamic_Programming #Matrix #Staff #Weekly_Contest_475 +// #2026_04_26_Time_212_ms_(91.38%)_Space_92.93_MB_(35.06%) + +public class Solution { + public int maxPathScore(int[][] grid, int k) { + int n = grid.length; + int m = grid[0].length; + int mxc = Math.min(k + 1, n + m + 5); + int[][][] dp = new int[n][m][mxc]; + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + for (int c = 0; c < mxc; c++) { + dp[i][j][c] = -1; + } + } + } + dp[0][0][0] = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + for (int c = 0; c < mxc; c++) { + if (dp[i][j][c] == -1) { + continue; + } + // move right + if (j + 1 < m) { + int cost = c + (grid[i][j + 1] > 0 ? 1 : 0); + if (cost < mxc) { + dp[i][j + 1][cost] = + Math.max(dp[i][j + 1][cost], dp[i][j][c] + grid[i][j + 1]); + } + } + // move down + if (i + 1 < n) { + int cost = c + (grid[i + 1][j] > 0 ? 1 : 0); + if (cost < mxc) { + dp[i + 1][j][cost] = + Math.max(dp[i + 1][j][cost], dp[i][j][c] + grid[i + 1][j]); + } + } + } + } + } + int ans = -1; + for (int c = 0; c < mxc; c++) { + ans = Math.max(ans, dp[n - 1][m - 1][c]); + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3742_maximum_path_score_in_a_grid/readme.md b/src/main/java/g3701_3800/s3742_maximum_path_score_in_a_grid/readme.md new file mode 100644 index 000000000..4294a424d --- /dev/null +++ b/src/main/java/g3701_3800/s3742_maximum_path_score_in_a_grid/readme.md @@ -0,0 +1,52 @@ +3742\. Maximum Path Score in a Grid + +Medium + +You are given an `m x n` grid where each cell contains one of the values 0, 1, or 2. You are also given an integer `k`. + +You start from the top-left corner `(0, 0)` and want to reach the bottom-right corner `(m - 1, n - 1)` by moving only **right** or **down**. + +Each cell contributes a specific score and incurs an associated cost, according to their cell values: + +* 0: adds 0 to your score and costs 0. +* 1: adds 1 to your score and costs 1. +* 2: adds 2 to your score and costs 1. + +Return the **maximum** score achievable without exceeding a total cost of `k`, or -1 if no valid path exists. + +**Note:** If you reach the last cell but the total cost exceeds `k`, the path is invalid. + +**Example 1:** + +**Input:** grid = [[0, 1],[2, 0]], k = 1 + +**Output:** 2 + +**Explanation:** + +The optimal path is: + +| Cell | grid[i][j] | Score | Total Score | Cost | Total Cost | +|--------|------------|-------|-------------|------|------------| +| (0, 0) | 0 | 0 | 0 | 0 | 0 | +| (1, 0) | 2 | 2 | 2 | 1 | 1 | +| (1, 1) | 0 | 0 | 2 | 0 | 1 | + +Thus, the maximum possible score is 2. + +**Example 2:** + +**Input:** grid = [[0, 1],[1, 2]], k = 1 + +**Output:** \-1 + +**Explanation:** + +There is no path that reaches cell `(1, 1)` without exceeding cost k. Thus, the answer is -1. + +**Constraints:** + +* `1 <= m, n <= 200` +* 0 <= k <= 103 +* `grid[0][0] == 0` +* `0 <= grid[i][j] <= 2` diff --git a/src/main/java/g3701_3800/s3743_maximize_cyclic_partition_score/Solution.java b/src/main/java/g3701_3800/s3743_maximize_cyclic_partition_score/Solution.java new file mode 100644 index 000000000..6157b2620 --- /dev/null +++ b/src/main/java/g3701_3800/s3743_maximize_cyclic_partition_score/Solution.java @@ -0,0 +1,67 @@ +package g3701_3800.s3743_maximize_cyclic_partition_score; + +// #Hard #Array #Dynamic_Programming #Weekly_Contest_475 #Principal +// #2026_04_26_Time_40_ms_(96.15%)_Space_120.45_MB_(7.69%) + +public class Solution { + public long maximumScore(int[] nums, int k) { + // Find index of minimum element + int j = 0; + for (int i = 0; i < nums.length; i++) { + if (nums[i] < nums[j]) { + j = i; + } + } + // Build array 'a' + int n = nums.length; + int[] a = new int[n]; + for (int i = 0; i < n; i++) { + a[i] = nums[(j + i) % n]; + } + // Build array 'b' (rotated and reversed) + int[] b = new int[n]; + for (int i = 0; i < n; i++) { + b[i] = nums[(j + 1 + i) % n]; + } + reverse(b); + // Compute and return max of f(a, k) and f(b, k) + return Math.max(f(a, k), f(b, k)); + } + + private long f(int[] a, int k) { + int n = a.length; + long[][] dp = new long[k + 1][n + 1]; + long mn = Long.MAX_VALUE; + long mx = Long.MIN_VALUE; + // Initialize dp[1][j+1] + for (int j = 0; j < n; j++) { + mn = Math.min(mn, a[j]); + mx = Math.max(mx, a[j]); + dp[1][j + 1] = mx - mn; + } + long res = dp[1][n]; + for (int i = 2; i <= k; i++) { + long x = Long.MIN_VALUE; + long y = Long.MIN_VALUE; + for (int j = i - 1; j < n; j++) { + x = Math.max(x, dp[i - 1][j] - a[j]); + y = Math.max(y, dp[i - 1][j] + a[j]); + dp[i][j + 1] = Math.max(dp[i][j], Math.max(x + a[j], y - a[j])); + } + res = Math.max(res, dp[i][n]); + } + return res; + } + + private void reverse(int[] arr) { + int left = 0; + int right = arr.length - 1; + while (left < right) { + int temp = arr[left]; + arr[left] = arr[right]; + arr[right] = temp; + left++; + right--; + } + } +} diff --git a/src/main/java/g3701_3800/s3743_maximize_cyclic_partition_score/readme.md b/src/main/java/g3701_3800/s3743_maximize_cyclic_partition_score/readme.md new file mode 100644 index 000000000..56f6640a3 --- /dev/null +++ b/src/main/java/g3701_3800/s3743_maximize_cyclic_partition_score/readme.md @@ -0,0 +1,52 @@ +3743\. Maximize Cyclic Partition Score + +Hard + +You are given a **cyclic** array `nums` and an integer `k`. + +**Partition** `nums` into **at most** `k` non-empty subarrays. As `nums` is cyclic, these subarrays may wrap around from the end of the array back to the beginning. + +The **range** of a subarray is the difference between its **maximum** and **minimum** values. The **score** of a partition is the sum of subarray **ranges**. + +Return the **maximum** possible **score** among all cyclic partitions. + +**Example 1:** + +**Input:** nums = [1,2,3,3], k = 2 + +**Output:** 3 + +**Explanation:** + +* Partition `nums` into `[2, 3]` and `[3, 1]` (wrapped around). +* The range of `[2, 3]` is `max(2, 3) - min(2, 3) = 3 - 2 = 1`. +* The range of `[3, 1]` is `max(3, 1) - min(3, 1) = 3 - 1 = 2`. +* The score is `1 + 2 = 3`. + +**Example 2:** + +**Input:** nums = [1,2,3,3], k = 1 + +**Output:** 2 + +**Explanation:** + +* Partition `nums` into `[1, 2, 3, 3]`. +* The range of `[1, 2, 3, 3]` is `max(1, 2, 3, 3) - min(1, 2, 3, 3) = 3 - 1 = 2`. +* The score is 2. + +**Example 3:** + +**Input:** nums = [1,2,3,3], k = 4 + +**Output:** 3 + +**Explanation:** + +Identical to Example 1, we partition `nums` into `[2, 3]` and `[3, 1]`. Note that `nums` may be partitioned into fewer than `k` subarrays. + +**Constraints:** + +* `1 <= nums.length <= 1000` +* 1 <= nums[i] <= 109 +* `1 <= k <= nums.length` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3745_maximize_expression_of_three_elements/Solution.java b/src/main/java/g3701_3800/s3745_maximize_expression_of_three_elements/Solution.java new file mode 100644 index 000000000..854c4c2d6 --- /dev/null +++ b/src/main/java/g3701_3800/s3745_maximize_expression_of_three_elements/Solution.java @@ -0,0 +1,24 @@ +package g3701_3800.s3745_maximize_expression_of_three_elements; + +// #Easy #Array #Sorting #Greedy #Enumeration #Mid_Level #Weekly_Contest_476 +// #2026_04_26_Time_1_ms_(99.84%)_Space_45.12_MB_(68.56%) + +public class Solution { + public int maximizeExpressionOfThree(int[] nums) { + int max1 = Integer.MIN_VALUE; + int max2 = Integer.MIN_VALUE; + int min = Integer.MAX_VALUE; + for (int num : nums) { + if (num > max1) { + max2 = max1; + max1 = num; + } else if (num > max2) { + max2 = num; + } + if (num < min) { + min = num; + } + } + return max1 + max2 - min; + } +} diff --git a/src/main/java/g3701_3800/s3745_maximize_expression_of_three_elements/readme.md b/src/main/java/g3701_3800/s3745_maximize_expression_of_three_elements/readme.md new file mode 100644 index 000000000..8b7d60816 --- /dev/null +++ b/src/main/java/g3701_3800/s3745_maximize_expression_of_three_elements/readme.md @@ -0,0 +1,34 @@ +3745\. Maximize Expression of Three Elements + +Easy + +You are given an integer array `nums`. + +Choose three elements `a`, `b`, and `c` from `nums` at **distinct** indices such that the value of the expression `a + b - c` is maximized. + +Return an integer denoting the **maximum possible value** of this expression. + +**Example 1:** + +**Input:** nums = [1,4,2,5] + +**Output:** 8 + +**Explanation:** + +We can choose `a = 4`, `b = 5`, and `c = 1`. The expression value is `4 + 5 - 1 = 8`, which is the maximum possible. + +**Example 2:** + +**Input:** nums = [-2,0,5,-2,4] + +**Output:** 11 + +**Explanation:** + +We can choose `a = 5`, `b = 4`, and `c = -2`. The expression value is `5 + 4 - (-2) = 11`, which is the maximum possible. + +**Constraints:** + +* `3 <= nums.length <= 100` +* `-100 <= nums[i] <= 100` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/Solution.java b/src/main/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/Solution.java new file mode 100644 index 000000000..e6f31ded3 --- /dev/null +++ b/src/main/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/Solution.java @@ -0,0 +1,14 @@ +package g3701_3800.s3746_minimum_string_length_after_balanced_removals; + +// #Medium #String #Stack #Counting #Senior #Weekly_Contest_476 +// #2026_04_26_Time_3_ms_(95.94%)_Space_47.34_MB_(25.76%) + +public class Solution { + public int minLengthAfterRemovals(String s) { + int[] hash = new int[2]; + for (char c : s.toCharArray()) { + hash[c - 'a']++; + } + return Math.abs(hash[0] - hash[1]); + } +} diff --git a/src/main/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/readme.md b/src/main/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/readme.md new file mode 100644 index 000000000..d97662b43 --- /dev/null +++ b/src/main/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/readme.md @@ -0,0 +1,44 @@ +3746\. Minimum String Length After Balanced Removals + +Medium + +You are given a string `s` consisting only of the characters `'a'` and `'b'`. + +You are allowed to repeatedly remove **any substring** where the number of `'a'` characters is equal to the number of `'b'` characters. After each removal, the remaining parts of the string are concatenated together without gaps. + +Return an integer denoting the **minimum possible length** of the string after performing any number of such operations. + +**Example 1:** + +**Input:** s = `"aabbab"` + +**Output:** 0 + +**Explanation:** + +The substring `"aabbab"` has three `'a'` and three `'b'`. Since their counts are equal, we can remove the entire string directly. The minimum length is 0. + +**Example 2:** + +**Input:** s = `"aaaa"` + +**Output:** 4 + +**Explanation:** + +Every substring of `"aaaa"` contains only `'a'` characters. No substring can be removed as a result, so the minimum length remains 4. + +**Example 3:** + +**Input:** s = `"aaabb"` + +**Output:** 1 + +**Explanation:** + +First, remove the substring `"ab"`, leaving `"aab"`. Next, remove the new substring `"ab"`, leaving `"a"`. No further removals are possible, so the minimum length is 1. + +**Constraints:** + +* 1 <= s.length <= 105 +* `s[i]` is either `'a'` or `'b'`. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/Solution.java b/src/main/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/Solution.java new file mode 100644 index 000000000..244b4c74c --- /dev/null +++ b/src/main/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/Solution.java @@ -0,0 +1,28 @@ +package g3701_3800.s3747_count_distinct_integers_after_removing_zeros; + +// #Medium #Dynamic_Programming #Math #Staff #Weekly_Contest_476 +// #2026_04_26_Time_1_ms_(100.00%)_Space_42.72_MB_(79.66%) + +public class Solution { + public long countDistinct(long n) { + String digits = Long.toString(n); + int m = digits.length(); + long[] power9 = new long[m + 1]; + power9[0] = 1; + for (int i = 1; i <= m; i++) { + power9[i] = power9[i - 1] * 9; + } + long total = 0; + for (int length = 1; length < m; length++) { + total += power9[length]; + } + for (int idx = 0; idx < m; idx++) { + int d = digits.charAt(idx) - '0'; + if (d == 0) { + return total; + } + total += (d - 1) * power9[m - idx - 1]; + } + return total + 1; + } +} diff --git a/src/main/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/readme.md b/src/main/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/readme.md new file mode 100644 index 000000000..fc8394dc5 --- /dev/null +++ b/src/main/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/readme.md @@ -0,0 +1,33 @@ +3747\. Count Distinct Integers After Removing Zeros + +Medium + +You are given a **positive** integer `n`. + +For every integer `x` from 1 to `n`, we write down the integer obtained by removing all zeros from the decimal representation of `x`. + +Return an integer denoting the number of **distinct** integers written down. + +**Example 1:** + +**Input:** n = 10 + +**Output:** 9 + +**Explanation:** + +The integers we wrote down are 1, 2, 3, 4, 5, 6, 7, 8, 9, 1. There are 9 distinct integers (1, 2, 3, 4, 5, 6, 7, 8, 9). + +**Example 2:** + +**Input:** n = 3 + +**Output:** 3 + +**Explanation:** + +The integers we wrote down are 1, 2, 3. There are 3 distinct integers (1, 2, 3). + +**Constraints:** + +* 1 <= n <= 1015 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3748_count_stable_subarrays/Solution.java b/src/main/java/g3701_3800/s3748_count_stable_subarrays/Solution.java new file mode 100644 index 000000000..cc0642ada --- /dev/null +++ b/src/main/java/g3701_3800/s3748_count_stable_subarrays/Solution.java @@ -0,0 +1,43 @@ +package g3701_3800.s3748_count_stable_subarrays; + +// #Hard #Array #Binary_Search #Prefix_Sum #Senior_Staff #Weekly_Contest_476 +// #2026_04_26_Time_9_ms_(100.00%)_Space_183.68_MB_(43.30%) + +public class Solution { + public long[] countStableSubarrays(int[] nums, int[][] queries) { + int n = nums.length; + long[] preSum = new long[n + 1]; + int[] idx = new int[n]; + int[] end = new int[n]; + int cnt = 0; + int prv = -1; + for (int i = 0; i < n; i++) { + if (nums[i] >= prv) { + cnt++; + } else { + cnt = 1; + } + prv = nums[i]; + preSum[i + 1] = preSum[i] + cnt; + idx[i] = cnt - 1; + } + end[n - 1] = n - 1; + for (int i = n - 2; i >= 0; i--) { + if (idx[i] + 1 == idx[i + 1]) { + end[i] = end[i + 1]; + } else { + end[i] = i; + } + } + long[] ans = new long[queries.length]; + for (int l = 0; l < queries.length; l++) { + int i = queries[l][0]; + int j = queries[l][1]; + long res = preSum[j + 1] - preSum[i]; + int endIdx = Math.min(end[i], j); + res -= (long) (endIdx - i + 1) * idx[i]; + ans[l] = res; + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3748_count_stable_subarrays/readme.md b/src/main/java/g3701_3800/s3748_count_stable_subarrays/readme.md new file mode 100644 index 000000000..4f79bb6d2 --- /dev/null +++ b/src/main/java/g3701_3800/s3748_count_stable_subarrays/readme.md @@ -0,0 +1,55 @@ +3748\. Count Stable Subarrays + +Hard + +You are given an integer array `nums`. + +A **non-empty subarrays** of `nums` is called **stable** if it contains **no inversions**, i.e., there is no pair of indices `i < j` such that `nums[i] > nums[j]`. + +You are also given a **2D integer array** `queries` of length `q`, where each queries[i] = [li, ri] represents a query. For each query [li, ri], compute the number of **stable subarrays** that lie entirely within the segment nums[li..ri]. + +Return an integer array `ans` of length `q`, where `ans[i]` is the answer to the ith query. + +**Note**: + +* A single element subarray is considered stable. + +**Example 1:** + +**Input:** nums = [3,1,2], queries = [[0,1],[1,2],[0,2]] + +**Output:** [2,3,4] + +**Explanation:** + +* For `queries[0] = [0, 1]`, the subarray is `[nums[0], nums[1]] = [3, 1]`. + * The stable subarrays are `[3]` and `[1]`. The total number of stable subarrays is 2. +* For `queries[1] = [1, 2]`, the subarray is `[nums[1], nums[2]] = [1, 2]`. + * The stable subarrays are `[1]`, `[2]`, and `[1, 2]`. The total number of stable subarrays is 3. +* For `queries[2] = [0, 2]`, the subarray is `[nums[0], nums[1], nums[2]] = [3, 1, 2]`. + * The stable subarrays are `[3]`, `[1]`, `[2]`, and `[1, 2]`. The total number of stable subarrays is 4. + +Thus, `ans = [2, 3, 4]`. + +**Example 2:** + +**Input:** nums = [2,2], queries = [[0,1],[0,0]] + +**Output:** [3,1] + +**Explanation:** + +* For `queries[0] = [0, 1]`, the subarray is `[nums[0], nums[1]] = [2, 2]`. + * The stable subarrays are `[2]`, `[2]`, and `[2, 2]`. The total number of stable subarrays is 3. +* For `queries[1] = [0, 0]`, the subarray is `[nums[0]] = [2]`. + * The stable subarray is `[2]`. The total number of stable subarrays is 1. + +Thus, `ans = [3, 1]`. + +**Constraints:** + +* 1 <= nums.length <= 105 +* 1 <= nums[i] <= 105 +* 1 <= queries.length <= 105 +* queries[i] = [li, ri] +* 0 <= li <= ri <= nums.length - 1 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/Solution.java b/src/main/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/Solution.java new file mode 100644 index 000000000..d38c3768f --- /dev/null +++ b/src/main/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/Solution.java @@ -0,0 +1,23 @@ +package g3701_3800.s3750_minimum_number_of_flips_to_reverse_binary_string; + +// #Easy #String #Math #Two_Pointers #Bit_Manipulation #Mid_Level #Biweekly_Contest_170 +// #2026_04_26_Time_1_ms_(100.00%)_Space_42.88_MB_(49.74%) + +public class Solution { + public int minimumFlips(int n) { + int ans = 0; + int temp = n; + int l = 0; + int r = -1; + while (temp > 0) { + temp >>= 1; + r++; + } + while (l < r) { + ans += ((n >> l) & 1) ^ ((n >> r) & 1); + l++; + r--; + } + return 2 * ans; + } +} diff --git a/src/main/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/readme.md b/src/main/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/readme.md new file mode 100644 index 000000000..ee86cd457 --- /dev/null +++ b/src/main/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/readme.md @@ -0,0 +1,37 @@ +3750\. Minimum Number of Flips to Reverse Binary String + +Easy + +You are given a **positive** integer `n`. + +Let `s` be the **binary representation** of `n` without leading zeros. + +The **reverse** of a binary string `s` is obtained by writing the characters of `s` in the opposite order. + +You may flip any bit in `s` (change `0 → 1` or `1 → 0`). Each flip affects **exactly** one bit. + +Return the **minimum** number of flips required to make `s` equal to the reverse of its original form. + +**Example 1:** + +**Input:** n = 7 + +**Output:** 0 + +**Explanation:** + +The binary representation of 7 is `"111"`. Its reverse is also `"111"`, which is the same. Hence, no flips are needed. + +**Example 2:** + +**Input:** n = 10 + +**Output:** 4 + +**Explanation:** + +The binary representation of 10 is `"1010"`. Its reverse is `"0101"`. All four bits must be flipped to make them equal. Thus, the minimum number of flips required is 4. + +**Constraints:** + +* 1 <= n <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/Solution.java b/src/main/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/Solution.java new file mode 100644 index 000000000..0771e9db9 --- /dev/null +++ b/src/main/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/Solution.java @@ -0,0 +1,38 @@ +package g3701_3800.s3751_total_waviness_of_numbers_in_range_i; + +// #Medium #Dynamic_Programming #Math #Enumeration #Senior #Biweekly_Contest_170 +// #2026_04_26_Time_11_ms_(98.18%)_Space_42.55_MB_(97.88%) + +public class Solution { + private int countpeakValley(int num) { + int lastdigit = num % 10; + int waiviness = 0; + int prevcurrent = -1; + num = num / 10; + while (num > 0) { + if (prevcurrent == -1) { + prevcurrent = num % 10; + num = num / 10; + continue; + } + int currvalue = num % 10; + if ((prevcurrent > currvalue && prevcurrent > lastdigit) + || (prevcurrent < currvalue && prevcurrent < lastdigit)) { + waiviness++; + } + lastdigit = prevcurrent; + prevcurrent = num % 10; + num = num / 10; + } + return waiviness; + } + + public int totalWaviness(int num1, int num2) { + int ans = 0; + for (int i = num1; i <= num2; i++) { + int l = countpeakValley(i); + ans = ans + l; + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/readme.md b/src/main/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/readme.md new file mode 100644 index 000000000..df45379fa --- /dev/null +++ b/src/main/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/readme.md @@ -0,0 +1,62 @@ +3751\. Total Waviness of Numbers in Range I + +Medium + +You are given two integers `num1` and `num2` representing an **inclusive** range `[num1, num2]`. + +The **waviness** of a number is defined as the total count of its **peaks** and **valleys**: + +* A digit is a **peak** if it is **strictly greater** than both of its immediate neighbors. +* A digit is a **valley** if it is **strictly less** than both of its immediate neighbors. +* The first and last digits of a number **cannot** be peaks or valleys. +* Any number with fewer than 3 digits has a waviness of 0. + +Return the total sum of waviness for all numbers in the range `[num1, num2]`. + +**Example 1:** + +**Input:** num1 = 120, num2 = 130 + +**Output:** 3 + +**Explanation:** + +In the range `[120, 130]`: + +* `120`: middle digit 2 is a peak, waviness = 1. +* `121`: middle digit 2 is a peak, waviness = 1. +* `130`: middle digit 3 is a peak, waviness = 1. +* All other numbers in the range have a waviness of 0. + +Thus, total waviness is `1 + 1 + 1 = 3`. + +**Example 2:** + +**Input:** num1 = 198, num2 = 202 + +**Output:** 3 + +**Explanation:** + +In the range `[198, 202]`: + +* `198`: middle digit 9 is a peak, waviness = 1. +* `201`: middle digit 0 is a valley, waviness = 1. +* `202`: middle digit 0 is a valley, waviness = 1. +* All other numbers in the range have a waviness of 0. + +Thus, total waviness is `1 + 1 + 1 = 3`. + +**Example 3:** + +**Input:** num1 = 4848, num2 = 4848 + +**Output:** 2 + +**Explanation:** + +Number `4848`: the second digit 8 is a peak, and the third digit 4 is a valley, giving a waviness of 2. + +**Constraints:** + +* 1 <= num1 <= num2 <= 105 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/Solution.java b/src/main/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/Solution.java new file mode 100644 index 000000000..6c9f7afe1 --- /dev/null +++ b/src/main/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/Solution.java @@ -0,0 +1,29 @@ +package g3701_3800.s3752_lexicographically_smallest_negated_permutation_that_sums_to_target; + +// #Medium #Array #Math #Sorting #Greedy #Two_Pointers #Staff #Biweekly_Contest_170 +// #2026_04_26_Time_3_ms_(100.00%)_Space_162.22_MB_(86.17%) + +public class Solution { + public int[] lexSmallestNegatedPerm(int n, long target) { + long drop = (long) n * (n + 1) / 2 - target; + if (drop < 0 || drop % 2 != 0) { + return new int[] {}; + } + int[] ans = new int[n]; + int l = 0; + int r = n - 1; + for (int i = n; i > 0; i--) { + int val = i; + if (2 * val <= drop) { + drop -= 2 * val; + ans[l++] = -val; + } else { + ans[r--] = val; + } + } + if (drop != 0) { + return new int[] {}; + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/readme.md b/src/main/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/readme.md new file mode 100644 index 000000000..7c381da51 --- /dev/null +++ b/src/main/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/readme.md @@ -0,0 +1,54 @@ +3752\. Lexicographically Smallest Negated Permutation that Sums to Target + +Medium + +You are given a positive integer `n` and an integer `target`. + +Return the **lexicographically smallest** array of integers of size `n` such that: + +* The **sum** of its elements equals `target`. +* The **absolute values** of its elements form a **permutation** of size `n`. + +If no such array exists, return an empty array. + +A **permutation** of size `n` is a rearrangement of integers `1, 2, ..., n`. + +**Example 1:** + +**Input:** n = 3, target = 0 + +**Output:** [-3,1,2] + +**Explanation:** + +The arrays that sum to 0 and whose absolute values form a permutation of size 3 are: + +* `[-3, 1, 2]` +* `[-3, 2, 1]` +* `[-2, -1, 3]` +* `[-2, 3, -1]` +* `[-1, -2, 3]` +* `[-1, 3, -2]` +* `[1, -3, 2]` +* `[1, 2, -3]` +* `[2, -3, 1]` +* `[2, 1, -3]` +* `[3, -2, -1]` +* `[3, -1, -2]` + +The lexicographically smallest one is `[-3, 1, 2]`. + +**Example 2:** + +**Input:** n = 1, target = 10000000000 + +**Output:** [] + +**Explanation:** + +There are no arrays that sum to 10000000000 and whose absolute values form a permutation of size 1. Therefore, the answer is `[]`. + +**Constraints:** + +* 1 <= n <= 105 +* -1010 <= target <= 1010 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/Solution.java b/src/main/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/Solution.java new file mode 100644 index 000000000..4f09ec544 --- /dev/null +++ b/src/main/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/Solution.java @@ -0,0 +1,78 @@ +package g3701_3800.s3753_total_waviness_of_numbers_in_range_ii; + +// #Hard #Dynamic_Programming #Math #Senior_Staff #Biweekly_Contest_170 +// #2026_04_26_Time_52_ms_(96.83%)_Space_46.46_MB_(98.41%) + +public class Solution { + private static class Pair { + long count; + long sum; + + Pair(long count, long sum) { + this.count = count; + this.sum = sum; + } + } + + private char[] digits; + private Pair[][][][][] memo; + private boolean[][][][][] seen; + + public long totalWaviness(long num1, long num2) { + return solve(num2) - solve(num1 - 1); + } + + private long solve(long x) { + if (x <= 0) { + return 0; + } + digits = Long.toString(x).toCharArray(); + int n = digits.length; + memo = new Pair[n][2][2][11][11]; + seen = new boolean[n][2][2][11][11]; + return dfs(0, 1, 0, 10, 10).sum; + } + + private Pair dfs(int pos, int tight, int started, int prev2, int prev1) { + if (pos == digits.length) { + return new Pair(1, 0); + } + if (seen[pos][tight][started][prev2][prev1]) { + return memo[pos][tight][started][prev2][prev1]; + } + seen[pos][tight][started][prev2][prev1] = true; + int limit = tight == 1 ? digits[pos] - '0' : 9; + long totalCount = 0; + long totalSum = 0; + for (int d = 0; d <= limit; d++) { + int nextTight = (tight == 1 && d == limit) ? 1 : 0; + if (started == 0 && d == 0) { + // still leading zeros, number not started + Pair nxt = dfs(pos + 1, nextTight, 0, 10, 10); + totalCount += nxt.count; + totalSum += nxt.sum; + } else if (started == 0) { + // first real digit + Pair nxt = dfs(pos + 1, nextTight, 1, 10, d); + totalCount += nxt.count; + totalSum += nxt.sum; + } else if (prev2 == 10) { + // second real digit + Pair nxt = dfs(pos + 1, nextTight, 1, prev1, d); + totalCount += nxt.count; + totalSum += nxt.sum; + } else { + // now prev1 is an interior candidate, decide if it is peak/valley + int add = 0; + if ((prev1 > prev2 && prev1 > d) || (prev1 < prev2 && prev1 < d)) { + add = 1; + } + Pair nxt = dfs(pos + 1, nextTight, 1, prev1, d); + totalCount += nxt.count; + totalSum += nxt.sum + add * nxt.count; + } + } + memo[pos][tight][started][prev2][prev1] = new Pair(totalCount, totalSum); + return memo[pos][tight][started][prev2][prev1]; + } +} diff --git a/src/main/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/readme.md b/src/main/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/readme.md new file mode 100644 index 000000000..ece80ce70 --- /dev/null +++ b/src/main/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/readme.md @@ -0,0 +1,62 @@ +3753\. Total Waviness of Numbers in Range II + +Hard + +You are given two integers `num1` and `num2` representing an **inclusive** range `[num1, num2]`. + +The **waviness** of a number is defined as the total count of its **peaks** and **valleys**: + +* A digit is a **peak** if it is **strictly greater** than both of its immediate neighbors. +* A digit is a **valley** if it is **strictly less** than both of its immediate neighbors. +* The first and last digits of a number **cannot** be peaks or valleys. +* Any number with fewer than 3 digits has a waviness of 0. + +Return the total sum of waviness for all numbers in the range `[num1, num2]`. + +**Example 1:** + +**Input:** num1 = 120, num2 = 130 + +**Output:** 3 + +**Explanation:** + +In the range `[120, 130]`: + +* `120`: middle digit 2 is a peak, waviness = 1. +* `121`: middle digit 2 is a peak, waviness = 1. +* `130`: middle digit 3 is a peak, waviness = 1. +* All other numbers in the range have a waviness of 0. + +Thus, total waviness is `1 + 1 + 1 = 3`. + +**Example 2:** + +**Input:** num1 = 198, num2 = 202 + +**Output:** 3 + +**Explanation:** + +In the range `[198, 202]`: + +* `198`: middle digit 9 is a peak, waviness = 1. +* `201`: middle digit 0 is a valley, waviness = 1. +* `202`: middle digit 0 is a valley, waviness = 1. +* All other numbers in the range have a waviness of 0. + +Thus, total waviness is `1 + 1 + 1 = 3`. + +**Example 3:** + +**Input:** num1 = 4848, num2 = 4848 + +**Output:** 2 + +**Explanation:** + +Number `4848`: the second digit 8 is a peak, and the third digit 4 is a valley, giving a waviness of 2. + +**Constraints:** + +* 1 <= num1 <= num2 <= 1015 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/Solution.java b/src/main/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/Solution.java new file mode 100644 index 000000000..679438891 --- /dev/null +++ b/src/main/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/Solution.java @@ -0,0 +1,32 @@ +package g3701_3800.s3754_concatenate_non_zero_digits_and_multiply_by_sum_i; + +// #Easy #Math #Mid_Level #Weekly_Contest_477 +// #2026_04_25_Time_1_ms_(100.00%)_Space_42.50_MB_(73.85%) + +public class Solution { + public long sumAndMultiply(int n) { + int newNum = 0; + int y = Math.abs(n); + while (y > 0) { + int rem = y % 10; + if (rem != 0) { + newNum = newNum * 10 + rem; + } + y /= 10; + } + int temp = 0; + while (newNum > 0) { + int rem = newNum % 10; + temp = temp * 10 + rem; + newNum /= 10; + } + int x = temp; + long sum = 0; + while (temp > 0) { + int rem = temp % 10; + sum += rem; + temp /= 10; + } + return sum * x; + } +} diff --git a/src/main/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/readme.md b/src/main/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/readme.md new file mode 100644 index 000000000..636cdd934 --- /dev/null +++ b/src/main/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/readme.md @@ -0,0 +1,38 @@ +3754\. Concatenate Non-Zero Digits and Multiply by Sum I + +Easy + +You are given an integer `n`. + +Form a new integer `x` by concatenating all the **non-zero digits** of `n` in their original order. If there are no **non-zero** digits, `x = 0`. + +Let `sum` be the **sum of digits** in `x`. + +Return an integer representing the value of `x * sum`. + +**Example 1:** + +**Input:** n = 10203004 + +**Output:** 12340 + +**Explanation:** + +* The non-zero digits are 1, 2, 3, and 4. Thus, `x = 1234`. +* The sum of digits is `sum = 1 + 2 + 3 + 4 = 10`. +* Therefore, the answer is `x * sum = 1234 * 10 = 12340`. + +**Example 2:** + +**Input:** n = 1000 + +**Output:** 1 + +**Explanation:** + +* The non-zero digit is 1, so `x = 1` and `sum = 1`. +* Therefore, the answer is `x * sum = 1 * 1 = 1`. + +**Constraints:** + +* 0 <= n <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/Solution.java b/src/main/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/Solution.java new file mode 100644 index 000000000..18833f611 --- /dev/null +++ b/src/main/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/Solution.java @@ -0,0 +1,30 @@ +package g3701_3800.s3755_find_maximum_balanced_xor_subarray_length; + +// #Medium #Array #Hash_Table #Bit_Manipulation #Prefix_Sum #Senior #Weekly_Contest_477 +// #2026_04_25_Time_91_ms_(98.50%)_Space_256.08_MB_(93.23%) + +import java.util.HashMap; +import java.util.Map; + +public class Solution { + public int maxBalancedSubarray(int[] nums) { + int n = nums.length; + int ans = 0; + int xor = 0; + int diff = n; + Map pos = new HashMap<>(n + 1, 1); + pos.put((long) xor << 20 | diff, -1); + for (int i = 0; i < n; i++) { + xor ^= nums[i]; + diff += nums[i] % 2 != 0 ? 1 : -1; + long key = (long) xor << 20 | diff; + Integer j = pos.get(key); + if (j != null) { + ans = Math.max(ans, i - j); + } else { + pos.put(key, i); + } + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/readme.md b/src/main/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/readme.md new file mode 100644 index 000000000..8b0b1129a --- /dev/null +++ b/src/main/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/readme.md @@ -0,0 +1,40 @@ +3755\. Find Maximum Balanced XOR Subarray Length + +Medium + +Given an integer array `nums`, return the **length** of the **longest non-empty subarrays** that has a bitwise XOR of zero and contains an **equal** number of **even** and **odd** numbers. If no such subarray exists, return 0. + +**Example 1:** + +**Input:** nums = [3,1,3,2,0] + +**Output:** 4 + +**Explanation:** + +The subarray `[1, 3, 2, 0]` has bitwise XOR `1 XOR 3 XOR 2 XOR 0 = 0` and contains 2 even and 2 odd numbers. + +**Example 2:** + +**Input:** nums = [3,2,8,5,4,14,9,15] + +**Output:** 8 + +**Explanation:** + +The whole array has bitwise XOR `0` and contains 4 even and 4 odd numbers. + +**Example 3:** + +**Input:** nums = [0] + +**Output:** 0 + +**Explanation:** + +No non-empty subarray satisfies both conditions. + +**Constraints:** + +* 1 <= nums.length <= 105 +* 0 <= nums[i] <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/Solution.java b/src/main/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/Solution.java new file mode 100644 index 000000000..d7805b14e --- /dev/null +++ b/src/main/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/Solution.java @@ -0,0 +1,38 @@ +package g3701_3800.s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii; + +// #Medium #String #Math #Prefix_Sum #Staff #Weekly_Contest_477 +// #2026_04_25_Time_14_ms_(100.00%)_Space_131.16_MB_(32.94%) + +public class Solution { + private static final long MOD = 1_000_000_007; + + public int[] sumAndMultiply(String s, int[][] queries) { + int m = s.length(); + long[] p = new long[m + 1]; + long[] sum = new long[m + 1]; + int[] cnt = new int[m + 1]; + long[] pow10 = new long[m + 1]; + pow10[0] = 1; + for (int i = 0; i < m; i++) { + int d = s.charAt(i) - '0'; + if (d != 0) { + p[i + 1] = (p[i] * 10 + d) % MOD; + } else { + p[i + 1] = p[i]; + } + sum[i + 1] = sum[i] + d; + cnt[i + 1] = cnt[i] + (d != 0 ? 1 : 0); + pow10[i + 1] = pow10[i] * 10 % MOD; + } + int[] ans = new int[queries.length]; + for (int i = 0; i < queries.length; i++) { + int l = queries[i][0]; + int r = queries[i][1]; + int k = cnt[r + 1] - cnt[l]; + long x = (p[r + 1] - p[l] * pow10[k] % MOD + MOD) % MOD; + long digitSum = sum[r + 1] - sum[l]; + ans[i] = (int) (x * digitSum % MOD); + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/readme.md b/src/main/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/readme.md new file mode 100644 index 000000000..2a409811d --- /dev/null +++ b/src/main/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/readme.md @@ -0,0 +1 @@ +3756\. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3757_number_of_effective_subsequences/Solution.java b/src/main/java/g3701_3800/s3757_number_of_effective_subsequences/Solution.java new file mode 100644 index 000000000..76feb9358 --- /dev/null +++ b/src/main/java/g3701_3800/s3757_number_of_effective_subsequences/Solution.java @@ -0,0 +1,65 @@ +package g3701_3800.s3757_number_of_effective_subsequences; + +// #Hard #Array #Dynamic_Programming #Math #Bit_Manipulation #Combinatorics #Senior_Staff +// #Weekly_Contest_477 #2026_04_25_Time_128_ms_(95.71%)_Space_85.91_MB_(18.57%) + +public class Solution { + private static final int MOD = 1_000_000_007; + + public int countEffective(int[] nums) { + int n = nums.length; + int t = 0; + for (int v : nums) { + t |= v; + } + if (t == 0) { + return 0; + } + int[] bits = new int[20]; + int m = 0; + for (int b = 0; b < 20; ++b) { + if (((t >> b) & 1) != 0) { + bits[m++] = b; + } + } + int s = 1 << m; + int[] freq = new int[s]; + for (int v : nums) { + int m1 = 0; + for (int j = 0; j < m; ++j) { + if (((v >> bits[j]) & 1) != 0) { + m1 |= 1 << j; + } + } + freq[m1]++; + } + int[] f = new int[s]; + System.arraycopy(freq, 0, f, 0, s); + for (int i = 0; i < m; ++i) { + for (int mask = 0; mask < s; ++mask) { + if ((mask & (1 << i)) != 0) { + f[mask] += f[mask ^ (1 << i)]; + } + } + } + long[] p2 = new long[n + 1]; + p2[0] = 1; + for (int i = 1; i <= n; ++i) { + p2[i] = (p2[i - 1] << 1) % MOD; + } + long ans = 0; + int all = s - 1; + for (int bmask = 1; bmask < s; ++bmask) { + int comp = all ^ bmask; + int cnt = f[comp]; + long add = p2[cnt]; + if (Integer.bitCount(bmask) % 2 == 1) { + ans = (ans + add) % MOD; + } else { + ans = (ans - add) % MOD; + } + } + ans = (ans % MOD + MOD) % MOD; + return (int) ans; + } +} diff --git a/src/main/java/g3701_3800/s3757_number_of_effective_subsequences/readme.md b/src/main/java/g3701_3800/s3757_number_of_effective_subsequences/readme.md new file mode 100644 index 000000000..910d9460b --- /dev/null +++ b/src/main/java/g3701_3800/s3757_number_of_effective_subsequences/readme.md @@ -0,0 +1,78 @@ +3757\. Number of Effective Subsequences + +Hard + +You are given an integer array `nums`. + +The **strength** of the array is defined as the **bitwise OR** of all its elements. + +A **subsequence** is considered **effective** if removing that subsequence **strictly decreases** the strength of the remaining elements. + +Return the number of **effective subsequences** in `nums`. Since the answer may be large, return it **modulo** 109 + 7. + +The bitwise OR of an empty array is 0. + +**Example 1:** + +**Input:** nums = [1,2,3] + +**Output:** 3 + +**Explanation:** + +* The Bitwise OR of the array is `1 OR 2 OR 3 = 3`. +* Subsequences that are effective are: + * `[1, 3]`: The remaining element `[2]` has a Bitwise OR of 2. + * `[2, 3]`: The remaining element `[1]` has a Bitwise OR of 1. + * `[1, 2, 3]`: The remaining elements `[]` have a Bitwise OR of 0. +* Thus, the total number of effective subsequences is 3. + +**Example 2:** + +**Input:** nums = [7,4,6] + +**Output:** 4 + +**Explanation:** + +* The Bitwise OR of the array is `7 OR 4 OR 6 = 7`. +* Subsequences that are effective are: + * `[7]`: The remaining elements `[4, 6]` have a Bitwise OR of 6. + * `[7, 4]`: The remaining element `[6]` has a Bitwise OR of 6. + * `[7, 6]`: The remaining element `[4]` has a Bitwise OR of 4. + * `[7, 4, 6]`: The remaining elements `[]` have a Bitwise OR of 0. +* Thus, the total number of effective subsequences is 4. + +**Example 3:** + +**Input:** nums = [8,8] + +**Output:** 1 + +**Explanation:** + +* The Bitwise OR of the array is `8 OR 8 = 8`. +* Only the subsequence `[8, 8]` is effective since removing it leaves `[]` which has a Bitwise OR of 0. +* Thus, the total number of effective subsequences is 1. + +**Example 4:** + +**Input:** nums = [2,2,1] + +**Output:** 5 + +**Explanation:** + +* The Bitwise OR of the array is `2 OR 2 OR 1 = 3`. +* Subsequences that are effective are: + * `[1]`: The remaining elements `[2, 2]` have a Bitwise OR of 2. + * `[2, 1]` (using `nums[0]`, `nums[2]`): The remaining element `[2]` has a Bitwise OR of 2. + * `[2, 1]` (using `nums[1]`, `nums[2]`): The remaining element `[2]` has a Bitwise OR of 2. + * `[2, 2]`: The remaining element `[1]` has a Bitwise OR of 1. + * `[2, 2, 1]`: The remaining elements `[]` have a Bitwise OR of 0. +* Thus, the total number of effective subsequences is 5. + +**Constraints:** + +* 1 <= nums.length <= 105 +* 1 <= nums[i] <= 106 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/Solution.java b/src/main/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/Solution.java new file mode 100644 index 000000000..e06331f6e --- /dev/null +++ b/src/main/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/Solution.java @@ -0,0 +1,24 @@ +package g3701_3800.s3759_count_elements_with_at_least_k_greater_values; + +// #Medium #Array #Sorting #Binary_Search #Divide_and_Conquer #Quickselect #Senior +// #Weekly_Contest_478 #2026_04_25_Time_40_ms_(96.15%)_Space_134.18_MB_(73.08%) + +import java.util.Arrays; + +public class Solution { + public int countElements(int[] nums, int k) { + if (k == 0) { + return nums.length; + } + Arrays.sort(nums); + int i = nums.length - k; + int n = nums[i]; + if (nums[0] == n) { + return 0; + } + while (n == nums[i]) { + i--; + } + return i + 1; + } +} diff --git a/src/main/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/readme.md b/src/main/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/readme.md new file mode 100644 index 000000000..0acf1ac95 --- /dev/null +++ b/src/main/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/readme.md @@ -0,0 +1,36 @@ +3759\. Count Elements With at Least K Greater Values + +Medium + +You are given an integer array `nums` of length `n` and an integer `k`. + +An element in `nums` is said to be **qualified** if there exist **at least** `k` elements in the array that are **strictly greater** than it. + +Return an integer denoting the total number of qualified elements in `nums`. + +**Example 1:** + +**Input:** nums = [3,1,2], k = 1 + +**Output:** 2 + +**Explanation:** + +The elements 1 and 2 each have at least `k = 1` element greater than themselves. + No element is greater than 3. Therefore, the answer is 2. + +**Example 2:** + +**Input:** nums = [5,5,5], k = 2 + +**Output:** 0 + +**Explanation:** + +Since all elements are equal to 5, no element is greater than the other. Therefore, the answer is 0. + +**Constraints:** + +* 1 <= n == nums.length <= 105 +* 1 <= nums[i] <= 109 +* `0 <= k < n` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/Solution.java b/src/main/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/Solution.java new file mode 100644 index 000000000..2cf37828c --- /dev/null +++ b/src/main/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/Solution.java @@ -0,0 +1,22 @@ +package g3701_3800.s3760_maximum_substrings_with_distinct_start; + +// #Medium #String #Hash_Table #Senior #Weekly_Contest_478 +// #2026_05_08_Time_5_ms_(98.92%)_Space_47.79_MB_(74.99%) + +public class Solution { + public int maxDistinct(String s) { + int mask = 0; + int res = 0; + for (char c : s.toCharArray()) { + int bit = 1 << (c - 'a'); + if ((mask & bit) == 0) { + mask |= bit; + res++; + if (res == 26) { + break; + } + } + } + return res; + } +} diff --git a/src/main/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/readme.md b/src/main/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/readme.md new file mode 100644 index 000000000..d9243db58 --- /dev/null +++ b/src/main/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/readme.md @@ -0,0 +1,45 @@ +3760\. Maximum Substrings With Distinct Start + +Medium + +You are given a string `s` consisting of lowercase English letters. + +Return an integer denoting the **maximum** number of substring you can split `s` into such that each **substring** starts with a **distinct** character (i.e., no two substrings start with the same character). + +**Example 1:** + +**Input:** s = "abab" + +**Output:** 2 + +**Explanation:** + +* Split `"abab"` into `"a"` and `"bab"`. +* Each substring starts with a distinct character i.e `'a'` and `'b'`. Thus, the answer is 2. + +**Example 2:** + +**Input:** s = "abcd" + +**Output:** 4 + +**Explanation:** + +* Split `"abcd"` into `"a"`, `"b"`, `"c"`, and `"d"`. +* Each substring starts with a distinct character. Thus, the answer is 4. + +**Example 3:** + +**Input:** s = "aaaa" + +**Output:** 1 + +**Explanation:** + +* All characters in `"aaaa"` are `'a'`. +* Only one substring can start with `'a'`. Thus, the answer is 1. + +**Constraints:** + +* 1 <= s.length <= 105 +* `s` consists of lowercase English letters. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/Solution.java b/src/main/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/Solution.java new file mode 100644 index 000000000..96693e412 --- /dev/null +++ b/src/main/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/Solution.java @@ -0,0 +1,26 @@ +package g3701_3800.s3761_minimum_absolute_distance_between_mirror_pairs; + +// #Medium #Array #Hash_Table #Math #Staff #Weekly_Contest_478 +// #2026_05_08_Time_49_ms_(84.83%)_Space_95.13_MB_(49.31%) + +import java.util.HashMap; + +public class Solution { + public int minMirrorPairDistance(int[] nums) { + int res = 100000; + int i = 0; + HashMap seen = new HashMap<>(); + for (int n : nums) { + int r; + if (seen.containsKey(n)) { + res = Math.min(res, i - seen.get(n)); + } + for (r = 0; n > 0; n /= 10) { + r = r * 10 + (n % 10); + } + seen.put(r, i++); + } + + return res == 100000 ? -1 : res; + } +} diff --git a/src/main/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/readme.md b/src/main/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/readme.md new file mode 100644 index 000000000..7333c65d2 --- /dev/null +++ b/src/main/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/readme.md @@ -0,0 +1,56 @@ +3761\. Minimum Absolute Distance Between Mirror Pairs + +Medium + +You are given an integer array `nums`. + +A **mirror pair** is a pair of indices `(i, j)` such that: + +* `0 <= i < j < nums.length`, and +* `reverse(nums[i]) == nums[j]`, where `reverse(x)` denotes the integer formed by reversing the digits of `x`. Leading zeros are omitted after reversing, for example `reverse(120) = 21`. + +Return the **minimum** absolute distance between the indices of any mirror pair. The absolute distance between indices `i` and `j` is `abs(i - j)`. + +If no mirror pair exists, return `-1`. + +**Example 1:** + +**Input:** nums = [12,21,45,33,54] + +**Output:** 1 + +**Explanation:** + +The mirror pairs are: + +* (0, 1) since `reverse(nums[0]) = reverse(12) = 21 = nums[1]`, giving an absolute distance `abs(0 - 1) = 1`. +* (2, 4) since `reverse(nums[2]) = reverse(45) = 54 = nums[4]`, giving an absolute distance `abs(2 - 4) = 2`. + +The minimum absolute distance among all pairs is 1. + +**Example 2:** + +**Input:** nums = [120,21] + +**Output:** 1 + +**Explanation:** + +There is only one mirror pair (0, 1) since `reverse(nums[0]) = reverse(120) = 21 = nums[1]`. + +The minimum absolute distance is 1. + +**Example 3:** + +**Input:** nums = [21,120] + +**Output:** \-1 + +**Explanation:** + +There are no mirror pairs in the array. + +**Constraints:** + +* 1 <= nums.length <= 105 +* 1 <= nums[i] <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/Solution.java b/src/main/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/Solution.java new file mode 100644 index 000000000..f95f68fc3 --- /dev/null +++ b/src/main/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/Solution.java @@ -0,0 +1,222 @@ +package g3701_3800.s3762_minimum_operations_to_equalize_subarrays; + +// #Hard #Array #Math #Binary_Search #Segment_Tree #Weekly_Contest_478 #Principal +// #2026_05_08_Time_528_ms_(100.00%)_Space_267.97_MB_(76.92%) + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; + +public class Solution { + private static class MNode { + int l; + int r; + int[] vals; + long[] pref; + MNode left; + MNode right; + + MNode(int l, int r) { + this.l = l; + this.r = r; + } + } + + private static class Group { + int[] pos; + int[] val; + long[] prefPos; + MNode root; + int minv; + int maxv; + } + + private static int lowerBound(int[] a, int x) { + int l = 0; + int r = a.length; + while (l < r) { + int m = (l + r) >>> 1; + if (a[m] >= x) { + r = m; + } else { + l = m + 1; + } + } + return l; + } + + private int upperBound(int[] a, int x) { + int l = 0; + int r = a.length; + while (l < r) { + int m = (l + r) >>> 1; + if (a[m] > x) { + r = m; + } else { + l = m + 1; + } + } + return l; + } + + private MNode buildMerge(int[] arr, int l, int r) { + MNode node = new MNode(l, r); + if (l == r) { + node.vals = new int[] {arr[l]}; + node.pref = new long[] {arr[l]}; + return node; + } + int m = (l + r) >>> 1; + node.left = buildMerge(arr, l, m); + node.right = buildMerge(arr, m + 1, r); + int[] a = node.left.vals; + int[] b = node.right.vals; + int na = a.length; + int nb = b.length; + int[] c = new int[na + nb]; + long[] pref = new long[na + nb]; + int ia = 0; + int ib = 0; + int k = 0; + while (ia < na && ib < nb) { + if (a[ia] <= b[ib]) { + c[k++] = a[ia++]; + } else { + c[k++] = b[ib++]; + } + } + while (ia < na) { + c[k++] = a[ia++]; + } + while (ib < nb) { + c[k++] = b[ib++]; + } + pref[0] = c[0]; + for (int i = 1; i < c.length; i++) { + pref[i] = pref[i - 1] + c[i]; + } + node.vals = c; + node.pref = pref; + return node; + } + + private int countLE(MNode node, int ql, int qr, int x) { + if (node == null || ql > node.r || qr < node.l) { + return 0; + } + if (ql <= node.l && node.r <= qr) { + int idx = upperBound(node.vals, x) - 1; + return idx < 0 ? 0 : idx + 1; + } + return countLE(node.left, ql, qr, x) + countLE(node.right, ql, qr, x); + } + + private long sumLE(MNode node, int ql, int qr, int x) { + if (node == null || ql > node.r || qr < node.l) { + return 0L; + } + if (ql <= node.l && node.r <= qr) { + int idx = upperBound(node.vals, x) - 1; + return idx < 0 ? 0L : node.pref[idx]; + } + return sumLE(node.left, ql, qr, x) + sumLE(node.right, ql, qr, x); + } + + public long[] minOperations(int[] nums, int k, int[][] queries) { + Map groupHashMap = buildGroups(nums, k); + long[] ans = new long[queries.length]; + for (int qi = 0; qi < queries.length; qi++) { + ans[qi] = processQuery(nums, queries[qi], groupHashMap, k); + } + return ans; + } + + private Map buildGroups(int[] nums, int k) { + Map> map = new HashMap<>(); + for (int i = 0; i < nums.length; i++) { + int rem = nums[i] % k; + int value = nums[i] / k; + map.computeIfAbsent(rem, z -> new ArrayList<>()).add(new int[] {i, value}); + } + Map groupHashMap = new HashMap<>(); + for (Map.Entry> entry : map.entrySet()) { + groupHashMap.put(entry.getKey(), createGroup(entry.getValue())); + } + return groupHashMap; + } + + private Group createGroup(ArrayList arr) { + arr.sort(Comparator.comparingInt(a -> a[0])); + int size = arr.size(); + int[] pos = new int[size]; + int[] val = new int[size]; + long[] prefPos = new long[size]; + int min = Integer.MAX_VALUE; + int max = Integer.MIN_VALUE; + for (int i = 0; i < size; i++) { + pos[i] = arr.get(i)[0]; + val[i] = arr.get(i)[1]; + min = Math.min(min, val[i]); + max = Math.max(max, val[i]); + prefPos[i] = i == 0 ? val[i] : prefPos[i - 1] + val[i]; + } + Group group = new Group(); + group.pos = pos; + group.val = val; + group.prefPos = prefPos; + group.minv = min; + group.maxv = max; + if (size > 0) { + group.root = buildMerge(val, 0, size - 1); + } + return group; + } + + private long processQuery(int[] nums, int[] query, Map groupHashMap, int k) { + int left = query[0]; + int right = query[1]; + int rem = nums[left] % k; + Group group = groupHashMap.get(rem); + if (group == null) { + return -1; + } + int l = lowerBound(group.pos, left); + int r = upperBound(group.pos, right) - 1; + if (!isValidRange(left, right, l, r)) { + return -1; + } + return calculateOperations(group, l, r); + } + + private boolean isValidRange(int left, int right, int l, int r) { + return l <= r && (r - l + 1 == right - left + 1); + } + + private long calculateOperations(Group group, int l, int r) { + int count = r - l + 1; + int median = findMedian(group, l, r, count); + long leftCount = countLE(group.root, l, r, median); + long leftSum = sumLE(group.root, l, r, median); + long total = group.prefPos[r] - (l == 0 ? 0L : group.prefPos[l - 1]); + long rightSum = total - leftSum; + long rightCount = count - leftCount; + return median * leftCount - leftSum + rightSum - median * rightCount; + } + + private int findMedian(Group group, int l, int r, int count) { + int need = (count + 1) / 2; + int low = group.minv; + int high = group.maxv; + while (low < high) { + int mid = low + ((high - low) >>> 1); + int currentCount = countLE(group.root, l, r, mid); + if (currentCount >= need) { + high = mid; + } else { + low = mid + 1; + } + } + return low; + } +} diff --git a/src/main/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/readme.md b/src/main/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/readme.md new file mode 100644 index 000000000..f0f048abe --- /dev/null +++ b/src/main/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/readme.md @@ -0,0 +1,57 @@ +3762\. Minimum Operations to Equalize Subarrays + +Hard + +You are given an integer array `nums` and an integer `k`. + +In one operation, you can **increase or decrease** any element of `nums` by **exactly** `k`. + +You are also given a 2D integer array `queries`, where each queries[i] = [li, ri]. + +For each query, find the **minimum** number of operations required to make **all** elements in the **non-empty subarrays** nums[li..ri] **equal**. If it is impossible, the answer for that query is `-1`. + +Return an array `ans`, where `ans[i]` is the answer for the ith query. + +**Example 1:** + +**Input:** nums = [1,4,7], k = 3, queries = [[0,1],[0,2]] + +**Output:** [1,2] + +**Explanation:** + +One optimal set of operations: + +| `i` | `[l_i, r_i]` | `nums[l_i..r_i]` | Possibility | Operations | Final `nums[l_i..r_i]` | `ans[i]` | +|---|---|---|---|---|---|---| +| 0 | [0, 1] | [1, 4] | Yes | `nums[0] + k = 1 + 3 = 4 = nums[1]` | [4, 4] | 1 | +| 1 | [0, 2] | [1, 4, 7] | Yes | `nums[0] + k = 1 + 3 = 4 = nums[1]`
`nums[2] - k = 7 - 3 = 4 = nums[1]` | [4, 4, 4] | 2 | + +Thus, `ans = [1, 2]`. + +**Example 2:** + +**Input:** nums = [1,2,4], k = 2, queries = [[0,2],[0,0],[1,2]] + +**Output:** [-1,0,1] + +**Explanation:** + +One optimal set of operations: + +| `i` | `[l_i, r_i]` | `nums[l_i..r_i]` | Possibility | Operations | Final `nums[l_i..r_i]` | `ans[i]` | +|---|---|---|---|---|---|---| +| 0 | [0, 2] | [1, 2, 4] | No | - | [1, 2, 4] | -1 | +| 1 | [0, 0] | [1] | Yes | Already equal | [1] | 0 | +| 2 | [1, 2] | [2, 4] | Yes | `nums[1] + k = 2 + 2 = 4 = nums[2]` | [4, 4] | 1 | + +Thus, `ans = [-1, 0, 1]`. + +**Constraints:** + +* 1 <= n == nums.length <= 4 × 104 +* 1 <= nums[i] <= 109 +* 1 <= k <= 109 +* 1 <= queries.length <= 4 × 104 +* queries[i] = [li, ri] +* 0 <= li <= ri <= n - 1 diff --git a/src/main/java/g3701_3800/s3764_most_common_course_pairs/readme.md b/src/main/java/g3701_3800/s3764_most_common_course_pairs/readme.md new file mode 100644 index 000000000..492a1b7d6 --- /dev/null +++ b/src/main/java/g3701_3800/s3764_most_common_course_pairs/readme.md @@ -0,0 +1,84 @@ +3764\. Most Common Course Pairs + +Hard + +Table: `course_completions` + + +-------------------+---------+ + | Column Name | Type | + +-------------------+---------+ + | user_id | int | + | course_id | int | + | course_name | varchar | + | completion_date | date | + | course_rating | int | + +-------------------+---------+ + (user_id, course_id) is the combination of columns with unique values for this table. + Each row represents a completed course by a user with their rating (1-5 scale). + +Write a solution to identify **skill mastery pathways** by analyzing course completion sequences among top-performing students: + +* Consider only **top-performing students** (those who completed **at least** `5` **courses** with an **average rating of** `4` **or higher**). +* For each top performer, identify the **sequence of courses** they completed in chronological order. +* Find all **consecutive course pairs** (`Course A → Course B`) taken by these students. +* Return the **pair frequency**, identifying which course transitions are most common among high achievers. + +Return _the result table ordered by_ _pair frequency in **descending** order_ _and then by first course name and second course name in **ascending** order_. + +The result format is in the following example. + +**Example:** + +**Input:** + +course_completions table: + + +---------+-----------+---------------------+-----------------+---------------+ + | user_id | course_id | course_name | completion_date | course_rating | + +---------+-----------+---------------------+-----------------+---------------+ + | 1 | 101 | Python Basics | 2024-01-05 | 5 | + | 1 | 102 | SQL Fundamentals | 2024-02-10 | 4 | + | 1 | 103 | JavaScript | 2024-03-15 | 5 | + | 1 | 104 | React Basics | 2024-04-20 | 4 | + | 1 | 105 | Node.js | 2024-05-25 | 5 | + | 1 | 106 | Docker | 2024-06-30 | 4 | + | 2 | 101 | Python Basics | 2024-01-08 | 4 | + | 2 | 104 | React Basics | 2024-02-14 | 5 | + | 2 | 105 | Node.js | 2024-03-20 | 4 | + | 2 | 106 | Docker | 2024-04-25 | 5 | + | 2 | 107 | AWS Fundamentals | 2024-05-30 | 4 | + | 3 | 101 | Python Basics | 2024-01-10 | 3 | + | 3 | 102 | SQL Fundamentals | 2024-02-12 | 3 | + | 3 | 103 | JavaScript | 2024-03-18 | 3 | + | 3 | 104 | React Basics | 2024-04-22 | 2 | + | 3 | 105 | Node.js | 2024-05-28 | 3 | + | 4 | 101 | Python Basics | 2024-01-12 | 5 | + | 4 | 108 | Data Science | 2024-02-16 | 5 | + | 4 | 109 | Machine Learning | 2024-03-22 | 5 | + +---------+-----------+---------------------+-----------------+---------------+ + +**Output:** + + +------------------+-------------------+------------------+ + | first_course | second_course | transition_count | + +------------------+-------------------+------------------+ + | Node.js | Docker | 2 | + | React Basics | Node.js | 2 | + | Docker | AWS Fundamentals | 1 | + | JavaScript | React Basics | 1 | + | Python Basics | React Basics | 1 | + | Python Basics | SQL Fundamentals | 1 | + | SQL Fundamentals | JavaScript | 1 | + +------------------+-------------------+------------------+ +**Explanation:** + +* **User 1**: Completed 6 courses with average rating 4.5 (qualifies as top performer) +* **User 2**: Completed 5 courses with average rating 4.4 (qualifies as top performer) +* **User 3**: Completed 5 courses but average rating is 2.8 (does not qualify) +* **User 4**: Completed only 3 courses (does not qualify) +* **Course Pairs Among Top Performers**: + * User 1: Python Basics → SQL Fundamentals → JavaScript → React Basics → Node.js → Docker + * User 2: Python Basics → React Basics → Node.js → Docker → AWS Fundamentals + * Most common transitions: Node.js → Docker (2 times), React Basics → Node.js (2 times) + +Results are ordered by transition_count in descending order, then by first_course in ascending order, and then by second_course in ascending order. diff --git a/src/main/java/g3701_3800/s3764_most_common_course_pairs/script.sql b/src/main/java/g3701_3800/s3764_most_common_course_pairs/script.sql new file mode 100644 index 000000000..4ea151824 --- /dev/null +++ b/src/main/java/g3701_3800/s3764_most_common_course_pairs/script.sql @@ -0,0 +1,27 @@ +# Write your MySQL query statement below +# #Hard #2026_05_08_Time_262_ms_(63.61%)_Space_0.0_MB_(100.00%) +-- Find the most common course-to-next-course transitions +-- among engaged users (>=5 courses, avg rating >= 4) +SELECT + course_name AS first_course, + next_course AS second_course, + COUNT(*) AS transition_count +FROM ( + SELECT + *, + LEAD(course_name) OVER ( + PARTITION BY user_id + ORDER BY completion_date + ) AS next_course + FROM course_completions + WHERE user_id IN ( + SELECT user_id + FROM course_completions + GROUP BY user_id + HAVING COUNT(course_id) >= 5 + AND AVG(course_rating) >= 4 + ) +) AS t +WHERE next_course IS NOT NULL +GROUP BY course_name, next_course +ORDER BY transition_count DESC, first_course ASC, second_course ASC; diff --git a/src/main/java/g3701_3800/s3765_complete_prime_number/Solution.java b/src/main/java/g3701_3800/s3765_complete_prime_number/Solution.java new file mode 100644 index 000000000..e00537b2d --- /dev/null +++ b/src/main/java/g3701_3800/s3765_complete_prime_number/Solution.java @@ -0,0 +1,36 @@ +package g3701_3800.s3765_complete_prime_number; + +// #Medium #Math #Enumeration #Number_Theory #Senior #Biweekly_Contest_171 +// #2026_05_08_Time_2_ms_(91.62%)_Space_42.93_MB_(55.39%) + +public class Solution { + private boolean isPrime(int n) { + if (n != 2 && n % 2 == 0) { + return false; + } + for (int i = 3; i * i <= n; i += 2) { + if (n % i == 0) { + return false; + } + } + return true; + } + + public boolean completePrime(int num) { + int y = 0; + int z = 1; + int x = num; + while (x > 0) { + y = z * (x % 10) + y; + if (y == 1 || !isPrime(y)) { + return false; + } + if (x == 1 || !isPrime(x)) { + return false; + } + x /= 10; + z *= 10; + } + return true; + } +} diff --git a/src/main/java/g3701_3800/s3765_complete_prime_number/readme.md b/src/main/java/g3701_3800/s3765_complete_prime_number/readme.md new file mode 100644 index 000000000..36922bd1f --- /dev/null +++ b/src/main/java/g3701_3800/s3765_complete_prime_number/readme.md @@ -0,0 +1,53 @@ +3765\. Complete Prime Number + +Medium + +You are given an integer `num`. + +A number `num` is called a **Complete Prime Number** if every **prefix** and every **suffix** of `num` is **prime**. + +Return `true` if `num` is a Complete Prime Number, otherwise return `false`. + +**Note**: + +* A **prefix** of a number is formed by the **first** `k` digits of the number. +* A **suffix** of a number is formed by the **last** `k` digits of the number. +* Single-digit numbers are considered Complete Prime Numbers only if they are **prime**. + +**Example 1:** + +**Input:** num = 23 + +**Output:** true + +**Explanation:** + +* Prefixes of `num = 23` are 2 and 23, both are prime. +* Suffixes of `num = 23` are 3 and 23, both are prime. +* All prefixes and suffixes are prime, so 23 is a Complete Prime Number and the answer is `true`. + +**Example 2:** + +**Input:** num = 39 + +**Output:** false + +**Explanation:** + +* Prefixes of `num = 39` are 3 and 39. 3 is prime, but 39 is not prime. +* Suffixes of `num = 39` are 9 and 39. Both 9 and 39 are not prime. +* At least one prefix or suffix is not prime, so 39 is not a Complete Prime Number and the answer is `false`. + +**Example 3:** + +**Input:** num = 7 + +**Output:** true + +**Explanation:** + +* 7 is prime, so all its prefixes and suffixes are prime and the answer is `true`. + +**Constraints:** + +* 1 <= num <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/Solution.java b/src/main/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/Solution.java new file mode 100644 index 000000000..cbc5a7a17 --- /dev/null +++ b/src/main/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/Solution.java @@ -0,0 +1,52 @@ +package g3701_3800.s3766_minimum_operations_to_make_binary_palindrome; + +// #Medium #Array #Binary_Search #Two_Pointers #Bit_Manipulation #Staff #Biweekly_Contest_171 +// #2026_05_08_Time_54_ms_(82.69%)_Space_47.43_MB_(64.42%) + +public class Solution { + private int binlen(int n) { + int c = 0; + while (n > 0) { + c++; + n >>= 1; + } + return c; + } + + private boolean isPal(int n) { + int l = 0; + int r = binlen(n) - 1; + while (l < r) { + if (((n >> l) & 1) != ((n >> r) & 1)) { + return false; + } + l++; + r--; + } + return true; + } + + public int[] minOperations(int[] nums) { + boolean[] binary = new boolean[5050]; + int[] ans = new int[nums.length]; + for (int i = 0; i < 5050; i++) { + binary[i] = isPal(i); + } + for (int i = 0; i < nums.length; i++) { + int a = nums[i]; + int b = nums[i]; + int c1 = 0; + int c2 = 0; + while (!binary[a]) { + a--; + c1++; + } + while (!binary[b]) { + b++; + c2++; + } + ans[i] = Math.min(c1, c2); + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/readme.md b/src/main/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/readme.md new file mode 100644 index 000000000..1eb6ac57a --- /dev/null +++ b/src/main/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/readme.md @@ -0,0 +1,55 @@ +3766\. Minimum Operations to Make Binary Palindrome + +Medium + +You are given an integer array `nums`. + +For each element `nums[i]`, you may perform the following operations **any** number of times (including zero): + +* Increase `nums[i]` by 1, or +* Decrease `nums[i]` by 1. + +A number is called a **binary palindrome** if its binary representation without leading zeros reads the same forward and backward. + +Your task is to return an integer array `ans`, where `ans[i]` represents the **minimum** number of operations required to convert `nums[i]` into a **binary palindrome**. + +**Example 1:** + +**Input:** nums = [1,2,4] + +**Output:** [0,1,1] + +**Explanation:** + +One optimal set of operations: + +| `nums[i]` | Binary(`nums[i]`) | Nearest Palindrome | Binary (Palindrome) | Operations Required | `ans[i]` | +|---|---|---|---|---|---| +| 1 | 1 | 1 | 1 | Already palindrome | 0 | +| 2 | 10 | 3 | 11 | Increase by 1 | 1 | +| 4 | 100 | 3 | 11 | Decrease by 1 | 1 | + +Thus, `ans = [0, 1, 1]`. + +**Example 2:** + +**Input:** nums = [6,7,12] + +**Output:** [1,0,3] + +**Explanation:** + +One optimal set of operations: + +| `nums[i]` | Binary(`nums[i]`) | Nearest Palindrome | Binary (Palindrome) | Operations Required | `ans[i]` | +|---|---|---|---|---|---| +| 6 | 110 | 5 | 101 | Decrease by 1 | 1 | +| 7 | 111 | 7 | 111 | Already palindrome | 0 | +| 12 | 1100 | 15 | 1111 | Increase by 3 | 3 | + +Thus, `ans = [1, 0, 3]`. + +**Constraints:** + +* `1 <= nums.length <= 5000` +* `1 <= nums[i] <= 5000` diff --git a/src/main/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/Solution.java b/src/main/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/Solution.java new file mode 100644 index 000000000..c8f52ac0a --- /dev/null +++ b/src/main/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/Solution.java @@ -0,0 +1,30 @@ +package g3701_3800.s3767_maximize_points_after_choosing_k_tasks; + +// #Medium #Array #Sorting #Greedy #Heap_Priority_Queue #Staff #Biweekly_Contest_171 +// #2026_05_08_Time_21_ms_(100.00%)_Space_130.40_MB_(85.82%) + +import java.util.PriorityQueue; + +public class Solution { + public long maxPoints(int[] technique1, int[] technique2, int k) { + int n = technique1.length; + int use2 = n - k; + PriorityQueue min = new PriorityQueue<>(); + long ans = 0; + for (int i = 0; i < n; ++i) { + int diff = technique2[i] - technique1[i]; + if (diff > 0) { + if (min.size() < use2) { + min.offer(diff); + ans += diff; + } else if (!min.isEmpty() && min.peek() < diff) { + ans -= min.poll(); + min.offer(diff); + ans += diff; + } + } + ans += technique1[i]; + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/readme.md b/src/main/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/readme.md new file mode 100644 index 000000000..d61da8f1e --- /dev/null +++ b/src/main/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/readme.md @@ -0,0 +1,58 @@ +3767\. Maximize Points After Choosing K Tasks + +Medium + +You are given two integer arrays, `technique1` and `technique2`, each of length `n`, where `n` represents the number of tasks to complete. + +* If the ith task is completed using technique 1, you earn `technique1[i]` points. +* If it is completed using technique 2, you earn `technique2[i]` points. + +You are also given an integer `k`, representing the **minimum** number of tasks that **must** be completed using technique 1. + +You **must** complete **at least** `k` tasks using technique 1 (they do not need to be the first `k` tasks). + +The remaining tasks may be completed using **either** technique. + +Return an integer denoting the **maximum total points** you can earn. + +**Example 1:** + +**Input:** technique1 = [5,2,10], technique2 = [10,3,8], k = 2 + +**Output:** 22 + +**Explanation:** + +We must complete at least `k = 2` tasks using `technique1`. + +Choosing `technique1[1]` and `technique1[2]` (completed using technique 1), and `technique2[0]` (completed using technique 2), yields the maximum points: `2 + 10 + 10 = 22`. + +**Example 2:** + +**Input:** technique1 = [10,20,30], technique2 = [5,15,25], k = 2 + +**Output:** 60 + +**Explanation:** + +We must complete at least `k = 2` tasks using `technique1`. + +Choosing all tasks using technique 1 yields the maximum points: `10 + 20 + 30 = 60`. + +**Example 3:** + +**Input:** technique1 = [1,2,3], technique2 = [4,5,6], k = 0 + +**Output:** 15 + +**Explanation:** + +Since `k = 0`, we are not required to choose any task using `technique1`. + +Choosing all tasks using technique 2 yields the maximum points: `4 + 5 + 6 = 15`. + +**Constraints:** + +* 1 <= n == technique1.length == technique2.length <= 105 +* 1 <= technique1[i], technique2[i] <= 105 +* `0 <= k <= n` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/Solution.java b/src/main/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/Solution.java new file mode 100644 index 000000000..a48cdb007 --- /dev/null +++ b/src/main/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/Solution.java @@ -0,0 +1,60 @@ +package g3701_3800.s3768_minimum_inversion_count_in_subarrays_of_fixed_length; + +// #Hard #Array #Sliding_Window #Segment_Tree #Senior_Staff #Biweekly_Contest_171 +// #2026_05_08_Time_157_ms_(94.34%)_Space_125.70_MB_(100.00%) + +import java.util.Arrays; + +public class Solution { + public long minInversionCount(int[] nums, int k) { + int n = nums.length; + // discretization of coordinates + int[] sorted = nums.clone(); + Arrays.sort(sorted); + for (int i = 0; i < n; i++) { + nums[i] = Arrays.binarySearch(sorted, nums[i]) + 1; + } + BinaryIndexedTree bit = new BinaryIndexedTree(n); + long invCount = 0L; + long ans = Long.MAX_VALUE; + for (int i = 0; i < n; i++) { + bit.add(nums[i], 1); + invCount += Math.min(i + 1, k) - bit.presum(nums[i]); + if (i < k - 1) { + continue; + } + ans = Math.min(ans, invCount); + invCount -= bit.presum(nums[i - k + 1] - 1); + bit.add(nums[i - k + 1], -1); + } + return ans; + } + + private class BinaryIndexedTree { + private final int[] tree; + + public BinaryIndexedTree(int n) { + tree = new int[n + 1]; + } + + public void add(int i, int val) { + while (i < tree.length) { + tree[i] += val; + i += lowbit(i); + } + } + + public int presum(int i) { + int sum = 0; + while (i > 0) { + sum += tree[i]; + i -= lowbit(i); + } + return sum; + } + + private int lowbit(int n) { + return n & (-n); + } + } +} diff --git a/src/main/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/readme.md b/src/main/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/readme.md new file mode 100644 index 000000000..7088d2594 --- /dev/null +++ b/src/main/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/readme.md @@ -0,0 +1,56 @@ +3768\. Minimum Inversion Count in Subarrays of Fixed Length + +Hard + +You are given an integer array `nums` of length `n` and an integer `k`. + +An **inversion** is a pair of indices `(i, j)` from `nums` such that `i < j` and `nums[i] > nums[j]`. + +The **inversion count** of a **non-empty subarrays** is the number of inversions within it. + +Return the **minimum** inversion count among all **subarrays** of `nums` with length `k`. + +**Example 1:** + +**Input:** nums = [3,1,2,5,4], k = 3 + +**Output:** 0 + +**Explanation:** + +We consider all subarrays of length `k = 3` (indices below are relative to each subarray): + +* `[3, 1, 2]` has 2 inversions: `(0, 1)` and `(0, 2)`. +* `[1, 2, 5]` has 0 inversions. +* `[2, 5, 4]` has 1 inversion: `(1, 2)`. + +The minimum inversion count among all subarrays of length `3` is 0, achieved by subarray `[1, 2, 5]`. + +**Example 2:** + +**Input:** nums = [5,3,2,1], k = 4 + +**Output:** 6 + +**Explanation:** + +There is only one subarray of length `k = 4`: `[5, 3, 2, 1]`. +Within this subarray, the inversions are: `(0, 1)`, `(0, 2)`, `(0, 3)`, `(1, 2)`, `(1, 3)`, and `(2, 3)`. +Total inversions is 6, so the minimum inversion count is 6. + +**Example 3:** + +**Input:** nums = [2,1], k = 1 + +**Output:** 0 + +**Explanation:** + +All subarrays of length `k = 1` contain only one element, so no inversions are possible. +The minimum inversion count is therefore 0. + +**Constraints:** + +* 1 <= n == nums.length <= 105 +* 1 <= nums[i] <= 109 +* `1 <= k <= n` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3769_sort_integers_by_binary_reflection/Solution.java b/src/main/java/g3701_3800/s3769_sort_integers_by_binary_reflection/Solution.java new file mode 100644 index 000000000..b7b3832a9 --- /dev/null +++ b/src/main/java/g3701_3800/s3769_sort_integers_by_binary_reflection/Solution.java @@ -0,0 +1,38 @@ +package g3701_3800.s3769_sort_integers_by_binary_reflection; + +// #Easy #Array #Sorting #Mid_Level #Weekly_Contest_479 +// #2026_05_08_Time_5_ms_(97.23%)_Space_46.52_MB_(97.70%) + +import java.util.PriorityQueue; + +public class Solution { + public int[] sortByReflection(int[] nums) { + PriorityQueue minHeap = + new PriorityQueue<>( + (a, b) -> { + if (a[1] == b[1]) { + return Integer.compare(a[0], b[0]); + } + return Integer.compare(a[1], b[1]); + }); + int[] sortedByReflection = new int[nums.length]; + for (int num : nums) { + minHeap.offer(new int[] {num, reverseBinary(num)}); + } + int idx = 0; + while (!minHeap.isEmpty()) { + sortedByReflection[idx++] = minHeap.poll()[0]; + } + return sortedByReflection; + } + + private int reverseBinary(int num) { + int reversed = 0; + while (num > 0) { + int lastBit = num & 1; + reversed = (reversed << 1) | lastBit; + num = num >> 1; + } + return reversed; + } +} diff --git a/src/main/java/g3701_3800/s3769_sort_integers_by_binary_reflection/readme.md b/src/main/java/g3701_3800/s3769_sort_integers_by_binary_reflection/readme.md new file mode 100644 index 000000000..b93acafb7 --- /dev/null +++ b/src/main/java/g3701_3800/s3769_sort_integers_by_binary_reflection/readme.md @@ -0,0 +1,50 @@ +3769\. Sort Integers by Binary Reflection + +Easy + +You are given an integer array `nums`. + +The **binary reflection** of a **positive** integer is defined as the number obtained by reversing the order of its **binary** digits (ignoring any leading zeros) and interpreting the resulting binary number as a decimal. + +Sort the array in **ascending** order based on the binary reflection of each element. If two different numbers have the same binary reflection, the **smaller** original number should appear first. + +Return the resulting sorted array. + +**Example 1:** + +**Input:** nums = [4,5,4] + +**Output:** [4,4,5] + +**Explanation:** + +Binary reflections are: + +* 4 -> (binary) `100` -> (reversed) `001` -> 1 +* 5 -> (binary) `101` -> (reversed) `101` -> 5 +* 4 -> (binary) `100` -> (reversed) `001` -> 1 + +Sorting by the reflected values gives `[4, 4, 5]`. + +**Example 2:** + +**Input:** nums = [3,6,5,8] + +**Output:** [8,3,6,5] + +**Explanation:** + +Binary reflections are: + +* 3 -> (binary) `11` -> (reversed) `11` -> 3 +* 6 -> (binary) `110` -> (reversed) `011` -> 3 +* 5 -> (binary) `101` -> (reversed) `101` -> 5 +* 8 -> (binary) `1000` -> (reversed) `0001` -> 1 + +Sorting by the reflected values gives `[8, 3, 6, 5]`. +Note that 3 and 6 have the same reflection, so we arrange them in increasing order of original value. + +**Constraints:** + +* `1 <= nums.length <= 100` +* 1 <= nums[i] <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/Solution.java b/src/main/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/Solution.java new file mode 100644 index 000000000..d14e8e197 --- /dev/null +++ b/src/main/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/Solution.java @@ -0,0 +1,29 @@ +package g3701_3800.s3770_largest_prime_from_consecutive_prime_sum; + +// #Medium #Array #Math #Number_Theory #Senior #Weekly_Contest_479 +// #2026_05_08_Time_1_ms_(100.00%)_Space_42.47_MB_(96.28%) + +public class Solution { + static int[] ppr = { + 2, 5, 17, 41, 197, 281, 7699, 8893, 22039, 24133, 25237, 28697, 32353, 37561, 38921, 43201, + 44683, 55837, 61027, 66463, 70241, 86453, 102001, 109147, 116533, 119069, 121631, 129419, + 132059, 263171, 287137, 325019, 329401, 333821, 338279, 342761, 360979, 379667, 393961, + 398771 + }; + + public int largestPrime(int n) { + int i = 0; + int j = ppr.length - 1; + int r = 0; + while (i <= j) { + int m = (i + j) >> 1; + if (ppr[m] <= n) { + r = ppr[m]; + i = m + 1; + } else { + j = m - 1; + } + } + return r; + } +} diff --git a/src/main/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/readme.md b/src/main/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/readme.md new file mode 100644 index 000000000..303111e34 --- /dev/null +++ b/src/main/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/readme.md @@ -0,0 +1,40 @@ +3770\. Largest Prime from Consecutive Prime Sum + +Medium + +You are given an integer `n`. + +Return the **largest prime number** less than or equal to `n` that can be expressed as the **sum** of one or more **consecutive prime numbers** starting from 2. If no such number exists, return 0. + +**Example 1:** + +**Input:** n = 20 + +**Output:** 17 + +**Explanation:** + +The prime numbers less than or equal to `n = 20` which are consecutive prime sums are: + +* `2 = 2` + +* `5 = 2 + 3` + +* `17 = 2 + 3 + 5 + 7` + + +The largest is 17, so it is the answer. + +**Example 2:** + +**Input:** n = 2 + +**Output:** 2 + +**Explanation:** + +The only consecutive prime sum less than or equal to 2 is 2 itself. + +**Constraints:** + +* 1 <= n <= 5 * 105 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3771_total_score_of_dungeon_runs/Solution.java b/src/main/java/g3701_3800/s3771_total_score_of_dungeon_runs/Solution.java new file mode 100644 index 000000000..99ebaeaa7 --- /dev/null +++ b/src/main/java/g3701_3800/s3771_total_score_of_dungeon_runs/Solution.java @@ -0,0 +1,35 @@ +package g3701_3800.s3771_total_score_of_dungeon_runs; + +// #Medium #Array #Binary_Search #Prefix_Sum #Staff #Weekly_Contest_479 +// #2026_05_07_Time_19_ms_(100.00%)_Space_170.56_MB_(72.37%) + +public class Solution { + public long totalScore(int hp, int[] damage, int[] requirement) { + int n = damage.length; + int[] cumulative = new int[n + 1]; + for (int i = n - 1; i >= 0; i--) { + cumulative[i] = cumulative[i + 1] + damage[i]; + } + long soln = 0; + for (int i = n - 1; i >= 0; i--) { + int adjHP = hp - requirement[i] + cumulative[i + 1]; + if (adjHP >= cumulative[i]) { + soln += i - binSearch(cumulative, adjHP, i) + 1; + } + } + return soln; + } + + private int binSearch(int[] arr, int hp, int l) { + int h = 0; + while (h < l) { + int mid = (h + l) >>> 1; + if (arr[mid] > hp) { + h = mid + 1; + } else { + l = mid; + } + } + return h; + } +} diff --git a/src/main/java/g3701_3800/s3771_total_score_of_dungeon_runs/readme.md b/src/main/java/g3701_3800/s3771_total_score_of_dungeon_runs/readme.md new file mode 100644 index 000000000..340370bc1 --- /dev/null +++ b/src/main/java/g3701_3800/s3771_total_score_of_dungeon_runs/readme.md @@ -0,0 +1,57 @@ +3771\. Total Score of Dungeon Runs + +Medium + +You are given a **positive** integer `hp` and two **positive** **1-indexed** integer arrays `damage` and `requirement`. + +There is a dungeon with `n` trap rooms numbered from 1 to `n`. Entering room `i` reduces your health points by `damage[i]`. After that reduction, if your remaining health points are **at least** `requirement[i]`, you earn **1 point** for that room. + +Let `score(j)` be the number of **points** you get if you start with `hp` health points and enter the rooms `j`, `j + 1`, ..., `n` in this order. + +Return the integer `score(1) + score(2) + ... + score(n)`, the sum of scores over all starting rooms. + +**Note**: You cannot skip rooms. You can finish your journey even if your health points become non-positive. + +**Example 1:** + +**Input:** hp = 11, damage = [3,6,7], requirement = [4,2,5] + +**Output:** 3 + +**Explanation:** + +`score(1) = 2`, `score(2) = 1`, `score(3) = 0`. The total score is `2 + 1 + 0 = 3`. + +As an example, `score(1) = 2` because you get 2 points if you start from room 1. + +* You start with 11 health points. +* Enter room 1. Your health points are now `11 - 3 = 8`. You get 1 point because `8 >= 4`. +* Enter room 2. Your health points are now `8 - 6 = 2`. You get 1 point because `2 >= 2`. +* Enter room 3. Your health points are now `2 - 7 = -5`. You do not get any points because `-5 < 5`. + +**Example 2:** + +**Input:** hp = 2, damage = [10000,1], requirement = [1,1] + +**Output:** 1 + +**Explanation:** + +`score(1) = 0`, `score(2) = 1`. The total score is `0 + 1 = 1`. + +`score(1) = 0` because you do not get any points if you start from room 1. + +* You start with 2 health points. +* Enter room 1. Your health points are now `2 - 10000 = -9998`. You do not get any points because `-9998 < 1`. +* Enter room 2. Your health points are now `-9998 - 1 = -9999`. You do not get any points because `-9999 < 1`. + +`score(2) = 1` because you get 1 point if you start from room 2. + +* You start with 2 health points. +* Enter room 2. Your health points are now `2 - 1 = 1`. You get 1 point because `1 >= 1`. + +**Constraints:** + +* 1 <= hp <= 109 +* 1 <= n == damage.length == requirement.length <= 105 +* 1 <= damage[i], requirement[i] <= 104 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/Solution.java b/src/main/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/Solution.java new file mode 100644 index 000000000..d1ec1d050 --- /dev/null +++ b/src/main/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/Solution.java @@ -0,0 +1,73 @@ +package g3701_3800.s3772_maximum_subgraph_score_in_a_tree; + +// #Hard #Array #Dynamic_Programming #Tree #Senior_Staff #Weekly_Contest_479 #Depth_First_Search +// #2026_05_08_Time_35_ms_(100.00%)_Space_279.46_MB_(74.36%) + +import java.util.Arrays; + +public class Solution { + public int[] maxSubgraphScore(int n, int[][] edges, int[] good) { + int[] h = new int[n]; + int[] e = new int[2 * (n - 1)]; + int[] ne = new int[2 * (n - 1)]; + int idx = 0; + Arrays.fill(h, -1); + for (int[] ed : edges) { + int a = ed[0]; + int b = ed[1]; + e[idx] = b; + ne[idx] = h[a]; + h[a] = idx; + idx++; + e[idx] = a; + ne[idx] = h[b]; + h[b] = idx; + idx++; + } + int[] v = new int[n]; + for (int i = 0; i < n; i++) { + v[i] = good[i] == 1 ? 1 : -1; + } + int[] dp = new int[n]; + int[] p = new int[n]; + int[] ord = new int[n]; + int top = 0; + Arrays.fill(p, -1); + int[] st = new int[n]; + int sp = 0; + boolean[] vis = new boolean[n]; + st[sp++] = 0; + vis[0] = true; + while (sp > 0) { + int u = st[--sp]; + ord[top++] = u; + for (int i = h[u]; i != -1; i = ne[i]) { + int w = e[i]; + if (!vis[w]) { + vis[w] = true; + p[w] = u; + st[sp++] = w; + } + } + } + for (int i = n - 1; i >= 0; i--) { + int u = ord[i]; + dp[u] = v[u]; + for (int j = h[u]; j != -1; j = ne[j]) { + int w = e[j]; + if (p[w] == u && dp[w] > 0) { + dp[u] += dp[w]; + } + } + } + int[] ans = new int[n]; + ans[0] = dp[0]; + for (int i = 1; i < n; i++) { + int u = ord[i]; + int par = p[u]; + int pc = ans[par] - Math.max(0, dp[u]); + ans[u] = dp[u] + Math.max(0, pc); + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/readme.md b/src/main/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/readme.md new file mode 100644 index 000000000..fd52c89c2 --- /dev/null +++ b/src/main/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/readme.md @@ -0,0 +1,67 @@ +3772\. Maximum Subgraph Score in a Tree + +Hard + +You are given an **undirected tree** with `n` nodes, numbered from 0 to `n - 1`. It is represented by a 2D integer array `edges` of length `n - 1`, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. + +You are also given an integer array `good` of length `n`, where `good[i]` is 1 if the ith node is good, and 0 if it is bad. + +Define the **score** of a **subgraph** as the number of good nodes minus the number of bad nodes in that subgraph. + +For each node `i`, find the **maximum** possible score among all **connected subgraphs** that contain node `i`. + +Return an array of `n` integers where the ith element is the **maximum** score for node `i`. + +A **subgraph** is a graph whose vertices and edges are subsets of the original graph. + +A **connected subgraph** is a subgraph in which every pair of its vertices is reachable from one another using only its edges. + +**Example 1:** + +![Tree Example 1](https://assets.leetcode.com/uploads/2025/11/17/tree1fixed.png) + +**Input:** n = 3, edges = [[0,1],[1,2]], good = [1,0,1] + +**Output:** [1,1,1] + +**Explanation:** + +* Green nodes are good and red nodes are bad. +* For each node, the best connected subgraph containing it is the whole tree, which has 2 good nodes and 1 bad node, resulting in a score of 1. +* Other connected subgraphs containing a node may have the same score. + +**Example 2:** + +![Tree Example 2](https://assets.leetcode.com/uploads/2025/11/17/tree2.png) + +**Input:** n = 5, edges = [[1,0],[1,2],[1,3],[3,4]], good = [0,1,0,1,1] + +**Output:** [2,3,2,3,3] + +**Explanation:** + +* Node 0: The best connected subgraph consists of nodes `0, 1, 3, 4`, which has 3 good nodes and 1 bad node, resulting in a score of `3 - 1 = 2`. +* Nodes 1, 3, and 4: The best connected subgraph consists of nodes `1, 3, 4`, which has 3 good nodes, resulting in a score of 3. +* Node 2: The best connected subgraph consists of nodes `1, 2, 3, 4`, which has 3 good nodes and 1 bad node, resulting in a score of `3 - 1 = 2`. + +**Example 3:** + +![Tree Example 3](https://assets.leetcode.com/uploads/2025/11/17/tree3.png) + +**Input:** n = 2, edges = [[0,1]], good = [0,0] + +**Output:** [-1,-1] + +**Explanation:** + +For each node, including the other node only adds another bad node, so the best score for both nodes is -1. + +**Constraints:** + +* 2 <= n <= 105 +* `edges.length == n - 1` +* edges[i] = [ai, bi] +* 0 <= ai, bi < n +* `good.length == n` +* `0 <= good[i] <= 1` +* The input is generated such that `edges` represents a valid tree. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/Solution.java b/src/main/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/Solution.java new file mode 100644 index 000000000..535995397 --- /dev/null +++ b/src/main/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/Solution.java @@ -0,0 +1,19 @@ +package g3701_3800.s3774_absolute_difference_between_maximum_and_minimum_k_elements; + +// #Easy #Array #Sorting #Mid_Level #Weekly_Contest_480 +// #2026_05_08_Time_5_ms_(96.82%)_Space_46.97_MB_(28.79%) + +import java.util.Arrays; + +public class Solution { + public int absDifference(int[] nums, int k) { + Arrays.sort(nums); + int maxSum = 0; + int minSum = 0; + for (int i = 0, j = nums.length - 1; i < k; i++, j--) { + minSum += nums[i]; + maxSum += nums[j]; + } + return maxSum - minSum; + } +} diff --git a/src/main/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/readme.md b/src/main/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/readme.md new file mode 100644 index 000000000..7cde9ee43 --- /dev/null +++ b/src/main/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/readme.md @@ -0,0 +1,42 @@ +3774\. Absolute Difference Between Maximum and Minimum K Elements + +Easy + +You are given an integer array `nums` and an integer `k`. + +Find the absolute difference between: + +* the **sum** of the `k` **largest** elements in the array; and +* the **sum** of the `k` **smallest** elements in the array. + +Return an integer denoting this difference. + +**Example 1:** + +**Input:** nums = [5,2,2,4], k = 2 + +**Output:** 5 + +**Explanation:** + +* The `k = 2` largest elements are 4 and 5. Their sum is `4 + 5 = 9`. +* The `k = 2` smallest elements are 2 and 2. Their sum is `2 + 2 = 4`. +* The absolute difference is `abs(9 - 4) = 5`. + +**Example 2:** + +**Input:** nums = [100], k = 1 + +**Output:** 0 + +**Explanation:** + +* The largest element is 100. +* The smallest element is 100. +* The absolute difference is `abs(100 - 100) = 0`. + +**Constraints:** + +* `1 <= n == nums.length <= 100` +* `1 <= nums[i] <= 100` +* `1 <= k <= n` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/Solution.java b/src/main/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/Solution.java new file mode 100644 index 000000000..d465f88cf --- /dev/null +++ b/src/main/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/Solution.java @@ -0,0 +1,40 @@ +package g3701_3800.s3775_reverse_words_with_same_vowel_count; + +// #Medium #String #Two_Pointers #Simulation #Senior #Weekly_Contest_480 +// #2026_05_08_Time_41_ms_(96.14%)_Space_48.30_MB_(90.84%) + +public class Solution { + public String reverseWords(String s) { + char[] wrd = s.toCharArray(); + String vowels = "aeiou"; + int left = 0; + int right = 0; + int firstWrd = 0; + int anotherWrd = 0; + while (left < wrd.length) { + right = left; + anotherWrd = 0; + while (right < wrd.length && wrd[right] != ' ') { + if (vowels.indexOf(wrd[right]) != -1) { + if (left == 0) { + firstWrd++; + } else { + anotherWrd++; + } + } + right++; + } + if (left != 0 && anotherWrd == firstWrd) { + int l = left; + int r = right - 1; + while (l < r) { + char temp = wrd[r]; + wrd[r--] = wrd[l]; + wrd[l++] = temp; + } + } + left = right + 1; + } + return new String(wrd); + } +} diff --git a/src/main/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/readme.md b/src/main/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/readme.md new file mode 100644 index 000000000..a62206e37 --- /dev/null +++ b/src/main/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/readme.md @@ -0,0 +1,56 @@ +3775\. Reverse Words With Same Vowel Count + +Medium + +You are given a string `s` consisting of lowercase English words, each separated by a single space. + +Determine how many vowels appear in the **first** word. Then, reverse each following word that has the **same vowel count**. Leave all remaining words unchanged. + +Return the resulting string. + +Vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`. + +**Example 1:** + +**Input:** s = "cat and mice" + +**Output:** "cat dna mice" + +**Explanation:** + +* The first word `"cat"` has 1 vowel. +* `"and"` has 1 vowel, so it is reversed to form `"dna"`. +* `"mice"` has 2 vowels, so it remains unchanged. +* Thus, the resulting string is `"cat dna mice"`. + +**Example 2:** + +**Input:** s = "book is nice" + +**Output:** "book is ecin" + +**Explanation:** + +* The first word `"book"` has 2 vowels. +* `"is"` has 1 vowel, so it remains unchanged. +* `"nice"` has 2 vowels, so it is reversed to form `"ecin"`. +* Thus, the resulting string is `"book is ecin"`. + +**Example 3:** + +**Input:** s = "banana healthy" + +**Output:** "banana healthy" + +**Explanation:** + +* The first word `"banana"` has 3 vowels. +* `"healthy"` has 2 vowels, so it remains unchanged. +* Thus, the resulting string is `"banana healthy"`. + +**Constraints:** + +* 1 <= s.length <= 105 +* `s` consists of lowercase English letters and spaces. +* Words in `s` are separated by a **single** space. +* `s` does **not** contain leading or trailing spaces. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/Solution.java b/src/main/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/Solution.java new file mode 100644 index 000000000..f0254745c --- /dev/null +++ b/src/main/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/Solution.java @@ -0,0 +1,31 @@ +package g3701_3800.s3776_minimum_moves_to_balance_circular_array; + +// #Medium #Array #Sorting #Greedy #Staff #Weekly_Contest_480 +// #2026_05_08_Time_2_ms_(100.00%)_Space_139.96_MB_(20.95%) + +public class Solution { + public long minMoves(int[] balance) { + int n = balance.length; + int j = -1; + long total = 0; + long res = 0; + for (int i = 0; i < n; i++) { + if (balance[i] < 0) { + j = i; + } + total += balance[i]; + } + if (j == -1) { + return 0; + } + if (total < 0) { + return -1; + } + for (int d = 1; balance[j] < 0; ++d) { + long storage = balance[(j + d) % n] + (long) balance[(j - d % n + n) % n]; + res += Math.min(-balance[j], (int) storage) * d; + balance[j] += (int) storage; + } + return res; + } +} diff --git a/src/main/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/readme.md b/src/main/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/readme.md new file mode 100644 index 000000000..585d2e057 --- /dev/null +++ b/src/main/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/readme.md @@ -0,0 +1,63 @@ +3776\. Minimum Moves to Balance Circular Array + +Medium + +You are given a **circular** array `balance` of length `n`, where `balance[i]` is the net balance of person `i`. + +In one move, a person can transfer **exactly** 1 unit of balance to either their left or right neighbor. + +Return the **minimum** number of moves required so that every person has a **non-negative** balance. If it is impossible, return `-1`. + +**Note**: You are guaranteed that **at most** 1 index has a **negative** balance initially. + +**Example 1:** + +**Input:** balance = [5,1,-4] + +**Output:** 4 + +**Explanation:** + +One optimal sequence of moves is: + +* Move 1 unit from `i = 1` to `i = 2`, resulting in `balance = [5, 0, -3]` +* Move 1 unit from `i = 0` to `i = 2`, resulting in `balance = [4, 0, -2]` +* Move 1 unit from `i = 0` to `i = 2`, resulting in `balance = [3, 0, -1]` +* Move 1 unit from `i = 0` to `i = 2`, resulting in `balance = [2, 0, 0]` + +Thus, the minimum number of moves required is 4. + +**Example 2:** + +**Input:** balance = [1,2,-5,2] + +**Output:** 6 + +**Explanation:** + +One optimal sequence of moves is: + +* Move 1 unit from `i = 1` to `i = 2`, resulting in `balance = [1, 1, -4, 2]` +* Move 1 unit from `i = 1` to `i = 2`, resulting in `balance = [1, 0, -3, 2]` +* Move 1 unit from `i = 3` to `i = 2`, resulting in `balance = [1, 0, -2, 1]` +* Move 1 unit from `i = 3` to `i = 2`, resulting in `balance = [1, 0, -1, 0]` +* Move 1 unit from `i = 0` to `i = 1`, resulting in `balance = [0, 1, -1, 0]` +* Move 1 unit from `i = 1` to `i = 2`, resulting in `balance = [0, 0, 0, 0]` + +Thus, the minimum number of moves required is 6. + +**Example 3:** + +**Input:** balance = [-3,2] + +**Output:** \-1 + +**Explanation:** + +It is impossible to make all balances non-negative for `balance = [-3, 2]`, so the answer is -1. + +**Constraints:** + +* 1 <= n == balance.length <= 105 +* -109 <= balance[i] <= 109 +* There is at most one negative value in `balance` initially. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/Solution.java b/src/main/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/Solution.java new file mode 100644 index 000000000..f09e8619d --- /dev/null +++ b/src/main/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/Solution.java @@ -0,0 +1,61 @@ +package g3701_3800.s3777_minimum_deletions_to_make_alternating_substring; + +// #Hard #String #Segment_Tree #Senior_Staff #Weekly_Contest_480 +// #2026_05_06_Time_35_ms_(100.00%)_Space_247.99_MB_(90.00%) + +import java.util.Arrays; + +public class Solution { + private int[] f; + private int n; + + private void add(int i, int v) { + for (i++; i <= n; i += i & -i) { + f[i] += v; + } + } + + private int sum(int i) { + int s = 0; + for (i++; i > 0; i -= i & -i) { + s += f[i]; + } + return s; + } + + public int[] minDeletions(String s, int[][] q) { + char[] a = s.toCharArray(); + n = a.length; + f = new int[n + 1]; + for (int i = 0; i + 1 < n; i++) { + if (a[i] == a[i + 1]) { + add(i, 1); + } + } + int[] ans = new int[q.length]; + int k = 0; + for (int[] e : q) { + if (e[0] == 1) { + int j = e[1]; + if (j > 0 && a[j] == a[j - 1]) { + add(j - 1, -1); + } + if (j + 1 < n && a[j] == a[j + 1]) { + add(j, -1); + } + a[j] = a[j] == 'A' ? 'B' : 'A'; + if (j > 0 && a[j] == a[j - 1]) { + add(j - 1, 1); + } + if (j + 1 < n && a[j] == a[j + 1]) { + add(j, 1); + } + } else { + int l = e[1]; + int r = e[2]; + ans[k++] = l < r ? sum(r - 1) - sum(l - 1) : 0; + } + } + return Arrays.copyOf(ans, k); + } +} diff --git a/src/main/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/readme.md b/src/main/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/readme.md new file mode 100644 index 000000000..d2790092d --- /dev/null +++ b/src/main/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/readme.md @@ -0,0 +1,73 @@ +3777\. Minimum Deletions to Make Alternating Substring + +Hard + +You are given a string `s` of length `n` consisting only of the characters `'A'` and `'B'`. + +You are also given a 2D integer array `queries` of length `q`, where each `queries[i]` is one of the following: + +* `[1, j]`: **Flip** the character at index `j` of `s` i.e. `'A'` changes to `'B'` (and vice versa). This operation mutates `s` and affects subsequent queries. +* `[2, l, r]`: **Compute** the **minimum** number of character deletions required to make the **substring** `s[l..r]` **alternating**. This operation does not modify `s`; the length of `s` remains `n`. + +A **substring** is **alternating** if no two **adjacent** characters are **equal**. A substring of length 1 is always alternating. + +Return an integer array `answer`, where `answer[i]` is the result of the ith query of type `[2, l, r]`. + +**Example 1:** + +**Input:** s = "ABA", queries = [[2,1,2],[1,1],[2,0,2]] + +**Output:** [0,2] + +**Explanation:** + +| i | queries[i] | j | l | r | s before query | s[l..r] | Result | Answer | +|---|------------|---|---|---|----------------|---------|--------|--------| +| 0 | [2, 1, 2] | - | 1 | 2 | `"ABA"` | `"BA"` | Already alternating | 0 | +| 1 | [1, 1] | 1 | - | - | `"ABA"` | - | Flip `s[1]` from `'B'` to `'A'` | - | +| 2 | [2, 0, 2] | - | 0 | 2 | `"AAA"` | `"AAA"` | Delete any two `'A'`s to get `"A"` | 2 | + +Thus, the answer is `[0, 2]`. + +**Example 2:** + +**Input:** s = "ABB", queries = [[2,0,2],[1,2],[2,0,2]] + +**Output:** [1,0] + +**Explanation:** + +| i | queries[i] | j | l | r | s before query | s[l..r] | Result | Answer | +|---|------------|---|---|---|----------------|---------|--------|--------| +| 0 | [2, 0, 2] | - | 0 | 2 | `"ABB"` | `"ABB"` | Delete one `'B'` to get `"AB"` | 1 | +| 1 | [1, 2] | 2 | - | - | `"ABB"` | - | Flip `s[2]` from `'B'` to `'A'` | - | +| 2 | [2, 0, 2] | - | 0 | 2 | `"ABA"` | `"ABA"` | Already alternating | 0 | + +Thus, the answer is `[1, 0]`. + +**Example 3:** + +**Input:** s = "BABA", queries = [[2,0,3],[1,1],[2,1,3]] + +**Output:** [0,1] + +**Explanation:** + +| i | queries[i] | j | l | r | s before query | s[l..r] | Result | Answer | +|---|------------|---|---|---|----------------|---------|--------|--------| +| 0 | [2, 0, 3] | - | 0 | 3 | `"BABA"` | `"BABA"`| Already alternating | 0 | +| 1 | [1, 1] | 1 | - | - | `"BABA"` | - | Flip `s[1]` from `'A'` to `'B'` | - | +| 2 | [2, 1, 3] | - | 1 | 3 | `"BBBA"` | `"BBA"` | Delete one `'B'` to get `"BA"` | 1 | + +Thus, the answer is `[0, 1]`. + +**Constraints:** + +* 1 <= n == s.length <= 105 +* `s[i]` is either `'A'` or `'B'`. +* 1 <= q == queries.length <= 105 +* `queries[i].length == 2` or `3` + * `queries[i] == [1, j]` or, + * `queries[i] == [2, l, r]` + * `0 <= j <= n - 1` + * `0 <= l <= r <= n - 1` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/Solution.java b/src/main/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/Solution.java new file mode 100644 index 000000000..424c409bf --- /dev/null +++ b/src/main/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/Solution.java @@ -0,0 +1,19 @@ +package g3701_3800.s3779_minimum_number_of_operations_to_have_distinct_elements; + +// #Medium #Array #Hash_Table #Senior #Biweekly_Contest_172 +// #2026_05_06_Time_4_ms_(99.25%)_Space_132.03_MB_(83.46%) + +public class Solution { + public int minOperations(int[] nums) { + boolean[] seen = new boolean[100001]; + int i = nums.length - 1; + while (i >= 0) { + if (seen[nums[i]]) { + break; + } + seen[nums[i]] = true; + i--; + } + return (i + 3) / 3; + } +} diff --git a/src/main/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/readme.md b/src/main/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/readme.md new file mode 100644 index 000000000..a53319d6d --- /dev/null +++ b/src/main/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/readme.md @@ -0,0 +1,46 @@ +3779\. Minimum Number of Operations to Have Distinct Elements + +Medium + +You are given an integer array `nums`. + +In one operation, you remove the **first three elements** of the current array. If there are fewer than three elements remaining, **all** remaining elements are removed. + +Repeat this operation until the array is empty or contains no duplicate values. + +Return an integer denoting the number of operations required. + +**Example 1:** + +**Input:** nums = [3,8,3,6,5,8] + +**Output:** 1 + +**Explanation:** + +In the first operation, we remove the first three elements. The remaining elements `[6, 5, 8]` are all distinct, so we stop. Only one operation is needed. + +**Example 2:** + +**Input:** nums = [2,2] + +**Output:** 1 + +**Explanation:** + +After one operation, the array becomes empty, which meets the stopping condition. + +**Example 3:** + +**Input:** nums = [4,3,5,1,2] + +**Output:** 0 + +**Explanation:** + +All elements in the array are distinct, therefore no operations are needed. + +**Constraints:** + +* 1 <= nums.length <= 105 +* 1 <= nums[i] <= 105 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/Solution.java b/src/main/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/Solution.java new file mode 100644 index 000000000..44c78a026 --- /dev/null +++ b/src/main/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/Solution.java @@ -0,0 +1,51 @@ +package g3701_3800.s3780_maximum_sum_of_three_numbers_divisible_by_three; + +// #Medium #Array #Sorting #Greedy #Heap_Priority_Queue #Senior #Biweekly_Contest_172 +// #2026_05_06_Time_7_ms_(98.17%)_Space_168.14_MB_(89.91%) + +public class Solution { + public int maximumSum(int[] nums) { + int[][] group = new int[3][3]; + for (int num : nums) { + int m = num % 3; + int max1 = group[m][0]; + int max2 = group[m][1]; + int max3 = group[m][2]; + if (num >= max1) { + max3 = max2; + max2 = max1; + max1 = num; + } else if (num >= max2) { + max3 = max2; + max2 = num; + } else if (num > max3) { + max3 = num; + } + group[m][0] = max1; + group[m][1] = max2; + group[m][2] = max3; + } + int res = 0; + for (int[] g : group) { + int sum = 0; + for (int i = 0; i < 3; i += 1) { + if (g[i] == 0) { + sum = 0; + break; + } + sum += g[i]; + } + res = Math.max(res, sum); + } + int max = 0; + for (int[] g : group) { + if (g[0] == 0) { + max = 0; + break; + } + max += g[0]; + } + res = Math.max(res, max); + return res; + } +} diff --git a/src/main/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/readme.md b/src/main/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/readme.md new file mode 100644 index 000000000..fce6203bd --- /dev/null +++ b/src/main/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/readme.md @@ -0,0 +1,39 @@ +3780\. Maximum Sum of Three Numbers Divisible by Three + +Medium + +You are given an integer array `nums`. + +Your task is to choose **exactly three** integers from `nums` such that their sum is divisible by three. + +Return the **maximum** possible sum of such a triplet. If no such triplet exists, return 0. + +**Example 1:** + +**Input:** nums = [4,2,3,1] + +**Output:** 9 + +**Explanation:** + +The valid triplets whose sum is divisible by 3 are: + +* `(4, 2, 3)` with a sum of `4 + 2 + 3 = 9`. +* `(2, 3, 1)` with a sum of `2 + 3 + 1 = 6`. + +Thus, the answer is 9. + +**Example 2:** + +**Input:** nums = [2,1,5] + +**Output:** 0 + +**Explanation:** + +No triplet forms a sum divisible by 3, so the answer is 0. + +**Constraints:** + +* 3 <= nums.length <= 105 +* 1 <= nums[i] <= 105 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3781_maximum_score_after_binary_swaps/Solution.java b/src/main/java/g3701_3800/s3781_maximum_score_after_binary_swaps/Solution.java new file mode 100644 index 000000000..5029d3fec --- /dev/null +++ b/src/main/java/g3701_3800/s3781_maximum_score_after_binary_swaps/Solution.java @@ -0,0 +1,26 @@ +package g3701_3800.s3781_maximum_score_after_binary_swaps; + +// #Medium #Array #String #Greedy #Heap_Priority_Queue #Staff #Biweekly_Contest_172 +// #2026_05_06_Time_39_ms_(96.47%)_Space_118.00_MB_(29.41%) + +import java.util.PriorityQueue; + +public class Solution { + public long maximumScore(int[] nums, String s) { + long sum = 0; + PriorityQueue pq = new PriorityQueue<>((a, b) -> b - a); + for (int i = 0; i < nums.length; i++) { + if (s.charAt(i) == '1') { + if (pq.isEmpty() || pq.peek() <= nums[i]) { + sum += nums[i]; + } else { + sum += pq.poll(); + pq.add(nums[i]); + } + } else { + pq.add(nums[i]); + } + } + return sum; + } +} diff --git a/src/main/java/g3701_3800/s3781_maximum_score_after_binary_swaps/readme.md b/src/main/java/g3701_3800/s3781_maximum_score_after_binary_swaps/readme.md new file mode 100644 index 000000000..af9c40b40 --- /dev/null +++ b/src/main/java/g3701_3800/s3781_maximum_score_after_binary_swaps/readme.md @@ -0,0 +1,43 @@ +3781\. Maximum Score After Binary Swaps + +Medium + +You are given an integer array `nums` of length `n` and a binary string `s` of the same length. + +Initially, your score is 0. Each index `i` where `s[i] = '1'` contributes `nums[i]` to the score. + +You may perform **any** number of operations (including zero). In one operation, you may choose an index `i` such that `0 <= i < n - 1`, where `s[i] = '0'`, and `s[i + 1] = '1'`, and swap these two characters. + +Return an integer denoting the **maximum possible score** you can achieve. + +**Example 1:** + +**Input:** nums = [2,1,5,2,3], s = "01010" + +**Output:** 7 + +**Explanation:** + +We can perform the following swaps: + +* Swap at index `i = 0`: `"01010"` changes to `"10010"` +* Swap at index `i = 2`: `"10010"` changes to `"10100"` + +Positions 0 and 2 contain `'1'`, contributing `nums[0] + nums[2] = 2 + 5 = 7`. This is maximum score achievable. + +**Example 2:** + +**Input:** nums = [4,7,2,9], s = "0000" + +**Output:** 0 + +**Explanation:** + +There are no `'1'` characters in `s`, so no swaps can be performed. The score remains 0. + +**Constraints:** + +* `n == nums.length == s.length` +* 1 <= n <= 105 +* 1 <= nums[i] <= 109 +* `s[i]` is either `'0'` or `'1'` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/Solution.java b/src/main/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/Solution.java new file mode 100644 index 000000000..7da4eac23 --- /dev/null +++ b/src/main/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/Solution.java @@ -0,0 +1,11 @@ +package g3701_3800.s3782_last_remaining_integer_after_alternating_deletion_operations; + +// #Hard #Math #Recursion #Senior_Staff #Biweekly_Contest_172 +// #2026_05_06_Time_1_ms_(100.00%)_Space_43.05_MB_(9.38%) + +public class Solution { + public long lastInteger(long n) { + final long mask = 0xAAAAAAAAAAAAAAAL; + return ((n - 1) & mask) + 1; + } +} diff --git a/src/main/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/readme.md b/src/main/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/readme.md new file mode 100644 index 000000000..7278cda22 --- /dev/null +++ b/src/main/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/readme.md @@ -0,0 +1,53 @@ +3782\. Last Remaining Integer After Alternating Deletion Operations + +Hard + +You are given an integer `n`. + +We write the integers from 1 to `n` in a sequence from left to right. Then, **alternately** apply the following two operations until only one integer remains, starting with operation 1: + +* **Operation 1**: Starting from the left, delete every second number. +* **Operation 2**: Starting from the right, delete every second number. + +Return the last remaining integer. + +**Example 1:** + +**Input:** n = 8 + +**Output:** 3 + +**Explanation:** + +* Write `[1, 2, 3, 4, 5, 6, 7, 8]` in a sequence. +* Starting from the left, we delete every second number: [1, **2**, 3, **4**, 5, **6**, 7, **8**]. The remaining integers are `[1, 3, 5, 7]`. +* Starting from the right, we delete every second number: [**1**, 3, **5**, 7]. The remaining integers are `[3, 7]`. +* Starting from the left, we delete every second number: [3, **7**]. The remaining integer is `[3]`. + +**Example 2:** + +**Input:** n = 5 + +**Output:** 1 + +**Explanation:** + +* Write `[1, 2, 3, 4, 5]` in a sequence. +* Starting from the left, we delete every second number: [1, **2**, 3, **4**, 5]. The remaining integers are `[1, 3, 5]`. +* Starting from the right, we delete every second number: [1, **3**, 5]. The remaining integers are `[1, 5]`. +* Starting from the left, we delete every second number: [1, **5**]. The remaining integer is `[1]`. + +**Example 3:** + +**Input:** n = 1 + +**Output:** 1 + +**Explanation:** + +* Write `[1]` in a sequence. +* The last remaining integer is 1. + +**Constraints:** + +* 1 <= n <= 1015 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3783_mirror_distance_of_an_integer/Solution.java b/src/main/java/g3701_3800/s3783_mirror_distance_of_an_integer/Solution.java new file mode 100644 index 000000000..8707b773f --- /dev/null +++ b/src/main/java/g3701_3800/s3783_mirror_distance_of_an_integer/Solution.java @@ -0,0 +1,19 @@ +package g3701_3800.s3783_mirror_distance_of_an_integer; + +// #Easy #Math #Mid_Level #Weekly_Contest_481 #2026_05_22_Time_1_ms_(99.88%)_Space_42.74_MB_(18.96%) + +public class Solution { + private int rev(int n) { + int a = 0; + while (n > 0) { + a = a * 10 + (n % 10); + n /= 10; + } + return a; + } + + public int mirrorDistance(int n) { + int m = rev(n); + return Math.abs(m - n); + } +} diff --git a/src/main/java/g3701_3800/s3783_mirror_distance_of_an_integer/readme.md b/src/main/java/g3701_3800/s3783_mirror_distance_of_an_integer/readme.md new file mode 100644 index 000000000..72f2e1bf9 --- /dev/null +++ b/src/main/java/g3701_3800/s3783_mirror_distance_of_an_integer/readme.md @@ -0,0 +1,48 @@ +3783\. Mirror Distance of an Integer + +Easy + +You are given an integer `n`. + +Define its **mirror distance** as: `abs(n - reverse(n))` where `reverse(n)` is the integer formed by reversing the digits of `n`. + +Return an integer denoting the mirror distance of `n`. + +`abs(x)` denotes the absolute value of `x`. + +**Example 1:** + +**Input:** n = 25 + +**Output:** 27 + +**Explanation:** + +* `reverse(25) = 52`. +* Thus, the answer is `abs(25 - 52) = 27`. + +**Example 2:** + +**Input:** n = 10 + +**Output:** 9 + +**Explanation:** + +* `reverse(10) = 01` which is 1. +* Thus, the answer is `abs(10 - 1) = 9`. + +**Example 3:** + +**Input:** n = 7 + +**Output:** 0 + +**Explanation:** + +* `reverse(7) = 7`. +* Thus, the answer is `abs(7 - 7) = 0`. + +**Constraints:** + +* 1 <= n <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/Solution.java b/src/main/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/Solution.java new file mode 100644 index 000000000..f1affc006 --- /dev/null +++ b/src/main/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/Solution.java @@ -0,0 +1,22 @@ +package g3701_3800.s3784_minimum_deletion_cost_to_make_all_characters_equal; + +// #Medium #Array #String #Hash_Table #Enumeration #Senior #Weekly_Contest_481 +// #2026_05_22_Time_3_ms_(94.77%)_Space_104.58_MB_(97.09%) + +public class Solution { + public long minCost(String s, int[] cost) { + long[] arr = new long[26]; + long m = Integer.MIN_VALUE; + long sum = 0; + for (int i = 0; i < s.length(); i++) { + arr[s.charAt(i) - 'a'] += cost[i]; + } + for (long i : arr) { + if (i > m) { + m = i; + } + sum += i; + } + return sum - m; + } +} diff --git a/src/main/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/readme.md b/src/main/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/readme.md new file mode 100644 index 000000000..a40c95528 --- /dev/null +++ b/src/main/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/readme.md @@ -0,0 +1,46 @@ +3784\. Minimum Deletion Cost to Make All Characters Equal + +Medium + +You are given a string `s` of length `n` and an integer array `cost` of the same length, where `cost[i]` is the cost to **delete** the ith character of `s`. + +You may delete any number of characters from `s` (possibly none), such that the resulting string is **non-empty** and consists of **equal** characters. + +Return an integer denoting the **minimum** total deletion cost required. + +**Example 1:** + +**Input:** s = "aabaac", cost = [1,2,3,4,1,10] + +**Output:** 11 + +**Explanation:** + +Deleting the characters at indices 0, 1, 2, 3, 4 results in the string `"c"`, which consists of equal characters, and the total cost is `cost[0] + cost[1] + cost[2] + cost[3] + cost[4] = 1 + 2 + 3 + 4 + 1 = 11`. + +**Example 2:** + +**Input:** s = "abc", cost = [10,5,8] + +**Output:** 13 + +**Explanation:** + +Deleting the characters at indices 1 and 2 results in the string `"a"`, which consists of equal characters, and the total cost is `cost[1] + cost[2] = 5 + 8 = 13`. + +**Example 3:** + +**Input:** s = "zzzzz", cost = [67,67,67,67,67] + +**Output:** 0 + +**Explanation:** + +All characters in `s` are equal, so the deletion cost is 0. + +**Constraints:** + +* `n == s.length == cost.length` +* 1 <= n <= 105 +* 1 <= cost[i] <= 109 +* `s` consists of lowercase English letters. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/Solution.java b/src/main/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/Solution.java new file mode 100644 index 000000000..2dbf8ed20 --- /dev/null +++ b/src/main/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/Solution.java @@ -0,0 +1,41 @@ +package g3701_3800.s3785_minimum_swaps_to_avoid_forbidden_values; + +// #Hard #Array #Hash_Table #Greedy #Counting #Senior_Staff #Weekly_Contest_481 +// #2026_05_22_Time_88_ms_(86.89%)_Space_159.68_MB_(81.97%) + +import java.util.HashMap; +import java.util.Map; + +public class Solution { + public int minSwaps(int[] nums, int[] forbidden) { + int n = nums.length; + Map map = new HashMap<>(); + for (int num : nums) { + map.put(num, map.getOrDefault(num, 0) + 1); + } + for (int num : forbidden) { + map.put(num, map.getOrDefault(num, 0) + 1); + } + for (int val : map.values()) { + if (val > n) { + return -1; + } + } + Map map2 = new HashMap<>(); + int total = 0; + for (int i = 0; i < n; i++) { + if (nums[i] == forbidden[i]) { + map2.put(nums[i], map2.getOrDefault(nums[i], 0) + 1); + total++; + } + } + if (total == 0) { + return 0; + } + int maxSwaps = 0; + for (int num : map2.values()) { + maxSwaps = Math.max(maxSwaps, num); + } + return Math.max(maxSwaps, (total + 1) / 2); + } +} diff --git a/src/main/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/readme.md b/src/main/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/readme.md new file mode 100644 index 000000000..1d51949cc --- /dev/null +++ b/src/main/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/readme.md @@ -0,0 +1,63 @@ +3785\. Minimum Swaps to Avoid Forbidden Values + +Hard + +You are given two integer arrays, `nums` and `forbidden`, each of length `n`. + +You may perform the following operation any number of times (including zero): + +* Choose two **distinct** indices `i` and `j`, and swap `nums[i]` with `nums[j]`. + +Return the **minimum** number of swaps required such that, for every index `i`, the value of `nums[i]` is **not equal** to `forbidden[i]`. If no amount of swaps can ensure that every index avoids its forbidden value, return -1. + +**Example 1:** + +**Input:** nums = [1,2,3], forbidden = [3,2,1] + +**Output:** 1 + +**Explanation:** + +One optimal set of swaps: + +* Select indices `i = 0` and `j = 1` in `nums` and swap them, resulting in `nums = [2, 1, 3]`. +* After this swap, for every index `i`, `nums[i]` is not equal to `forbidden[i]`. + +**Example 2:** + +**Input:** nums = [4,6,6,5], forbidden = [4,6,5,5] + +**Output:** 2 + +**Explanation:** + +One optimal set of swaps: + +* Select indices `i = 0` and `j = 2` in `nums` and swap them, resulting in `nums = [6, 6, 4, 5]`. +* Select indices `i = 1` and `j = 3` in `nums` and swap them, resulting in `nums = [6, 5, 4, 6]`. +* After these swaps, for every index `i`, `nums[i]` is not equal to `forbidden[i]`. + +**Example 3:** + +**Input:** nums = [7,7], forbidden = [8,7] + +**Output:** \-1 + +**Explanation:** + +It is not possible to make `nums[i]` different from `forbidden[i]` for all indices. + +**Example 4:** + +**Input:** nums = [1,2], forbidden = [2,1] + +**Output:** 0 + +**Explanation:** + +No swaps are required because `nums[i]` is already different from `forbidden[i]` for all indices, so the answer is 0. + +**Constraints:** + +* 1 <= n == nums.length == forbidden.length <= 105 +* 1 <= nums[i], forbidden[i] <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/Solution.java b/src/main/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/Solution.java new file mode 100644 index 000000000..19a5f634a --- /dev/null +++ b/src/main/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/Solution.java @@ -0,0 +1,51 @@ +package g3701_3800.s3786_total_sum_of_interaction_cost_in_tree_groups; + +// #Hard #Array #Tree #Senior_Staff #Weekly_Contest_481 #Depth_First_Search +// #2026_05_22_Time_82_ms_(90.67%)_Space_296.78_MB_(21.33%) + +import java.util.ArrayList; +import java.util.List; + +public class Solution { + private long totalCost = 0; + private int[][] counts; + private int[] totalInGroup; + private List> adj; + + public long interactionCosts(int n, int[][] edges, int[] group) { + adj = new ArrayList<>(); + for (int i = 0; i < n; i++) { + adj.add(new ArrayList<>()); + } + for (int[] edge : edges) { + adj.get(edge[0]).add(edge[1]); + adj.get(edge[1]).add(edge[0]); + } + totalInGroup = new int[21]; + for (int g : group) { + totalInGroup[g]++; + } + counts = new int[n][21]; + dfs(0, -1, group); + return totalCost; + } + + private void dfs(int u, int p, int[] group) { + counts[u][group[u]] = 1; + for (int v : adj.get(u)) { + if (v == p) { + continue; + } + dfs(v, u, group); + for (int g = 1; g <= 20; g++) { + if (totalInGroup[g] < 2) { + continue; + } + long inSubtree = counts[v][g]; + long outsideSubtree = totalInGroup[g] - inSubtree; + totalCost += inSubtree * outsideSubtree; + counts[u][g] += counts[v][g]; + } + } + } +} diff --git a/src/main/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/readme.md b/src/main/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/readme.md new file mode 100644 index 000000000..e4f28b2ab --- /dev/null +++ b/src/main/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/readme.md @@ -0,0 +1,78 @@ +3786\. Total Sum of Interaction Cost in Tree Groups + +Hard + +You are given an integer `n` and an undirected tree with `n` nodes numbered from 0 to `n - 1`. This is represented by a 2D array `edges` of length `n - 1`, where edges[i] = [ui, vi] indicates an undirected edge between nodes ui and vi. + +You are also given an integer array `group` of length `n`, where `group[i]` denotes the group label assigned to node `i`. + +* Two nodes `u` and `v` are considered part of the same group if `group[u] == group[v]`. +* The **interaction cost** between `u` and `v` is defined as the number of edges on the unique path connecting them in the tree. + +Return an integer denoting the **sum** of interaction costs over all **unordered** pairs `(u, v)` with `u != v` such that `group[u] == group[v]`. + +**Example 1:** + +**Input:** n = 3, edges = [[0,1],[1,2]], group = [1,1,1] + +**Output:** 4 + +**Explanation:** + +**![](https://assets.leetcode.com/uploads/2025/09/24/screenshot-2025-09-24-at-50538-pm.png)** + +All nodes belong to group 1. The interaction costs between the pairs of nodes are: + +* Nodes `(0, 1)`: 1 +* Nodes `(1, 2)`: 1 +* Nodes `(0, 2)`: 2 + +Thus, the total interaction cost is `1 + 1 + 2 = 4`. + +**Example 2:** + +**Input:** n = 3, edges = [[0,1],[1,2]], group = [3,2,3] + +**Output:** 2 + +**Explanation:** + +* Nodes 0 and 2 belong to group 3. The interaction cost between this pair is 2. +* Node 1 belongs to a different group and forms no valid pair. Therefore, the total interaction cost is 2. + +**Example 3:** + +**Input:** n = 4, edges = [[0,1],[0,2],[0,3]], group = [1,1,4,4] + +**Output:** 3 + +**Explanation:** + +![](https://assets.leetcode.com/uploads/2025/09/24/screenshot-2025-09-24-at-51312-pm.png) + +Nodes belonging to the same groups and their interaction costs are: + +* Group 1: Nodes `(0, 1)`: 1 +* Group 4: Nodes `(2, 3)`: 2 + +Thus, the total interaction cost is `1 + 2 = 3`. + +**Example 4:** + +**Input:** n = 2, edges = [[0,1]], group = [9,8] + +**Output:** 0 + +**Explanation:** + +All nodes belong to different groups and there are no valid pairs. Therefore, the total interaction cost is 0. + +**Constraints:** + +* 1 <= n <= 105 +* `edges.length == n - 1` +* edges[i] = [ui, vi] +* 0 <= ui, vi <= n - 1 +* `group.length == n` +* `1 <= group[i] <= 20` +* The input is generated such that `edges` represents a valid tree. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3788_maximum_score_of_a_split/Solution.java b/src/main/java/g3701_3800/s3788_maximum_score_of_a_split/Solution.java new file mode 100644 index 000000000..76fccd3f6 --- /dev/null +++ b/src/main/java/g3701_3800/s3788_maximum_score_of_a_split/Solution.java @@ -0,0 +1,22 @@ +package g3701_3800.s3788_maximum_score_of_a_split; + +// #Medium #Array #Prefix_Sum #Senior #Weekly_Contest_482 +// #2026_05_22_Time_2_ms_(100.00%)_Space_113.41_MB_(96.82%) + +public class Solution { + public long maximumScore(int[] nums) { + long ans = nums[0] - (long) nums[1]; + long prefixSum = 0; + int n = nums.length; + int min = nums[n - 1]; + for (int i = 0; i < n - 1; i++) { + prefixSum += nums[i]; + } + for (int i = n - 2; i >= 0; i--) { + ans = Math.max(ans, prefixSum - min); + min = Math.min(min, nums[i]); + prefixSum -= nums[i]; + } + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3788_maximum_score_of_a_split/readme.md b/src/main/java/g3701_3800/s3788_maximum_score_of_a_split/readme.md new file mode 100644 index 000000000..4b142a2e2 --- /dev/null +++ b/src/main/java/g3701_3800/s3788_maximum_score_of_a_split/readme.md @@ -0,0 +1,53 @@ +3788\. Maximum Score of a Split + +Medium + +You are given an integer array `nums` of length `n`. + +Choose an index `i` such that `0 <= i < n - 1`. + +For a chosen split index `i`: + +* Let `prefixSum(i)` be the sum of `nums[0] + nums[1] + ... + nums[i]`. +* Let `suffixMin(i)` be the minimum value among `nums[i + 1], nums[i + 2], ..., nums[n - 1]`. + +The **score** of a split at index `i` is defined as: + +`score(i) = prefixSum(i) - suffixMin(i)` + +Return an integer denoting the **maximum** score over all valid split indices. + +**Example 1:** + +**Input:** nums = [10,-1,3,-4,-5] + +**Output:** 17 + +**Explanation:** + +The optimal split is at `i = 2`, `score(2) = prefixSum(2) - suffixMin(2) = (10 + (-1) + 3) - (-5) = 17`. + +**Example 2:** + +**Input:** nums = [-7,-5,3] + +**Output:** \-2 + +**Explanation:** + +The optimal split is at `i = 0`, `score(0) = prefixSum(0) - suffixMin(0) = (-7) - (-5) = -2`. + +**Example 3:** + +**Input:** nums = [1,1] + +**Output:** 0 + +**Explanation:** + +The only valid split is at `i = 0`, `score(0) = prefixSum(0) - suffixMin(0) = 1 - 1 = 0`. + +**Constraints:** + +* 2 <= nums.length <= 105 +* -109 <= nums[i] <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/Solution.java b/src/main/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/Solution.java new file mode 100644 index 000000000..cee0972e2 --- /dev/null +++ b/src/main/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/Solution.java @@ -0,0 +1,18 @@ +package g3701_3800.s3789_minimum_cost_to_acquire_required_items; + +// #Medium #Math #Greedy #Staff #Weekly_Contest_482 +// #2026_05_22_Time_1_ms_(100.00%)_Space_42.78_MB_(58.24%) + +public class Solution { + public long minimumCost(int cost1, int cost2, int costBoth, int need1, int need2) { + long min; + long max; + long ans; + min = Math.min(need1, need2); + max = Math.max(need1, need2); + ans = (long) need1 * cost1 + (long) need2 * cost2; + ans = Math.min(ans, min * costBoth + (need1 - min) * cost1 + (need2 - min) * cost2); + ans = Math.min(ans, max * costBoth); + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/readme.md b/src/main/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/readme.md new file mode 100644 index 000000000..da4152326 --- /dev/null +++ b/src/main/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/readme.md @@ -0,0 +1,52 @@ +3789\. Minimum Cost to Acquire Required Items + +Medium + +You are given five integers `cost1`, `cost2`, `costBoth`, `need1`, and `need2`. + +There are three types of items available: + +* An item of **type 1** costs `cost1` and contributes 1 unit to the type 1 requirement only. +* An item of **type 2** costs `cost2` and contributes 1 unit to the type 2 requirement only. +* An item of **type 3** costs `costBoth` and contributes 1 unit to **both** type 1 and type 2 requirements. + +You must collect enough items so that the total contribution toward type 1 is **at least** `need1` and the total contribution toward type 2 is **at least** `need2`. + +Return an integer representing the **minimum** possible total cost to achieve these requirements. + +**Example 1:** + +**Input:** cost1 = 3, cost2 = 2, costBoth = 1, need1 = 3, need2 = 2 + +**Output:** 3 + +**Explanation:** + +After buying three type 3 items, which cost `3 * 1 = 3`, the total contribution to type 1 is 3 (`>= need1 = 3`) and to type 2 is 3 (`>= need2 = 2`). +Any other valid combination would cost more, so the minimum total cost is 3. + +**Example 2:** + +**Input:** cost1 = 5, cost2 = 4, costBoth = 15, need1 = 2, need2 = 3 + +**Output:** 22 + +**Explanation:** + +We buy `need1 = 2` items of type 1 and `need2 = 3` items of type 2: `2 * 5 + 3 * 4 = 10 + 12 = 22`. +Any other valid combination would cost more, so the minimum total cost is 22. + +**Example 3:** + +**Input:** cost1 = 5, cost2 = 4, costBoth = 15, need1 = 0, need2 = 0 + +**Output:** 0 + +**Explanation:** + +Since no items are required (`need1 = need2 = 0`), we buy nothing and pay 0. + +**Constraints:** + +* 1 <= cost1, cost2, costBoth <= 106 +* 0 <= need1, need2 <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3790_smallest_all_ones_multiple/Solution.java b/src/main/java/g3701_3800/s3790_smallest_all_ones_multiple/Solution.java new file mode 100644 index 000000000..a41c46eb8 --- /dev/null +++ b/src/main/java/g3701_3800/s3790_smallest_all_ones_multiple/Solution.java @@ -0,0 +1,20 @@ +package g3701_3800.s3790_smallest_all_ones_multiple; + +// #Medium #Hash_Table #Math #Staff #Weekly_Contest_482 +// #2026_05_22_Time_8_ms_(100.00%)_Space_42.48_MB_(81.03%) + +public class Solution { + public int minAllOneMultiple(int k) { + if (k % 2 == 0 || k % 5 == 0) { + return -1; + } + int rem = 0; + for (int i = 1; i <= k; i++) { + rem = (rem * 10 + 1) % k; + if (rem == 0) { + return i; + } + } + return -1; + } +} diff --git a/src/main/java/g3701_3800/s3790_smallest_all_ones_multiple/readme.md b/src/main/java/g3701_3800/s3790_smallest_all_ones_multiple/readme.md new file mode 100644 index 000000000..820508e36 --- /dev/null +++ b/src/main/java/g3701_3800/s3790_smallest_all_ones_multiple/readme.md @@ -0,0 +1,43 @@ +3790\. Smallest All-Ones Multiple + +Medium + +You are given a positive integer `k`. + +Find the **smallest** integer `n` divisible by `k` that consists of **only the digit 1** in its decimal representation (e.g., 1, 11, 111, ...). + +Return an integer denoting the **number of digits** in the decimal representation of `n`. If no such `n` exists, return `-1`. + +**Example 1:** + +**Input:** k = 3 + +**Output:** 3 + +**Explanation:** + +`n = 111` because 111 is divisible by 3, but 1 and 11 are not. The length of `n = 111` is 3. + +**Example 2:** + +**Input:** k = 7 + +**Output:** 6 + +**Explanation:** + +`n = 111111`. The length of `n = 111111` is 6. + +**Example 3:** + +**Input:** k = 2 + +**Output:** \-1 + +**Explanation:** + +There does not exist a valid `n` that is a multiple of 2. + +**Constraints:** + +* 2 <= k <= 105 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/Solution.java b/src/main/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/Solution.java new file mode 100644 index 000000000..e2fd758e4 --- /dev/null +++ b/src/main/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/Solution.java @@ -0,0 +1,49 @@ +package g3701_3800.s3791_number_of_balanced_integers_in_a_range; + +// #Hard #Dynamic_Programming #Principal #Weekly_Contest_482 +// #2026_05_22_Time_75_ms_(83.12%)_Space_46.63_MB_(70.13%) + +import java.util.Arrays; + +public class Solution { + private long solve(String number, int idx, int diff, int tight, long[][][] dp) { + if (idx == number.length()) { + return diff == 0 ? 1 : 0; + } + if (dp[idx][diff + dp[0].length / 2][tight] != -1) { + return dp[idx][diff + dp[0].length / 2][tight]; + } + long ans = 0; + int ub = tight == 1 ? number.charAt(idx) - '0' : 9; + for (int i = 0; i <= ub; i++) { + int newTight = (tight == 1 && i == ub) ? 1 : 0; + if (idx % 2 == 0) { + ans += solve(number, idx + 1, diff - i, newTight, dp); + } else { + ans += solve(number, idx + 1, diff + i, newTight, dp); + } + } + dp[idx][diff + dp[0].length / 2][tight] = ans; + return dp[idx][diff + dp[0].length / 2][tight]; + } + + private long solve(long num) { + if (num == 0) { + return 1; + } + String number = Long.toString(num); + int len = number.length(); + long[][][] dp = + len % 2 == 1 ? new long[len][(len + 1) * 9 + 1][2] : new long[len][len * 9 + 1][2]; + for (long[][] tbl : dp) { + for (long[] row : tbl) { + Arrays.fill(row, -1); + } + } + return solve(number, 0, 0, 1, dp); + } + + public long countBalanced(long low, long high) { + return solve(high) - solve(low - 1); + } +} diff --git a/src/main/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/readme.md b/src/main/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/readme.md new file mode 100644 index 000000000..1ec67fa8e --- /dev/null +++ b/src/main/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/readme.md @@ -0,0 +1,46 @@ +3791\. Number of Balanced Integers in a Range + +Hard + +You are given two integers `low` and `high`. + +An integer is called **balanced** if it satisfies **both** of the following conditions: + +* It contains **at least** two digits. +* The **sum of digits at even positions** is equal to the **sum of digits at odd positions** (the leftmost digit has position 1). + +Return an integer representing the number of balanced integers in the range `[low, high]` (both inclusive). + +**Example 1:** + +**Input:** low = 1, high = 100 + +**Output:** 9 + +**Explanation:** + +The 9 balanced numbers between 1 and 100 are 11, 22, 33, 44, 55, 66, 77, 88, and 99. + +**Example 2:** + +**Input:** low = 120, high = 129 + +**Output:** 1 + +**Explanation:** + +Only 121 is balanced because the sum of digits at even and odd positions are both 2. + +**Example 3:** + +**Input:** low = 1234, high = 1234 + +**Output:** 0 + +**Explanation:** + +1234 is not balanced because the sum of digits at odd positions `(1 + 3 = 4)` does not equal the sum at even positions `(2 + 4 = 6)`. + +**Constraints:** + +* 1 <= low <= high <= 1015 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3793_find_users_with_high_token_usage/readme.md b/src/main/java/g3701_3800/s3793_find_users_with_high_token_usage/readme.md new file mode 100644 index 000000000..87b54026a --- /dev/null +++ b/src/main/java/g3701_3800/s3793_find_users_with_high_token_usage/readme.md @@ -0,0 +1,76 @@ +3793\. Find Users with High Token Usage + +Easy + +Table: prompts + + +-------------+---------+ + | Column Name | Type | + +-------------+---------+ + | user_id | int | + | prompt | varchar | + | tokens | int | + +-------------+---------+ + +(user_id, prompt) is the primary key (unique value) for this table. +Each row represents a prompt submitted by a user to an AI system along with the number of tokens consumed. + +Write a solution to analyze AI prompt usage patterns based on the following requirements: + +* For each user, calculate the total number of prompts they have submitted. +* For each user, calculate the average tokens used per prompt (Rounded to 2 decimal places). +* Only include users who have submitted at least 3 prompts. +* Only include users who have submitted at least one prompt with tokens greater than their own average token usage. + +Return the result table ordered by average tokens in descending order, and then by user_id in ascending order. + +The result format is in the following example. + +Example: + +Input: + +prompts table: + + +---------+--------------------------+--------+ + | user_id | prompt | tokens | + +---------+--------------------------+--------+ + | 1 | Write a blog outline | 120 | + | 1 | Generate SQL query | 80 | + | 1 | Summarize an article | 200 | + | 2 | Create resume bullet | 60 | + | 2 | Improve LinkedIn bio | 70 | + | 3 | Explain neural networks | 300 | + | 3 | Generate interview Q&A | 250 | + | 3 | Write cover letter | 180 | + | 3 | Optimize Python code | 220 | + +---------+--------------------------+--------+ + +Output: + + +---------+--------------+------------+ + | user_id | prompt_count | avg_tokens | + +---------+--------------+------------+ + | 3 | 4 | 237.50 | + | 1 | 3 | 133.33 | + +---------+--------------+------------+ + +Explanation: + +* User 1: + * Total prompts = 3 + * Average tokens = (120 + 80 + 200) / 3 = 133.33 + * Has a prompt with 200 tokens, which is greater than the average + * Included in the result + +* User 2: + * Total prompts = 2 (less than the required minimum) + * Excluded from the result + +* User 3: + * Total prompts = 4 + * Average tokens = (300 + 250 + 180 + 220) / 4 = 237.50 + * Has prompts with 300 and 250 tokens, both greater than the average + * Included in the result + +The result table is ordered by avg_tokens in descending order, then by user_id in ascending order. diff --git a/src/main/java/g3701_3800/s3793_find_users_with_high_token_usage/script.sql b/src/main/java/g3701_3800/s3793_find_users_with_high_token_usage/script.sql new file mode 100644 index 000000000..5ec8d02e9 --- /dev/null +++ b/src/main/java/g3701_3800/s3793_find_users_with_high_token_usage/script.sql @@ -0,0 +1,7 @@ +# Write your MySQL query statement below +# #Easy #2026_05_22_Time_286_ms_(70.33%)_Space_0.0_MB_(100.00%) +SELECT user_id, COUNT(prompt) as prompt_count, ROUND(AVG(tokens),2) as avg_tokens +FROM prompts +GROUP BY user_id +HAVING prompt_count > 2 AND MAX(tokens) > avg_tokens +ORDER BY avg_tokens DESC, user_id asc; diff --git a/src/main/java/g3701_3800/s3794_reverse_string_prefix/Solution.java b/src/main/java/g3701_3800/s3794_reverse_string_prefix/Solution.java new file mode 100644 index 000000000..9b03a966c --- /dev/null +++ b/src/main/java/g3701_3800/s3794_reverse_string_prefix/Solution.java @@ -0,0 +1,16 @@ +package g3701_3800.s3794_reverse_string_prefix; + +// #Easy #String #Two_Pointers #Mid_Level #Biweekly_Contest_173 +// #2026_05_22_Time_1_ms_(100.00%)_Space_44.69_MB_(49.90%) + +public class Solution { + public String reversePrefix(String s, int k) { + char[] arr = s.toCharArray(); + for (int i = 0; i < k / 2; i++) { + char temp = arr[i]; + arr[i] = arr[k - 1 - i]; + arr[k - 1 - i] = temp; + } + return new String(arr); + } +} diff --git a/src/main/java/g3701_3800/s3794_reverse_string_prefix/readme.md b/src/main/java/g3701_3800/s3794_reverse_string_prefix/readme.md new file mode 100644 index 000000000..61cea26bd --- /dev/null +++ b/src/main/java/g3701_3800/s3794_reverse_string_prefix/readme.md @@ -0,0 +1,43 @@ +3794\. Reverse String Prefix + +Easy + +You are given a string `s` and an integer `k`. + +Reverse the first `k` characters of `s` and return the resulting string. + +**Example 1:** + +**Input:** s = "abcd", k = 2 + +**Output:** "bacd" + +**Explanation:** + +The first `k = 2` characters `"ab"` are reversed to `"ba"`. The final resulting string is `"bacd"`. + +**Example 2:** + +**Input:** s = "xyz", k = 3 + +**Output:** "zyx" + +**Explanation:** + +The first `k = 3` characters `"xyz"` are reversed to `"zyx"`. The final resulting string is `"zyx"`. + +**Example 3:** + +**Input:** s = "hey", k = 1 + +**Output:** "hey" + +**Explanation:** + +The first `k = 1` character `"h"` remains unchanged on reversal. The final resulting string is `"hey"`. + +**Constraints:** + +* `1 <= s.length <= 100` +* `s` consists of lowercase English letters. +* `1 <= k <= s.length` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/Solution.java b/src/main/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/Solution.java new file mode 100644 index 000000000..82b64f2a8 --- /dev/null +++ b/src/main/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/Solution.java @@ -0,0 +1,43 @@ +package g3701_3800.s3795_minimum_subarray_length_with_distinct_sum_at_least_k; + +// #Medium #Array #Hash_Table #Sliding_Window #Senior #Biweekly_Contest_173 +// #2026_05_22_Time_88_ms_(85.14%)_Space_207.14_MB_(6.02%) + +import java.util.HashMap; +import java.util.Map; + +public class Solution { + public int minLength(int[] nums, int k) { + for (int i : nums) { + if (i >= k) { + return 1; + } + } + int ans = Integer.MAX_VALUE; + int alt = -1; + int i = 0; + int j = 1; + int sum = nums[0]; + if (sum >= k) { + return 1; + } + Map hm = new HashMap<>(); + hm.put(nums[0], 1); + while (i < nums.length && j < nums.length) { + hm.put(nums[j], hm.getOrDefault(nums[j], 0) + 1); + if (hm.get(nums[j]) == 1) { + sum += nums[j]; + } + while (sum >= k) { + ans = Math.min(ans, j - i + 1); + hm.put(nums[i], hm.get(nums[i]) - 1); + if (hm.get(nums[i]) == 0) { + sum -= nums[i]; + } + i++; + } + j++; + } + return (ans != Integer.MAX_VALUE) ? ans : alt; + } +} diff --git a/src/main/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/readme.md b/src/main/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/readme.md new file mode 100644 index 000000000..039f74fa5 --- /dev/null +++ b/src/main/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/readme.md @@ -0,0 +1,43 @@ +3795\. Minimum Subarray Length With Distinct Sum At Least K + +Medium + +You are given an integer array `nums` and an integer `k`. + +Return the **minimum** length of a **non-empty subarrays** whose sum of the **distinct** values present in that subarray (each value counted once) is **at least** `k`. If no such subarray exists, return -1. + +**Example 1:** + +**Input:** nums = [2,2,3,1], k = 4 + +**Output:** 2 + +**Explanation:** + +The subarray `[2, 3]` has distinct elements `{2, 3}` whose sum is `2 + 3 = 5`, which is at least `k = 4`. Thus, the answer is 2. + +**Example 2:** + +**Input:** nums = [3,2,3,4], k = 5 + +**Output:** 2 + +**Explanation:** + +The subarray `[3, 2]` has distinct elements `{3, 2}` whose sum is `3 + 2 = 5`, which is at least `k = 5`. Thus, the answer is 2. + +**Example 3:** + +**Input:** nums = [5,5,4], k = 5 + +**Output:** 1 + +**Explanation:** + +The subarray `[5]` has distinct elements `{5}` whose sum is `5`, which is at least `k = 5`. Thus, the answer is 1. + +**Constraints:** + +* 1 <= nums.length <= 105 +* 1 <= nums[i] <= 105 +* 1 <= k <= 109 \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/Solution.java b/src/main/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/Solution.java new file mode 100644 index 000000000..cc24214bd --- /dev/null +++ b/src/main/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/Solution.java @@ -0,0 +1,28 @@ +package g3701_3800.s3796_find_maximum_value_in_a_constrained_sequence; + +// #Medium #Array #Greedy #Staff #Biweekly_Contest_173 +// #2026_05_22_Time_6_ms_(98.18%)_Space_208.10_MB_(32.73%) + +public class Solution { + public int findMaxVal(int n, int[][] restrictions, int[] diff) { + int[] a = new int[n]; + a[0] = 0; + for (int i = 1; i < n; i++) { + a[i] = Integer.MAX_VALUE; + } + for (int[] r : restrictions) { + a[r[0]] = Math.min(a[r[0]], r[1]); + } + for (int i = 1; i < n; i++) { + a[i] = Math.min(a[i], a[i - 1] + diff[i - 1]); + } + for (int i = n - 2; i >= 0; i--) { + a[i] = Math.min(a[i], a[i + 1] + diff[i]); + } + int maxi = 0; + for (int i : a) { + maxi = Math.max(maxi, i); + } + return maxi; + } +} diff --git a/src/main/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/readme.md b/src/main/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/readme.md new file mode 100644 index 000000000..151f6554f --- /dev/null +++ b/src/main/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/readme.md @@ -0,0 +1,48 @@ +3796\. Find Maximum Value in a Constrained Sequence + +Medium + +You are given an integer `n`, a 2D integer array `restrictions`, and an integer array `diff` of length `n - 1`. Your task is to construct a sequence of length `n`, denoted by `a[0], a[1], ..., a[n - 1]`, such that it satisfies the following conditions: + +* `a[0]` is 0. +* All elements in the sequence are **non-negative**. +* For every index `i` (`0 <= i <= n - 2`), `abs(a[i] - a[i + 1]) <= diff[i]`. +* For each `restrictions[i] = [idx, maxVal]`, the value at position `idx` in the sequence must not exceed `maxVal` (i.e., `a[idx] <= maxVal`). + +Your goal is to construct a valid sequence that **maximizes** the **largest** value within the sequence while satisfying all the above conditions. + +Return an integer denoting the **largest** value present in such an optimal sequence. + +**Example 1:** + +**Input:** n = 10, restrictions = [[3,1],[8,1]], diff = [2,2,3,1,4,5,1,1,2] + +**Output:** 6 + +**Explanation:** + +* The sequence `a = [0, 2, 4, 1, 2, 6, 2, 1, 1, 3]` satisfies the given constraints (`a[3] <= 1` and `a[8] <= 1`). +* The maximum value in the sequence is 6. + +**Example 2:** + +**Input:** n = 8, restrictions = [[3,2]], diff = [3,5,2,4,2,3,1] + +**Output:** 12 + +**Explanation:** + +* The sequence `a = [0, 3, 3, 2, 6, 8, 11, 12]` satisfies the given constraints (`a[3] <= 2`). +* The maximum value in the sequence is 12. + +**Constraints:** + +* 2 <= n <= 105 +* `1 <= restrictions.length <= n - 1` +* `restrictions[i].length == 2` +* `restrictions[i] = [idx, maxVal]` +* `1 <= idx < n` +* 1 <= maxVal <= 106 +* `diff.length == n - 1` +* `1 <= diff[i] <= 10` +* The values of `restrictions[i][0]` are unique. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/Solution.java b/src/main/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/Solution.java new file mode 100644 index 000000000..d88da09bb --- /dev/null +++ b/src/main/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/Solution.java @@ -0,0 +1,55 @@ +package g3701_3800.s3797_count_routes_to_climb_a_rectangular_grid; + +// #Hard #Array #Dynamic_Programming #Matrix #Prefix_Sum #Senior_Staff #Biweekly_Contest_173 +// #2026_05_22_Time_89_ms_(89.19%)_Space_57.00_MB_(81.08%) + +import java.util.Arrays; + +public class Solution { + public int numberOfRoutes(String[] grid, int d) { + int n = grid.length; + int m = grid[0].length(); + long mod = 1_000_000_007; + long[] dp = null; + for (int i = n - 1; i >= 0; i--) { + String r = grid[i]; + if (dp == null) { + long[] init = new long[m]; + Arrays.fill(init, 1); + dp = f(init, 0, r, m, mod); + } else { + int d2 = (int) Math.sqrt((double) d * d - 1); + dp = f(dp, d2, r, m, mod); + } + dp = f(dp, d, r, m, mod); + } + long res = 0; + for (long v : dp) { + res = (res + v) % mod; + } + return (int) (res); + } + + private long[] f(long[] dp, int dist, String r, int m, long mod) { + long[] dp2 = new long[m]; + long window = 0; + for (int k = 0; k <= Math.min(m - 1, dist); k++) { + window += dp[k]; + } + dp2[0] = window; + for (int j = 1; j < m; j++) { + window = dp2[j - 1]; + if (j - dist - 1 >= 0) { + window -= dp[j - dist - 1]; + } + if (j + dist < m) { + window += dp[j + dist]; + } + dp2[j] = window; + } + for (int j = 0; j < m; j++) { + dp2[j] = (r.charAt(j) == '#') ? 0 : dp2[j] % mod; + } + return dp2; + } +} diff --git a/src/main/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/readme.md b/src/main/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/readme.md new file mode 100644 index 000000000..797a3ba3c --- /dev/null +++ b/src/main/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/readme.md @@ -0,0 +1,88 @@ +3797\. Count Routes to Climb a Rectangular Grid + +Hard + +You are given a string array `grid` of size `n`, where each string `grid[i]` has length `m`. The character `grid[i][j]` is one of the following symbols: + +* `'.'`: The cell is available. +* `'#'`: The cell is blocked. + +You want to count the number of different routes to climb `grid`. Each route must start from _any cell_ in the bottom row (row `n - 1`) and end in the top row (row 0). + +However, there are some constraints on the route. + +* You can only move from one available cell to **another** available cell. +* The **Euclidean distance** of each move is **at most** `d`, where `d` is an integer parameter given to you. The Euclidean distance between two cells `(r1, c1)`, `(r2, c2)` is sqrt((r1 - r2)2 + (c1 - c2)2). +* Each move either stays on the same row or moves to the row directly above (from row `r` to `r - 1`). +* You cannot stay on the same row for two consecutive turns. If you stay on the same row in a move (and this move is not the last move), your next move must go to the row above. + +Return an integer denoting the number of such routes. Since the answer may be very large, return it **modulo** 109 + 7. + +**Example 1:** + +**Input:** grid = ["..","#."], d = 1 + +**Output:** 2 + +**Explanation:** + +We label the cells we visit in the routes sequentially, starting from 1. The two routes are: + +.2 #1 + +32 #1 + +We can move from the cell (1, 1) to the cell (0, 1) because the Euclidean distance is sqrt((1 - 0)2 + (1 - 1)2) = sqrt(1) <= d. + +However, we cannot move from the cell (1, 1) to the cell (0, 0) because the Euclidean distance is sqrt((1 - 0)2 + (1 - 0)2) = sqrt(2) > d. + +**Example 2:** + +**Input:** grid = ["..","#."], d = 2 + +**Output:** 4 + +**Explanation:** + +Two of the routes are given in example 1. The other two routes are: + +2\. #1 + +23 #1 + +Note that we can move from (1, 1) to (0, 0) because the Euclidean distance is `sqrt(2) <= d`. + +**Example 3:** + +**Input:** grid = ["#"], d = 750 + +**Output:** 0 + +**Explanation:** + +We cannot choose any cell as the starting cell. Therefore, there are no routes. + +**Example 4:** + +**Input:** grid = [".."], d = 1 + +**Output:** 4 + +**Explanation:** + +The possible routes are: + +.1 + +1\. + +12 + +21 + +**Constraints:** + +* `1 <= n == grid.length <= 750` +* `1 <= m == grid[i].length <= 750` +* `grid[i][j]` is `'.'` or `'#'`. +* `1 <= d <= 750` \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3798_largest_even_number/Solution.java b/src/main/java/g3701_3800/s3798_largest_even_number/Solution.java new file mode 100644 index 000000000..bcf702a14 --- /dev/null +++ b/src/main/java/g3701_3800/s3798_largest_even_number/Solution.java @@ -0,0 +1,16 @@ +package g3701_3800.s3798_largest_even_number; + +// #Easy #String #Mid_Level #Weekly_Contest_483 +// #2026_05_22_Time_0_ms_(100.00%)_Space_43.67_MB_(94.28%) + +public class Solution { + public String largestEven(String s) { + int i; + for (i = s.length() - 1; i >= 0; i--) { + if (s.charAt(i) == '2') { + break; + } + } + return s.substring(0, i + 1); + } +} diff --git a/src/main/java/g3701_3800/s3798_largest_even_number/readme.md b/src/main/java/g3701_3800/s3798_largest_even_number/readme.md new file mode 100644 index 000000000..a2f771819 --- /dev/null +++ b/src/main/java/g3701_3800/s3798_largest_even_number/readme.md @@ -0,0 +1,44 @@ +3798\. Largest Even Number + +Easy + +You are given a string `s` consisting only of the characters `'1'` and `'2'`. + +You may delete any number of characters from `s` without changing the order of the remaining characters. + +Return the **largest possible resultant string** that represents an **even** integer. If there is no such string, return the empty string `""`. + +**Example 1:** + +**Input:** s = "1112" + +**Output:** "1112" + +**Explanation:** + +The string already represents the largest possible even number, so no deletions are needed. + +**Example 2:** + +**Input:** s = "221" + +**Output:** "22" + +**Explanation:** + +Deleting `'1'` results in the largest possible even number which is equal to 22. + +**Example 3:** + +**Input:** s = "1" + +**Output:** "" + +**Explanation:** + +There is no way to get an even number. + +**Constraints:** + +* `1 <= s.length <= 100` +* `s` consists only of the characters `'1'` and `'2'`. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3799_word_squares_ii/Solution.java b/src/main/java/g3701_3800/s3799_word_squares_ii/Solution.java new file mode 100644 index 000000000..24d394a14 --- /dev/null +++ b/src/main/java/g3701_3800/s3799_word_squares_ii/Solution.java @@ -0,0 +1,37 @@ +package g3701_3800.s3799_word_squares_ii; + +// #Medium #Array #String #Sorting #Backtracking #Enumeration #Senior #Weekly_Contest_483 +// #2026_05_22_Time_5_ms_(99.15%)_Space_56.77_MB_(55.56%) + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Solution { + public List> wordSquares(String[] words) { + String[] s = words.clone(); + Arrays.sort(s); + List> result = new ArrayList<>(); + int n = s.length; + for (int a = 0; a < n; a++) { + for (int b = 0; b < n; b++) { + if (a != b && s[a].charAt(0) == s[b].charAt(0)) { + for (int c = 0; c < n; c++) { + if (c != a && c != b && s[a].charAt(3) == s[c].charAt(0)) { + for (int d = 0; d < n; d++) { + if (d != a + && d != b + && d != c + && s[d].charAt(0) == s[b].charAt(3) + && s[d].charAt(3) == s[c].charAt(3)) { + result.add(Arrays.asList(s[a], s[b], s[c], s[d])); + } + } + } + } + } + } + } + return result; + } +} diff --git a/src/main/java/g3701_3800/s3799_word_squares_ii/readme.md b/src/main/java/g3701_3800/s3799_word_squares_ii/readme.md new file mode 100644 index 000000000..2878f9ea0 --- /dev/null +++ b/src/main/java/g3701_3800/s3799_word_squares_ii/readme.md @@ -0,0 +1,56 @@ +3799\. Word Squares II + +Medium + +You are given a string array `words`, consisting of **distinct** 4-letter strings, each containing lowercase English letters. + +A **word square** consists of 4 **distinct** words: `top`, `left`, `right` and `bottom`, arranged as follows: + +* `top` forms the **top row**. +* `bottom` forms the **bottom row**. +* `left` forms the **left column** (top to bottom). +* `right` forms the **right column** (top to bottom). + +It must satisfy: + +* `top[0] == left[0]`, `top[3] == right[0]` +* `bottom[0] == left[3]`, `bottom[3] == right[3]` + +Return all valid **distinct** word squares, sorted in **ascending lexicographic** order by the 4-tuple `(top, left, right, bottom)`. + +**Example 1:** + +**Input:** words = ["able","area","echo","also"] + +**Output:** [["able","area","echo","also"],["area","able","also","echo"]] + +**Explanation:** + +There are exactly two valid 4-word squares that satisfy all corner constraints: + +* `"able"` (top), `"area"` (left), `"echo"` (right), `"also"` (bottom) + * `top[0] == left[0] == 'a'` + * `top[3] == right[0] == 'e'` + * `bottom[0] == left[3] == 'a'` + * `bottom[3] == right[3] == 'o'` +* `"area"` (top), `"able"` (left), `"also"` (right), `"echo"` (bottom) + * All corner constraints are satisfied. + +Thus, the answer is `[["able","area","echo","also"],["area","able","also","echo"]]`. + +**Example 2:** + +**Input:** words = ["code","cafe","eden","edge"] + +**Output:** [] + +**Explanation:** + +No combination of four words satisfies all four corner constraints. Thus, the answer is empty array `[]`. + +**Constraints:** + +* `4 <= words.length <= 15` +* `words[i].length == 4` +* `words[i]` consists of only lowercase English letters. +* All `words[i]` are **distinct**. \ No newline at end of file diff --git a/src/main/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/Solution.java b/src/main/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/Solution.java new file mode 100644 index 000000000..850d504f4 --- /dev/null +++ b/src/main/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/Solution.java @@ -0,0 +1,39 @@ +package g3701_3800.s3800_minimum_cost_to_make_two_binary_strings_equal; + +// #Medium #String #Greedy #Staff #Weekly_Contest_483 +// #2026_05_22_Time_8_ms_(85.71%)_Space_47.61_MB_(85.71%) + +public class Solution { + public long minimumCost(String s, String t, int flipCost, int swapCost, int crossCost) { + int len = t.length(); + int diff = 0; + int one = 0; + int zero = 0; + char[] arr1 = s.toCharArray(); + char[] arr2 = t.toCharArray(); + for (int i = 0; i < len; i++) { + if (arr1[i] != arr2[i]) { + diff++; + if (arr1[i] == '0') { + zero++; + } else { + one++; + } + } + } + int min = Math.min(one, zero); + long ans = 0; + long costOfFlip = ((long) min * flipCost) * 2; + long costOfSwap = ((long) min * swapCost); + ans += Math.min(costOfFlip, costOfSwap); + diff -= (min * 2); + int oddLeft = diff % 2; + int evenLeft = diff - oddLeft; + long costOfCrossSwap = + (((long) (evenLeft / 2) * crossCost) + ((long) (evenLeft / 2) * swapCost)); + long costOfFlipMain = ((long) evenLeft * flipCost); + ans += Math.min(costOfCrossSwap, costOfFlipMain); + ans += (long) oddLeft * flipCost; + return ans; + } +} diff --git a/src/main/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/readme.md b/src/main/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/readme.md new file mode 100644 index 000000000..72889f339 --- /dev/null +++ b/src/main/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/readme.md @@ -0,0 +1,57 @@ +3800\. Minimum Cost to Make Two Binary Strings Equal + +Medium + +You are given two binary strings `s` and `t`, both of length `n`, and three **positive** integers `flipCost`, `swapCost`, and `crossCost`. + +You are allowed to apply the following operations any number of times (in any order) to the strings `s` and `t`: + +* Choose any index `i` and flip `s[i]` or `t[i]` (change `'0'` to `'1'` or `'1'` to `'0'`). The cost of this operation is `flipCost`. +* Choose two **distinct** indices `i` and `j`, and swap either `s[i]` and `s[j]` or `t[i]` and `t[j]`. The cost of this operation is `swapCost`. +* Choose an index `i` and swap `s[i]` with `t[i]`. The cost of this operation is `crossCost`. + +Return an integer denoting the **minimum** total cost needed to make the strings `s` and `t` equal. + +**Example 1:** + +**Input:** s = "01000", t = "10111", flipCost = 10, swapCost = 2, crossCost = 2 + +**Output:** 16 + +**Explanation:** + +We can perform the following operations: + +* Swap `s[0]` and `s[1]` (`swapCost = 2`). After this operation, `s = "10000"` and `t = "10111"`. +* Cross swap `s[2]` and `t[2]` (`crossCost = 2`). After this operation, `s = "10100"` and `t = "10011"`. +* Swap `s[2]` and `s[3]` (`swapCost = 2`). After this operation, `s = "10010"` and `t = "10011"`. +* Flip `s[4]` (`flipCost = 10`). After this operation, `s = t = "10011"`. + +The total cost is `2 + 2 + 2 + 10 = 16`. + +**Example 2:** + +**Input:** s = "001", t = "110", flipCost = 2, swapCost = 100, crossCost = 100 + +**Output:** 6 + +**Explanation:** + +Flipping all the bits of `s` makes the strings equal, and the total cost is `3 * flipCost = 3 * 2 = 6`. + +**Example 3:** + +**Input:** s = "1010", t = "1010", flipCost = 5, swapCost = 5, crossCost = 5 + +**Output:** 0 + +**Explanation:** + +The strings are already equal, so no operations are required. + +**Constraints:** + +* `n == s.length == t.length` +* 1 <= n <= 105 +* 1 <= flipCost, swapCost, crossCost <= 109 +* `s` and `t` consist only of the characters `'0'` and `'1'`. \ No newline at end of file diff --git a/src/main/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/Solution.java b/src/main/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/Solution.java new file mode 100644 index 000000000..878412814 --- /dev/null +++ b/src/main/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/Solution.java @@ -0,0 +1,114 @@ +package g3801_3900.s3801_minimum_cost_to_merge_sorted_lists; + +// #Hard #Array #Dynamic_Programming #Binary_Search #Two_Pointers #Bit_Manipulation #Senior_Staff +// #Weekly_Contest_483 #2026_05_22_Time_251_ms_(89.19%)_Space_47.69_MB_(83.78%) + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class Solution { + private int numLt(int[][] lists, int enabled, int guess) { + int result = 0; + for (int i = 0; i < lists.length; i++) { + if (((enabled >> i) & 1) == 1) { + int[] list = lists[i]; + int low = 0; + int high = list.length; + while (low < high) { + int mid = (low + high) / 2; + if (list[mid] < guess) { + low = mid + 1; + } else { + high = mid; + } + } + result += low; + } + } + return result; + } + + public long minMergeCost(int[][] lists) { + int n = lists.length; + List allNums = getSortedNumbers(lists); + long[][] subsets = buildSubsetInfo(lists, allNums); + long[] dp = new long[1 << n]; + Arrays.fill(dp, Long.MAX_VALUE); + for (int subset = 0; subset < (1 << n); subset++) { + if (Integer.bitCount(subset) <= 1) { + dp[subset] = 0; + continue; + } + dp[subset] = calculateMinCost(subset, subsets, dp); + } + return dp[(1 << n) - 1]; + } + + private List getSortedNumbers(int[][] lists) { + List allNums = new ArrayList<>(); + for (int[] lst : lists) { + for (int num : lst) { + allNums.add(num); + } + } + Collections.sort(allNums); + return allNums; + } + + private long[][] buildSubsetInfo(int[][] lists, List allNums) { + int n = lists.length; + long[][] subsets = new long[1 << n][2]; + for (int subset = 1; subset < (1 << n); subset++) { + int resultLen = getSubsetLength(lists, subset); + int medianLt = (resultLen - 1) / 2; + subsets[subset][0] = resultLen; + subsets[subset][1] = findMedian(lists, subset, medianLt, allNums); + } + return subsets; + } + + private int getSubsetLength(int[][] lists, int subset) { + int resultLen = 0; + for (int i = 0; i < lists.length; i++) { + if (((subset >> i) & 1) == 1) { + resultLen += lists[i].length; + } + } + return resultLen; + } + + private int findMedian(int[][] lists, int subset, int medianLt, List allNums) { + int low = 0; + int high = allNums.size() - 1; + int actualMedian = -1; + while (low <= high) { + int mid = (low + high) / 2; + int num = allNums.get(mid); + if (numLt(lists, subset, num) <= medianLt) { + actualMedian = num; + low = mid + 1; + } else { + high = mid - 1; + } + } + return actualMedian; + } + + private long calculateMinCost(int subset, long[][] subsets, long[] dp) { + long minCost = Long.MAX_VALUE; + int a = (subset - 1) & subset; + while (a > 0) { + int b = subset ^ a; + long aLen = subsets[a][0]; + long aMedian = subsets[a][1]; + long bLen = subsets[b][0]; + long bMedian = subsets[b][1]; + long cost = aLen + bLen + Math.abs(aMedian - bMedian); + minCost = Math.min(minCost, dp[a] + dp[b] + cost); + a = (a - 1) & subset; + } + return minCost; + } +} diff --git a/src/main/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/readme.md b/src/main/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/readme.md new file mode 100644 index 000000000..bd58c4656 --- /dev/null +++ b/src/main/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/readme.md @@ -0,0 +1,89 @@ +3801\. Minimum Cost to Merge Sorted Lists + +Hard + +You are given a 2D integer array `lists`, where each `lists[i]` is a non-empty array of integers **sorted** in **non-decreasing** order. + +You may **repeatedly** choose two lists `a = lists[i]` and `b = lists[j]`, where `i != j`, and merge them. The **cost** to merge `a` and `b` is: + +`len(a) + len(b) + abs(median(a) - median(b))`, where `len` and `median` denote the list length and median, respectively. + +After merging `a` and `b`, remove both `a` and `b` from `lists` and insert the new merged **sorted list** in **any** position. Repeat merges until only **one** list remains. + +Return an integer denoting the **minimum total cost** required to merge all lists into one single sorted list. + +The **median** of an array is the middle element after sorting it in non-decreasing order. If the array has an even number of elements, the median is the left middle element. + +**Example 1:** + +**Input:** lists = [[1,3,5],[2,4],[6,7,8]] + +**Output:** 18 + +**Explanation:** + +Merge `a = [1, 3, 5]` and `b = [2, 4]`: + +* `len(a) = 3` and `len(b) = 2` +* `median(a) = 3` and `median(b) = 2` +* `cost = len(a) + len(b) + abs(median(a) - median(b)) = 3 + 2 + abs(3 - 2) = 6` + +So `lists` becomes `[[1, 2, 3, 4, 5], [6, 7, 8]]`. + +Merge `a = [1, 2, 3, 4, 5]` and `b = [6, 7, 8]`: + +* `len(a) = 5` and `len(b) = 3` +* `median(a) = 3` and `median(b) = 7` +* `cost = len(a) + len(b) + abs(median(a) - median(b)) = 5 + 3 + abs(3 - 7) = 12` + +So `lists` becomes `[[1, 2, 3, 4, 5, 6, 7, 8]]`, and total cost is `6 + 12 = 18`. + +**Example 2:** + +**Input:** lists = [[1,1,5],[1,4,7,8]] + +**Output:** 10 + +**Explanation:** + +Merge `a = [1, 1, 5]` and `b = [1, 4, 7, 8]`: + +* `len(a) = 3` and `len(b) = 4` +* `median(a) = 1` and `median(b) = 4` +* `cost = len(a) + len(b) + abs(median(a) - median(b)) = 3 + 4 + abs(1 - 4) = 10` + +So `lists` becomes `[[1, 1, 1, 4, 5, 7, 8]]`, and total cost is 10. + +**Example 3:** + +**Input:** lists = [[1],[3]] + +**Output:** 4 + +**Explanation:** + +Merge `a = [1]` and `b = [3]`: + +* `len(a) = 1` and `len(b) = 1` +* `median(a) = 1` and `median(b) = 3` +* `cost = len(a) + len(b) + abs(median(a) - median(b)) = 1 + 1 + abs(1 - 3) = 4` + +So `lists` becomes `[[1, 3]]`, and total cost is 4. + +**Example 4:** + +**Input:** lists = [[1],[1]] + +**Output:** 2 + +**Explanation:** + +The total cost is `len(a) + len(b) + abs(median(a) - median(b)) = 1 + 1 + abs(1 - 1) = 2`. + +**Constraints:** + +* `2 <= lists.length <= 12` +* `1 <= lists[i].length <= 500` +* -109 <= lists[i][j] <= 109 +* `lists[i]` is sorted in non-decreasing order. +* The **sum** of `lists[i].length` will not exceed 2000. \ No newline at end of file diff --git a/src/main/java/g3801_3900/s3803_count_residue_prefixes/Solution.java b/src/main/java/g3801_3900/s3803_count_residue_prefixes/Solution.java new file mode 100644 index 000000000..5525fa092 --- /dev/null +++ b/src/main/java/g3801_3900/s3803_count_residue_prefixes/Solution.java @@ -0,0 +1,28 @@ +package g3801_3900.s3803_count_residue_prefixes; + +// #Easy #String #Hash_Table #Mid_Level #Weekly_Contest_484 +// #2026_05_22_Time_1_ms_(100.00%)_Space_43.67_MB_(91.69%) + +public class Solution { + public int residuePrefixes(String s) { + int n = s.length(); + int count = 0; + int p = 0; + char c1 = s.charAt(p); + while (p < n && c1 == s.charAt(p)) { + if (++p % 3 == 1) { + count++; + } + } + if (p >= n) { + return count; + } + char c2 = s.charAt(p); + while (p < n && (c1 == s.charAt(p) || c2 == s.charAt(p))) { + if (++p % 3 == 2) { + count++; + } + } + return count; + } +} diff --git a/src/main/java/g3801_3900/s3803_count_residue_prefixes/readme.md b/src/main/java/g3801_3900/s3803_count_residue_prefixes/readme.md new file mode 100644 index 000000000..2006a7b3f --- /dev/null +++ b/src/main/java/g3801_3900/s3803_count_residue_prefixes/readme.md @@ -0,0 +1,50 @@ +3803\. Count Residue Prefixes + +Easy + +You are given a string `s` consisting only of lowercase English letters. + +A **prefix** of `s` is called a **residue** if the number of **distinct characters** in the **prefix** is equal to `len(prefix) % 3`. + +Return the count of **residue** prefixes in `s`. + +A **prefix** of a string is a **non-empty substring** that starts from the beginning of the string and extends to any point within it. + +**Example 1:** + +**Input:** s = "abc" + +**Output:** 2 + +**Explanation:** + +* Prefix `"a"` has 1 distinct character and length modulo 3 is 1, so it is a residue. +* Prefix `"ab"` has 2 distinct characters and length modulo 3 is 2, so it is a residue. +* Prefix `"abc"` does not satisfy the condition. Thus, the answer is 2. + +**Example 2:** + +**Input:** s = "dd" + +**Output:** 1 + +**Explanation:** + +* Prefix `"d"` has 1 distinct character and length modulo 3 is 1, so it is a residue. +* Prefix `"dd"` has 1 distinct character but length modulo 3 is 2, so it is not a residue. Thus, the answer is 1. + +**Example 3:** + +**Input:** s = "bob" + +**Output:** 2 + +**Explanation:** + +* Prefix `"b"` has 1 distinct character and length modulo 3 is 1, so it is a residue. +* Prefix `"bo"` has 2 distinct characters and length mod 3 is 2, so it is a residue. Thus, the answer is 2. + +**Constraints:** + +* `1 <= s.length <= 100` +* `s` contains only lowercase English letters. \ No newline at end of file diff --git a/src/main/java/g3801_3900/s3804_number_of_centered_subarrays/Solution.java b/src/main/java/g3801_3900/s3804_number_of_centered_subarrays/Solution.java new file mode 100644 index 000000000..fe99dd4ff --- /dev/null +++ b/src/main/java/g3801_3900/s3804_number_of_centered_subarrays/Solution.java @@ -0,0 +1,24 @@ +package g3801_3900.s3804_number_of_centered_subarrays; + +// #Medium #Array #Hash_Table #Enumeration #Senior #Weekly_Contest_484 +// #2026_05_22_Time_84_ms_(80.43%)_Space_47.00_MB_(47.83%) + +import java.util.HashSet; +import java.util.Set; + +public class Solution { + public int centeredSubarrays(int[] nums) { + int n = nums.length; + int result = 0; + for (int i = 0; i < n; i++) { + int subsum = 0; + Set subnums = new HashSet<>(); + for (int j = i; j < n; j++) { + subsum += nums[j]; + subnums.add(nums[j]); + result += subnums.contains(subsum) ? 1 : 0; + } + } + return result; + } +} diff --git a/src/main/java/g3801_3900/s3804_number_of_centered_subarrays/readme.md b/src/main/java/g3801_3900/s3804_number_of_centered_subarrays/readme.md new file mode 100644 index 000000000..dc8af7f74 --- /dev/null +++ b/src/main/java/g3801_3900/s3804_number_of_centered_subarrays/readme.md @@ -0,0 +1,37 @@ +3804\. Number of Centered Subarrays + +Medium + +You are given an integer array `nums`. + +A **non-empty subarrays** of `nums` is called **centered** if the sum of its elements is **equal to at least one** element within that **same subarray**. + +Return the number of **centered subarrays** of `nums`. + +**Example 1:** + +**Input:** nums = [-1,1,0] + +**Output:** 5 + +**Explanation:** + +* All single-element subarrays (`[-1]`, `[1]`, `[0]`) are centered. +* The subarray `[1, 0]` has a sum of 1, which is present in the subarray. +* The subarray `[-1, 1, 0]` has a sum of 0, which is present in the subarray. +* Thus, the answer is 5. + +**Example 2:** + +**Input:** nums = [2,-3] + +**Output:** 2 + +**Explanation:** + +Only single-element subarrays (`[2]`, `[-3]`) are centered. + +**Constraints:** + +* `1 <= nums.length <= 500` +* -105 <= nums[i] <= 105 \ No newline at end of file diff --git a/src/main/java/g3801_3900/s3805_count_caesar_cipher_pairs/Solution.java b/src/main/java/g3801_3900/s3805_count_caesar_cipher_pairs/Solution.java new file mode 100644 index 000000000..871703c42 --- /dev/null +++ b/src/main/java/g3801_3900/s3805_count_caesar_cipher_pairs/Solution.java @@ -0,0 +1,27 @@ +package g3801_3900.s3805_count_caesar_cipher_pairs; + +// #Medium #Array #String #Hash_Table #Math #Counting #Senior #Weekly_Contest_484 +// #2026_05_22_Time_34_ms_(98.75%)_Space_67.70_MB_(82.50%) + +import java.util.HashMap; +import java.util.Map; + +public class Solution { + public long countPairs(String[] words) { + String[] a = words; + Map b = new HashMap<>(); + long c = 0; + for (String d : a) { + char[] e = d.toCharArray(); + int f = e[0]; + for (int g = 0; g < e.length; g++) { + e[g] = (char) ((e[g] - f + 26) % 26); + } + String h = new String(e); + int i = b.getOrDefault(h, 0); + c += i; + b.put(h, i + 1); + } + return c; + } +} diff --git a/src/main/java/g3801_3900/s3805_count_caesar_cipher_pairs/readme.md b/src/main/java/g3801_3900/s3805_count_caesar_cipher_pairs/readme.md new file mode 100644 index 000000000..06fd3e06a --- /dev/null +++ b/src/main/java/g3801_3900/s3805_count_caesar_cipher_pairs/readme.md @@ -0,0 +1,52 @@ +3805\. Count Caesar Cipher Pairs + +Medium + +You are given an array `words` of `n` strings. Each string has length `m` and contains only lowercase English letters. + +Two strings `s` and `t` are **similar** if we can apply the following operation any number of times (possibly zero times) so that `s` and `t` become **equal**. + +* Choose either `s` or `t`. +* Replace **every** letter in the chosen string with the next letter in the alphabet cyclically. The next letter after `'z'` is `'a'`. + +Count the number of pairs of indices `(i, j)` such that: + +* `i < j` +* `words[i]` and `words[j]` are **similar**. + +Return an integer denoting the number of such pairs. + +**Example 1:** + +**Input:** words = ["fusion","layout"] + +**Output:** 1 + +**Explanation:** + +`words[0] = "fusion"` and `words[1] = "layout"` are similar because we can apply the operation to `"fusion"` 6 times. The string `"fusion"` changes as follows. + +* `"fusion"` +* `"gvtjpo"` +* `"hwukqp"` +* `"ixvlrq"` +* `"jywmsr"` +* `"kzxnts"` +* `"layout"` + +**Example 2:** + +**Input:** words = ["ab","aa","za","aa"] + +**Output:** 2 + +**Explanation:** + +`words[0] = "ab"` and `words[2] = "za"` are similar. `words[1] = "aa"` and `words[3] = "aa"` are similar. + +**Constraints:** + +* 1 <= n == words.length <= 105 +* 1 <= m == words[i].length <= 105 +* 1 <= n * m <= 105 +* `words[i]` consists only of lowercase English letters. \ No newline at end of file diff --git a/src/test/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/SolutionTest.java b/src/test/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/SolutionTest.java new file mode 100644 index 000000000..383e6edae --- /dev/null +++ b/src/test/java/g3701_3800/s3736_minimum_moves_to_equal_array_elements_iii/SolutionTest.java @@ -0,0 +1,18 @@ +package g3701_3800.s3736_minimum_moves_to_equal_array_elements_iii; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minMoves() { + assertThat(new Solution().minMoves(new int[] {2, 1, 3}), equalTo(3)); + } + + @Test + void minMoves2() { + assertThat(new Solution().minMoves(new int[] {4, 4, 5}), equalTo(2)); + } +} diff --git a/src/test/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/SolutionTest.java b/src/test/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/SolutionTest.java new file mode 100644 index 000000000..715d376f4 --- /dev/null +++ b/src/test/java/g3701_3800/s3737_count_subarrays_with_majority_element_i/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3737_count_subarrays_with_majority_element_i; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countMajoritySubarrays() { + assertThat(new Solution().countMajoritySubarrays(new int[] {1, 1, 2}, 1), equalTo(4)); + } + + @Test + void countMajoritySubarrays2() { + assertThat(new Solution().countMajoritySubarrays(new int[] {2, 2}, 1), equalTo(0)); + } + + @Test + void countMajoritySubarrays3() { + assertThat(new Solution().countMajoritySubarrays(new int[] {1, 2, 1, 2}, 1), equalTo(3)); + } +} diff --git a/src/test/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/SolutionTest.java b/src/test/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/SolutionTest.java new file mode 100644 index 000000000..f93e28135 --- /dev/null +++ b/src/test/java/g3701_3800/s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element/SolutionTest.java @@ -0,0 +1,28 @@ +package g3701_3800.s3738_longest_non_decreasing_subarray_after_replacing_at_most_one_element; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void longestSubarray() { + assertThat(new Solution().longestSubarray(new int[] {1, 2, 3}), equalTo(3)); + } + + @Test + void longestSubarray2() { + assertThat(new Solution().longestSubarray(new int[] {3, 2, 1}), equalTo(2)); + } + + @Test + void longestSubarray3() { + assertThat(new Solution().longestSubarray(new int[] {1, 5, 3, 4, 6}), equalTo(5)); + } + + @Test + void longestSubarray4() { + assertThat(new Solution().longestSubarray(new int[] {1, 5}), equalTo(2)); + } +} diff --git a/src/test/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/SolutionTest.java b/src/test/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/SolutionTest.java new file mode 100644 index 000000000..d2150cb30 --- /dev/null +++ b/src/test/java/g3701_3800/s3739_count_subarrays_with_majority_element_ii/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3739_count_subarrays_with_majority_element_ii; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countMajoritySubarrays() { + assertThat(new Solution().countMajoritySubarrays(new int[] {1, 1, 2}, 1), equalTo(4L)); + } + + @Test + void countMajoritySubarrays2() { + assertThat(new Solution().countMajoritySubarrays(new int[] {2, 2}, 1), equalTo(0L)); + } + + @Test + void countMajoritySubarrays3() { + assertThat(new Solution().countMajoritySubarrays(new int[] {1, 2, 1, 2}, 1), equalTo(3L)); + } +} diff --git a/src/test/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/SolutionTest.java b/src/test/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/SolutionTest.java new file mode 100644 index 000000000..b37a726aa --- /dev/null +++ b/src/test/java/g3701_3800/s3740_minimum_distance_between_three_equal_elements_i/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3740_minimum_distance_between_three_equal_elements_i; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minimumDistance() { + assertThat(new Solution().minimumDistance(new int[] {1, 1, 1}), equalTo(4)); + } + + @Test + void minimumDistance2() { + assertThat(new Solution().minimumDistance(new int[] {1, 2, 3, 1, 2, 3}), equalTo(-1)); + } + + @Test + void minimumDistance3() { + assertThat(new Solution().minimumDistance(new int[] {1, 2, 1, 2, 1}), equalTo(8)); + } +} diff --git a/src/test/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/SolutionTest.java b/src/test/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/SolutionTest.java new file mode 100644 index 000000000..698fa427d --- /dev/null +++ b/src/test/java/g3701_3800/s3741_minimum_distance_between_three_equal_elements_ii/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3741_minimum_distance_between_three_equal_elements_ii; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minimumDistance() { + assertThat(new Solution().minimumDistance(new int[] {1, 1, 1}), equalTo(4)); + } + + @Test + void minimumDistance2() { + assertThat(new Solution().minimumDistance(new int[] {1, 2, 3, 1, 2, 3}), equalTo(-1)); + } + + @Test + void minimumDistance3() { + assertThat(new Solution().minimumDistance(new int[] {1, 2, 1, 2, 1}), equalTo(8)); + } +} diff --git a/src/test/java/g3701_3800/s3742_maximum_path_score_in_a_grid/SolutionTest.java b/src/test/java/g3701_3800/s3742_maximum_path_score_in_a_grid/SolutionTest.java new file mode 100644 index 000000000..1647dc91c --- /dev/null +++ b/src/test/java/g3701_3800/s3742_maximum_path_score_in_a_grid/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3742_maximum_path_score_in_a_grid; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maxPathScore() { + assertThat(new Solution().maxPathScore(new int[][] {{0, 1}, {2, 3}}, 1), equalTo(-1)); + } + + @Test + void maxPathScore2() { + assertThat(new Solution().maxPathScore(new int[][] {{0, 1}, {2, 3}}, 2), equalTo(5)); + } + + @Test + void maxPathScore3() { + assertThat(new Solution().maxPathScore(new int[][] {{-1, -2}, {-3, -4}}, 0), equalTo(-1)); + } +} diff --git a/src/test/java/g3701_3800/s3743_maximize_cyclic_partition_score/SolutionTest.java b/src/test/java/g3701_3800/s3743_maximize_cyclic_partition_score/SolutionTest.java new file mode 100644 index 000000000..37f54fb21 --- /dev/null +++ b/src/test/java/g3701_3800/s3743_maximize_cyclic_partition_score/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3743_maximize_cyclic_partition_score; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maximumScore() { + assertThat(new Solution().maximumScore(new int[] {5, 5, 5}, 2), equalTo(0L)); + } + + @Test + void maximumScore2() { + assertThat(new Solution().maximumScore(new int[] {1, 3, 2}, 1), equalTo(2L)); + } + + @Test + void maximumScore3() { + assertThat(new Solution().maximumScore(new int[] {1, 4, 2}, 2), equalTo(3L)); + } +} diff --git a/src/test/java/g3701_3800/s3745_maximize_expression_of_three_elements/SolutionTest.java b/src/test/java/g3701_3800/s3745_maximize_expression_of_three_elements/SolutionTest.java new file mode 100644 index 000000000..3dfc57688 --- /dev/null +++ b/src/test/java/g3701_3800/s3745_maximize_expression_of_three_elements/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3745_maximize_expression_of_three_elements; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maximizeExpressionOfThree() { + assertThat(new Solution().maximizeExpressionOfThree(new int[] {1, 2, 3}), equalTo(4)); + } + + @Test + void maximizeExpressionOfThree2() { + assertThat(new Solution().maximizeExpressionOfThree(new int[] {5, 5, 5}), equalTo(5)); + } + + @Test + void maximizeExpressionOfThree3() { + assertThat(new Solution().maximizeExpressionOfThree(new int[] {-5, -1, -3, 4}), equalTo(8)); + } +} diff --git a/src/test/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/SolutionTest.java b/src/test/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/SolutionTest.java new file mode 100644 index 000000000..057a9b553 --- /dev/null +++ b/src/test/java/g3701_3800/s3746_minimum_string_length_after_balanced_removals/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3746_minimum_string_length_after_balanced_removals; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minLengthAfterRemovals() { + assertThat(new Solution().minLengthAfterRemovals("ab"), equalTo(0)); + } + + @Test + void minLengthAfterRemovals2() { + assertThat(new Solution().minLengthAfterRemovals("aaab"), equalTo(2)); + } + + @Test + void minLengthAfterRemovals3() { + assertThat(new Solution().minLengthAfterRemovals("bbbb"), equalTo(4)); + } +} diff --git a/src/test/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/SolutionTest.java b/src/test/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/SolutionTest.java new file mode 100644 index 000000000..e4e91a351 --- /dev/null +++ b/src/test/java/g3701_3800/s3747_count_distinct_integers_after_removing_zeros/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3747_count_distinct_integers_after_removing_zeros; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countDistinct() { + assertThat(new Solution().countDistinct(9L), equalTo(9L)); + } + + @Test + void countDistinct2() { + assertThat(new Solution().countDistinct(20L), equalTo(18L)); + } + + @Test + void countDistinct3() { + assertThat(new Solution().countDistinct(99L), equalTo(90L)); + } +} diff --git a/src/test/java/g3701_3800/s3748_count_stable_subarrays/SolutionTest.java b/src/test/java/g3701_3800/s3748_count_stable_subarrays/SolutionTest.java new file mode 100644 index 000000000..0e9447168 --- /dev/null +++ b/src/test/java/g3701_3800/s3748_count_stable_subarrays/SolutionTest.java @@ -0,0 +1,24 @@ +package g3701_3800.s3748_count_stable_subarrays; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countStableSubarrays() { + assertThat( + new Solution() + .countStableSubarrays( + new int[] {3, 1, 2}, new int[][] {{0, 1}, {1, 2}, {0, 2}}), + equalTo(new long[] {2L, 3L, 4L})); + } + + @Test + void countStableSubarrays2() { + assertThat( + new Solution().countStableSubarrays(new int[] {2, 2}, new int[][] {{0, 1}, {0, 0}}), + equalTo(new long[] {3L, 1L})); + } +} diff --git a/src/test/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/SolutionTest.java b/src/test/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/SolutionTest.java new file mode 100644 index 000000000..fc7954354 --- /dev/null +++ b/src/test/java/g3701_3800/s3750_minimum_number_of_flips_to_reverse_binary_string/SolutionTest.java @@ -0,0 +1,18 @@ +package g3701_3800.s3750_minimum_number_of_flips_to_reverse_binary_string; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minimumFlips() { + assertThat(new Solution().minimumFlips(7), equalTo(0)); + } + + @Test + void minimumFlips2() { + assertThat(new Solution().minimumFlips(10), equalTo(4)); + } +} diff --git a/src/test/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/SolutionTest.java b/src/test/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/SolutionTest.java new file mode 100644 index 000000000..d7d8b8df4 --- /dev/null +++ b/src/test/java/g3701_3800/s3751_total_waviness_of_numbers_in_range_i/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3751_total_waviness_of_numbers_in_range_i; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void totalWaviness() { + assertThat(new Solution().totalWaviness(120, 130), equalTo(3)); + } + + @Test + void totalWaviness2() { + assertThat(new Solution().totalWaviness(198, 202), equalTo(3)); + } + + @Test + void totalWaviness3() { + assertThat(new Solution().totalWaviness(4848, 4848), equalTo(2)); + } +} diff --git a/src/test/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/SolutionTest.java b/src/test/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/SolutionTest.java new file mode 100644 index 000000000..ce5a0370b --- /dev/null +++ b/src/test/java/g3701_3800/s3752_lexicographically_smallest_negated_permutation_that_sums_to_target/SolutionTest.java @@ -0,0 +1,18 @@ +package g3701_3800.s3752_lexicographically_smallest_negated_permutation_that_sums_to_target; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void lexSmallestNegatedPerm() { + assertThat(new Solution().lexSmallestNegatedPerm(3, 0L), equalTo(new int[] {-3, 1, 2})); + } + + @Test + void lexSmallestNegatedPerm2() { + assertThat(new Solution().lexSmallestNegatedPerm(3, 10000000000L), equalTo(new int[] {})); + } +} diff --git a/src/test/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/SolutionTest.java b/src/test/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/SolutionTest.java new file mode 100644 index 000000000..895b95607 --- /dev/null +++ b/src/test/java/g3701_3800/s3753_total_waviness_of_numbers_in_range_ii/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3753_total_waviness_of_numbers_in_range_ii; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void totalWaviness() { + assertThat(new Solution().totalWaviness(120L, 130L), equalTo(3L)); + } + + @Test + void totalWaviness2() { + assertThat(new Solution().totalWaviness(198L, 202L), equalTo(3L)); + } + + @Test + void totalWaviness3() { + assertThat(new Solution().totalWaviness(4848L, 4848L), equalTo(2L)); + } +} diff --git a/src/test/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/SolutionTest.java b/src/test/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/SolutionTest.java new file mode 100644 index 000000000..3b1c33b2c --- /dev/null +++ b/src/test/java/g3701_3800/s3754_concatenate_non_zero_digits_and_multiply_by_sum_i/SolutionTest.java @@ -0,0 +1,18 @@ +package g3701_3800.s3754_concatenate_non_zero_digits_and_multiply_by_sum_i; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void sumAndMultiply() { + assertThat(new Solution().sumAndMultiply(10203004), equalTo(12340L)); + } + + @Test + void sumAndMultiply2() { + assertThat(new Solution().sumAndMultiply(1000), equalTo(1L)); + } +} diff --git a/src/test/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/SolutionTest.java b/src/test/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/SolutionTest.java new file mode 100644 index 000000000..eac7b7c92 --- /dev/null +++ b/src/test/java/g3701_3800/s3755_find_maximum_balanced_xor_subarray_length/SolutionTest.java @@ -0,0 +1,20 @@ +package g3701_3800.s3755_find_maximum_balanced_xor_subarray_length; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maxBalancedSubarray() { + assertThat(new Solution().maxBalancedSubarray(new int[] {3, 1, 3, 2, 0}), equalTo(4)); + } + + @Test + void maxBalancedSubarray2() { + assertThat( + new Solution().maxBalancedSubarray(new int[] {3, 2, 8, 5, 4, 14, 9, 15}), + equalTo(8)); + } +} diff --git a/src/test/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/SolutionTest.java b/src/test/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/SolutionTest.java new file mode 100644 index 000000000..1d6dca34b --- /dev/null +++ b/src/test/java/g3701_3800/s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii/SolutionTest.java @@ -0,0 +1,29 @@ +package g3701_3800.s3756_concatenate_non_zero_digits_and_multiply_by_sum_ii; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void sumAndMultiply() { + assertThat( + new Solution().sumAndMultiply("10203004", new int[][] {{0, 7}, {1, 3}, {4, 6}}), + equalTo(new int[] {12340, 4, 9})); + } + + @Test + void sumAndMultiply2() { + assertThat( + new Solution().sumAndMultiply("1000", new int[][] {{0, 3}, {1, 1}}), + equalTo(new int[] {1, 0})); + } + + @Test + void sumAndMultiply3() { + assertThat( + new Solution().sumAndMultiply("9876543210", new int[][] {{0, 9}}), + equalTo(new int[] {444444137})); + } +} diff --git a/src/test/java/g3701_3800/s3757_number_of_effective_subsequences/SolutionTest.java b/src/test/java/g3701_3800/s3757_number_of_effective_subsequences/SolutionTest.java new file mode 100644 index 000000000..dcad582d8 --- /dev/null +++ b/src/test/java/g3701_3800/s3757_number_of_effective_subsequences/SolutionTest.java @@ -0,0 +1,28 @@ +package g3701_3800.s3757_number_of_effective_subsequences; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countEffective() { + assertThat(new Solution().countEffective(new int[] {1, 2, 3}), equalTo(3)); + } + + @Test + void countEffective2() { + assertThat(new Solution().countEffective(new int[] {7, 4, 6}), equalTo(4)); + } + + @Test + void countEffective3() { + assertThat(new Solution().countEffective(new int[] {8, 8}), equalTo(1)); + } + + @Test + void countEffective4() { + assertThat(new Solution().countEffective(new int[] {2, 2, 1}), equalTo(5)); + } +} diff --git a/src/test/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/SolutionTest.java b/src/test/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/SolutionTest.java new file mode 100644 index 000000000..f07f99274 --- /dev/null +++ b/src/test/java/g3701_3800/s3759_count_elements_with_at_least_k_greater_values/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3759_count_elements_with_at_least_k_greater_values; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countElements() { + assertThat(new Solution().countElements(new int[] {3, 1, 2}, 1), equalTo(2)); + } + + @Test + void countElements2() { + assertThat(new Solution().countElements(new int[] {5, 5, 5}, 2), equalTo(0)); + } + + @Test + void countElements3() { + assertThat(new Solution().countElements(new int[] {5, 5, 5}, 0), equalTo(3)); + } +} diff --git a/src/test/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/SolutionTest.java b/src/test/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/SolutionTest.java new file mode 100644 index 000000000..a2a375ff3 --- /dev/null +++ b/src/test/java/g3701_3800/s3760_maximum_substrings_with_distinct_start/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3760_maximum_substrings_with_distinct_start; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maxDistinct() { + assertThat(new Solution().maxDistinct("abca"), equalTo(3)); + } + + @Test + void maxDistinct2() { + assertThat(new Solution().maxDistinct("aaaa"), equalTo(1)); + } + + @Test + void maxDistinct3() { + assertThat(new Solution().maxDistinct("abcdefghijklmnopqrstuvwxyz"), equalTo(26)); + } +} diff --git a/src/test/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/SolutionTest.java b/src/test/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/SolutionTest.java new file mode 100644 index 000000000..e052f0d18 --- /dev/null +++ b/src/test/java/g3701_3800/s3761_minimum_absolute_distance_between_mirror_pairs/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3761_minimum_absolute_distance_between_mirror_pairs; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minMirrorPairDistance() { + assertThat(new Solution().minMirrorPairDistance(new int[] {12, 21}), equalTo(1)); + } + + @Test + void minMirrorPairDistance2() { + assertThat(new Solution().minMirrorPairDistance(new int[] {10, 1, 100}), equalTo(1)); + } + + @Test + void minMirrorPairDistance3() { + assertThat(new Solution().minMirrorPairDistance(new int[] {12, 34, 56}), equalTo(-1)); + } +} diff --git a/src/test/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/SolutionTest.java b/src/test/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/SolutionTest.java new file mode 100644 index 000000000..bd3eaa460 --- /dev/null +++ b/src/test/java/g3701_3800/s3762_minimum_operations_to_equalize_subarrays/SolutionTest.java @@ -0,0 +1,26 @@ +package g3701_3800.s3762_minimum_operations_to_equalize_subarrays; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minOperations() { + long[] result = new Solution().minOperations(new int[] {1, 3, 5}, 2, new int[][] {{0, 2}}); + assertThat(result[0], equalTo(2L)); + } + + @Test + void minOperations2() { + long[] result = new Solution().minOperations(new int[] {1, 3, 5}, 2, new int[][] {{0, 1}}); + assertThat(result[0], equalTo(1L)); + } + + @Test + void minOperations3() { + long[] result = new Solution().minOperations(new int[] {1, 2}, 2, new int[][] {{0, 1}}); + assertThat(result[0], equalTo(-1L)); + } +} diff --git a/src/test/java/g3701_3800/s3764_most_common_course_pairs/MysqlTest.java b/src/test/java/g3701_3800/s3764_most_common_course_pairs/MysqlTest.java new file mode 100644 index 000000000..874284821 --- /dev/null +++ b/src/test/java/g3701_3800/s3764_most_common_course_pairs/MysqlTest.java @@ -0,0 +1,94 @@ +package g3701_3800.s3764_most_common_course_pairs; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import javax.sql.DataSource; +import org.junit.jupiter.api.Test; +import org.zapodot.junit.db.annotations.EmbeddedDatabase; +import org.zapodot.junit.db.annotations.EmbeddedDatabaseTest; +import org.zapodot.junit.db.common.CompatibilityMode; + +@EmbeddedDatabaseTest( + compatibilityMode = CompatibilityMode.MySQL, + initialSqls = + "CREATE TABLE course_completions (" + + " user_id INTEGER," + + " course_id INTEGER," + + " course_name VARCHAR(512)," + + " completion_date DATE," + + " course_rating INTEGER," + + " PRIMARY KEY (user_id, course_id)" + + ");" + + "INSERT INTO course_completions (user_id, course_id, course_name, completion_date," + + " course_rating) VALUES" + + "(1, 101, 'Python Basics', '2024-01-05', 5)," + + "(1, 102, 'SQL Fundamentals', '2024-02-10', 4)," + + "(1, 103, 'JavaScript', '2024-03-15', 5)," + + "(1, 104, 'React Basics', '2024-04-20', 4)," + + "(1, 105, 'Node.js', '2024-05-25', 5)," + + "(1, 106, 'Docker', '2024-06-30', 4)," + + "(2, 101, 'Python Basics', '2024-01-08', 4)," + + "(2, 104, 'React Basics', '2024-02-14', 5)," + + "(2, 105, 'Node.js', '2024-03-20', 4)," + + "(2, 106, 'Docker', '2024-04-25', 5)," + + "(2, 107, 'AWS Fundamentals', '2024-05-30', 4)," + + "(3, 101, 'Python Basics', '2024-01-10', 3)," + + "(3, 102, 'SQL Fundamentals', '2024-02-12', 3)," + + "(3, 103, 'JavaScript', '2024-03-18', 3)," + + "(3, 104, 'React Basics', '2024-04-22', 2)," + + "(3, 105, 'Node.js', '2024-05-28', 3)," + + "(4, 101, 'Python Basics', '2024-01-12', 5)," + + "(4, 108, 'Data Science', '2024-02-16', 5)," + + "(4, 109, 'Machine Learning', '2024-03-22', 5);") +class MysqlTest { + @Test + void testScript(@EmbeddedDatabase DataSource dataSource) + throws SQLException, FileNotFoundException { + try (final Connection connection = dataSource.getConnection()) { + try (final Statement statement = connection.createStatement(); + final ResultSet resultSet = + statement.executeQuery( + new BufferedReader( + new FileReader( + "src/main/java/g3701_3800/" + + "s3764_most_common_course_pairs/" + + "script.sql")) + .lines() + .collect(Collectors.joining("\n")) + .replaceAll("#.*?\\r?\\n", ""))) { + List actualRows = new ArrayList<>(); + while (resultSet.next()) { + actualRows.add( + resultSet.getString(1) + + "|" + + resultSet.getString(2) + + "|" + + resultSet.getString(3)); + } + + List expectedRows = + Arrays.asList( + "Node.js|Docker|2", + "React Basics|Node.js|2", + "Docker|AWS Fundamentals|1", + "JavaScript|React Basics|1", + "Python Basics|React Basics|1", + "Python Basics|SQL Fundamentals|1", + "SQL Fundamentals|JavaScript|1"); + assertThat(actualRows, equalTo(expectedRows)); + } + } + } +} diff --git a/src/test/java/g3701_3800/s3765_complete_prime_number/SolutionTest.java b/src/test/java/g3701_3800/s3765_complete_prime_number/SolutionTest.java new file mode 100644 index 000000000..b1e3478a0 --- /dev/null +++ b/src/test/java/g3701_3800/s3765_complete_prime_number/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3765_complete_prime_number; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void completePrime() { + assertThat(new Solution().completePrime(239), equalTo(false)); + } + + @Test + void completePrime2() { + assertThat(new Solution().completePrime(21), equalTo(false)); + } + + @Test + void completePrime3() { + assertThat(new Solution().completePrime(2), equalTo(true)); + } +} diff --git a/src/test/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/SolutionTest.java b/src/test/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/SolutionTest.java new file mode 100644 index 000000000..e0113c123 --- /dev/null +++ b/src/test/java/g3701_3800/s3766_minimum_operations_to_make_binary_palindrome/SolutionTest.java @@ -0,0 +1,31 @@ +package g3701_3800.s3766_minimum_operations_to_make_binary_palindrome; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minOperations() { + int[] result = new Solution().minOperations(new int[] {5, 6, 7}); + assertThat(result[0], equalTo(0)); + assertThat(result[1], equalTo(1)); + assertThat(result[2], equalTo(0)); + } + + @Test + void minOperations2() { + int[] result = new Solution().minOperations(new int[] {10}); + assertThat(result[0], equalTo(1)); + } + + @Test + void minOperations3() { + int[] result = new Solution().minOperations(new int[] {1, 2, 3, 4}); + assertThat(result[0], equalTo(0)); + assertThat(result[1], equalTo(1)); + assertThat(result[2], equalTo(0)); + assertThat(result[3], equalTo(1)); + } +} diff --git a/src/test/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/SolutionTest.java b/src/test/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/SolutionTest.java new file mode 100644 index 000000000..fe39fda45 --- /dev/null +++ b/src/test/java/g3701_3800/s3767_maximize_points_after_choosing_k_tasks/SolutionTest.java @@ -0,0 +1,62 @@ +package g3701_3800.s3767_maximize_points_after_choosing_k_tasks; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maxPoints() { + assertThat( + new Solution().maxPoints(new int[] {5, 1, 3}, new int[] {4, 10, 2}, 1), + equalTo(18L)); + } + + @Test + void maxPoints2() { + assertThat(new Solution().maxPoints(new int[] {1, 2}, new int[] {3, 4}, 0), equalTo(7L)); + } + + @Test + void maxPoints3() { + assertThat( + new Solution().maxPoints(new int[] {7, 2, 5}, new int[] {1, 8, 4}, 3), + equalTo(14L)); + } + + @Test + void maxPoints4() { + assertThat( + new Solution().maxPoints(new int[] {5, 4, 3}, new int[] {3, 4, 1}, 3), + equalTo(12L)); + } + + @Test + void maxPoints5() { + assertThat( + new Solution().maxPoints(new int[] {1, 2, 3}, new int[] {5, 5, 1}, 1), + equalTo(13L)); + } + + @Test + void maxPoints6() { + assertThat( + new Solution().maxPoints(new int[] {1, 1, 1, 1}, new int[] {3, 4, 2, 6}, 2), + equalTo(12L)); + } + + @Test + void maxPoints7() { + assertThat( + new Solution().maxPoints(new int[] {1, 1, 1, 1}, new int[] {6, 5, 4, 0}, 2), + equalTo(13L)); + } + + @Test + void maxPoints8() { + assertThat( + new Solution().maxPoints(new int[] {7, 8, 9}, new int[] {100, 100, 100}, 3), + equalTo(24L)); + } +} diff --git a/src/test/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/SolutionTest.java b/src/test/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/SolutionTest.java new file mode 100644 index 000000000..60ca5c1e0 --- /dev/null +++ b/src/test/java/g3701_3800/s3768_minimum_inversion_count_in_subarrays_of_fixed_length/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3768_minimum_inversion_count_in_subarrays_of_fixed_length; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minInversionCount() { + assertThat(new Solution().minInversionCount(new int[] {3, 1, 2}, 2), equalTo(0L)); + } + + @Test + void minInversionCount2() { + assertThat(new Solution().minInversionCount(new int[] {3, 2, 1}, 3), equalTo(3L)); + } + + @Test + void minInversionCount3() { + assertThat(new Solution().minInversionCount(new int[] {1, 2, 3, 4}, 2), equalTo(0L)); + } +} diff --git a/src/test/java/g3701_3800/s3769_sort_integers_by_binary_reflection/SolutionTest.java b/src/test/java/g3701_3800/s3769_sort_integers_by_binary_reflection/SolutionTest.java new file mode 100644 index 000000000..88d8e9ac5 --- /dev/null +++ b/src/test/java/g3701_3800/s3769_sort_integers_by_binary_reflection/SolutionTest.java @@ -0,0 +1,31 @@ +package g3701_3800.s3769_sort_integers_by_binary_reflection; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void sortByReflection() { + int[] result = new Solution().sortByReflection(new int[] {1, 2, 3}); + assertThat(result[0], equalTo(1)); + assertThat(result[1], equalTo(2)); + assertThat(result[2], equalTo(3)); + } + + @Test + void sortByReflection2() { + int[] result = new Solution().sortByReflection(new int[] {0, 1, 2}); + assertThat(result[0], equalTo(0)); + assertThat(result[1], equalTo(1)); + assertThat(result[2], equalTo(2)); + } + + @Test + void sortByReflection3() { + int[] result = new Solution().sortByReflection(new int[] {6, 9}); + assertThat(result[0], equalTo(6)); + assertThat(result[1], equalTo(9)); + } +} diff --git a/src/test/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/SolutionTest.java b/src/test/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/SolutionTest.java new file mode 100644 index 000000000..be82bfa3a --- /dev/null +++ b/src/test/java/g3701_3800/s3770_largest_prime_from_consecutive_prime_sum/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3770_largest_prime_from_consecutive_prime_sum; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void largestPrime() { + assertThat(new Solution().largestPrime(100), equalTo(41)); + } + + @Test + void largestPrime2() { + assertThat(new Solution().largestPrime(2), equalTo(2)); + } + + @Test + void largestPrime3() { + assertThat(new Solution().largestPrime(1), equalTo(0)); + } +} diff --git a/src/test/java/g3701_3800/s3771_total_score_of_dungeon_runs/SolutionTest.java b/src/test/java/g3701_3800/s3771_total_score_of_dungeon_runs/SolutionTest.java new file mode 100644 index 000000000..d95b9c12d --- /dev/null +++ b/src/test/java/g3701_3800/s3771_total_score_of_dungeon_runs/SolutionTest.java @@ -0,0 +1,21 @@ +package g3701_3800.s3771_total_score_of_dungeon_runs; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void totalScore() { + assertThat( + new Solution().totalScore(11, new int[] {3, 6, 7}, new int[] {4, 2, 5}), + equalTo(3L)); + } + + @Test + void totalScore2() { + assertThat( + new Solution().totalScore(2, new int[] {10000, 1}, new int[] {1, 1}), equalTo(1L)); + } +} diff --git a/src/test/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/SolutionTest.java b/src/test/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/SolutionTest.java new file mode 100644 index 000000000..048e211ba --- /dev/null +++ b/src/test/java/g3701_3800/s3772_maximum_subgraph_score_in_a_tree/SolutionTest.java @@ -0,0 +1,34 @@ +package g3701_3800.s3772_maximum_subgraph_score_in_a_tree; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maxSubgraphScore() { + assertThat( + new Solution() + .maxSubgraphScore(3, new int[][] {{0, 1}, {1, 2}}, new int[] {1, 0, 1}), + equalTo(new int[] {1, 1, 1})); + } + + @Test + void maxSubgraphScore2() { + assertThat( + new Solution() + .maxSubgraphScore( + 5, + new int[][] {{1, 0}, {1, 2}, {1, 3}, {3, 4}}, + new int[] {0, 1, 0, 1, 1}), + equalTo(new int[] {2, 3, 2, 3, 3})); + } + + @Test + void maxSubgraphScore3() { + assertThat( + new Solution().maxSubgraphScore(2, new int[][] {{0, 1}}, new int[] {0, 0}), + equalTo(new int[] {-1, -1})); + } +} diff --git a/src/test/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/SolutionTest.java b/src/test/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/SolutionTest.java new file mode 100644 index 000000000..379b26e57 --- /dev/null +++ b/src/test/java/g3701_3800/s3774_absolute_difference_between_maximum_and_minimum_k_elements/SolutionTest.java @@ -0,0 +1,18 @@ +package g3701_3800.s3774_absolute_difference_between_maximum_and_minimum_k_elements; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void absDifference() { + assertThat(new Solution().absDifference(new int[] {5, 2, 2, 4}, 2), equalTo(5)); + } + + @Test + void absDifference2() { + assertThat(new Solution().absDifference(new int[] {100}, 1), equalTo(0)); + } +} diff --git a/src/test/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/SolutionTest.java b/src/test/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/SolutionTest.java new file mode 100644 index 000000000..4fa4491a0 --- /dev/null +++ b/src/test/java/g3701_3800/s3775_reverse_words_with_same_vowel_count/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3775_reverse_words_with_same_vowel_count; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void reverseWords() { + assertThat(new Solution().reverseWords("cat and mice"), equalTo("cat dna mice")); + } + + @Test + void reverseWords2() { + assertThat(new Solution().reverseWords("book is nice"), equalTo("book is ecin")); + } + + @Test + void reverseWords3() { + assertThat(new Solution().reverseWords("banana healthy"), equalTo("banana healthy")); + } +} diff --git a/src/test/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/SolutionTest.java b/src/test/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/SolutionTest.java new file mode 100644 index 000000000..520f095eb --- /dev/null +++ b/src/test/java/g3701_3800/s3776_minimum_moves_to_balance_circular_array/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3776_minimum_moves_to_balance_circular_array; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minMoves() { + assertThat(new Solution().minMoves(new int[] {5, 1, -4}), equalTo(4L)); + } + + @Test + void minMoves2() { + assertThat(new Solution().minMoves(new int[] {1, 2, -5, 2}), equalTo(6L)); + } + + @Test + void minMoves3() { + assertThat(new Solution().minMoves(new int[] {-3, 2}), equalTo(-1L)); + } +} diff --git a/src/test/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/SolutionTest.java b/src/test/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/SolutionTest.java new file mode 100644 index 000000000..7c01f6150 --- /dev/null +++ b/src/test/java/g3701_3800/s3777_minimum_deletions_to_make_alternating_substring/SolutionTest.java @@ -0,0 +1,108 @@ +package g3701_3800.s3777_minimum_deletions_to_make_alternating_substring; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minDeletions() { + assertThat( + new Solution().minDeletions("ABA", new int[][] {{2, 1, 2}, {1, 1}, {2, 0, 2}}), + equalTo(new int[] {0, 2})); + } + + @Test + void minDeletions2() { + assertThat( + new Solution().minDeletions("ABB", new int[][] {{2, 0, 2}, {1, 2}, {2, 0, 2}}), + equalTo(new int[] {1, 0})); + } + + @Test + void minDeletions3() { + assertThat( + new Solution().minDeletions("BABA", new int[][] {{2, 0, 3}, {1, 1}, {2, 1, 3}}), + equalTo(new int[] {0, 1})); + } + + @Test + void minDeletions4() { + // j == 0, tests j > 0 false branch + // "AAB" -> flip index 0 -> "BAB" + assertThat( + new Solution().minDeletions("AAB", new int[][] {{2, 0, 2}, {1, 0}, {2, 0, 2}}), + equalTo(new int[] {1, 0})); + } + + @Test + void minDeletions5() { + // j == n-1, tests j + 1 < n false branch + // "ABB" -> flip index 2 -> "ABA" + assertThat( + new Solution().minDeletions("ABB", new int[][] {{2, 0, 2}, {1, 2}, {2, 0, 2}}), + equalTo(new int[] {1, 0})); + } + + @Test + void minDeletions6() { + // tests a[j] == 'A' false branch (i.e., 'B' -> 'A') + // "BAA" -> flip index 0 (B) -> "AAA" + assertThat( + new Solution().minDeletions("BAA", new int[][] {{2, 0, 2}, {1, 0}, {2, 0, 2}}), + equalTo(new int[] {1, 2})); + } + + @Test + void minDeletions7() { + // tests a[j] == 'A' true branch + // "AAA" -> flip index 1 -> "ABA" + assertThat( + new Solution().minDeletions("AAA", new int[][] {{2, 0, 2}, {1, 1}, {2, 0, 2}}), + equalTo(new int[] {2, 0})); + } + + @Test + void minDeletions8() { + // tests l < r false branch + assertThat( + new Solution().minDeletions("AAB", new int[][] {{2, 1, 1}, {2, 0, 0}}), + equalTo(new int[] {0, 0})); + } + + @Test + void minDeletions9() { + // larger string to exercise BIT loops more + // "AABBA" -> pairs at index 0 (AA), 2 (BB) + assertThat( + new Solution() + .minDeletions( + "AABBA", + new int[][] { + {2, 0, 4}, {1, 2}, {2, 0, 4}, {1, 0}, {2, 0, 4}, {2, 1, 3} + }), + equalTo(new int[] {2, 2, 1, 1})); + } + + @Test + void minDeletions10() { + // All neighbor pairs match + // "AAAA" -> flip middle to break/create pairs + assertThat( + new Solution() + .minDeletions( + "AAAA", new int[][] {{2, 0, 3}, {1, 2}, {2, 0, 3}, {2, 0, 1}}), + equalTo(new int[] {3, 1, 1})); + } + + @Test + void minDeletions11() { + // No initial neighbor pairs - covers a[i] == a[i+1] false branch dominantly + assertThat( + new Solution() + .minDeletions( + "ABABAB", new int[][] {{2, 0, 5}, {1, 3}, {2, 0, 5}, {2, 2, 4}}), + equalTo(new int[] {0, 2, 2})); + } +} diff --git a/src/test/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/SolutionTest.java b/src/test/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/SolutionTest.java new file mode 100644 index 000000000..758cedfa7 --- /dev/null +++ b/src/test/java/g3701_3800/s3779_minimum_number_of_operations_to_have_distinct_elements/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3779_minimum_number_of_operations_to_have_distinct_elements; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minOperations() { + assertThat(new Solution().minOperations(new int[] {3, 8, 3, 6, 5, 8}), equalTo(1)); + } + + @Test + void minOperations2() { + assertThat(new Solution().minOperations(new int[] {2, 2}), equalTo(1)); + } + + @Test + void minOperations3() { + assertThat(new Solution().minOperations(new int[] {4, 3, 5, 1, 2}), equalTo(0)); + } +} diff --git a/src/test/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/SolutionTest.java b/src/test/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/SolutionTest.java new file mode 100644 index 000000000..54a0a6a6d --- /dev/null +++ b/src/test/java/g3701_3800/s3780_maximum_sum_of_three_numbers_divisible_by_three/SolutionTest.java @@ -0,0 +1,18 @@ +package g3701_3800.s3780_maximum_sum_of_three_numbers_divisible_by_three; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maximumSum() { + assertThat(new Solution().maximumSum(new int[] {4, 2, 3, 1}), equalTo(9)); + } + + @Test + void maximumSum2() { + assertThat(new Solution().maximumSum(new int[] {2, 1, 5}), equalTo(0)); + } +} diff --git a/src/test/java/g3701_3800/s3781_maximum_score_after_binary_swaps/SolutionTest.java b/src/test/java/g3701_3800/s3781_maximum_score_after_binary_swaps/SolutionTest.java new file mode 100644 index 000000000..dbe6b4895 --- /dev/null +++ b/src/test/java/g3701_3800/s3781_maximum_score_after_binary_swaps/SolutionTest.java @@ -0,0 +1,18 @@ +package g3701_3800.s3781_maximum_score_after_binary_swaps; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maximumScore() { + assertThat(new Solution().maximumScore(new int[] {2, 1, 5, 2, 3}, "01010"), equalTo(7L)); + } + + @Test + void maximumScore2() { + assertThat(new Solution().maximumScore(new int[] {4, 7, 2, 9}, "0000"), equalTo(0L)); + } +} diff --git a/src/test/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/SolutionTest.java b/src/test/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/SolutionTest.java new file mode 100644 index 000000000..6ac50cda0 --- /dev/null +++ b/src/test/java/g3701_3800/s3782_last_remaining_integer_after_alternating_deletion_operations/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3782_last_remaining_integer_after_alternating_deletion_operations; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void lastInteger() { + assertThat(new Solution().lastInteger(8L), equalTo(3L)); + } + + @Test + void lastInteger2() { + assertThat(new Solution().lastInteger(5L), equalTo(1L)); + } + + @Test + void lastInteger3() { + assertThat(new Solution().lastInteger(1L), equalTo(1L)); + } +} diff --git a/src/test/java/g3701_3800/s3783_mirror_distance_of_an_integer/SolutionTest.java b/src/test/java/g3701_3800/s3783_mirror_distance_of_an_integer/SolutionTest.java new file mode 100644 index 000000000..5269219d1 --- /dev/null +++ b/src/test/java/g3701_3800/s3783_mirror_distance_of_an_integer/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3783_mirror_distance_of_an_integer; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void mirrorDistance() { + assertThat(new Solution().mirrorDistance(25), equalTo(27)); + } + + @Test + void mirrorDistance2() { + assertThat(new Solution().mirrorDistance(10), equalTo(9)); + } + + @Test + void mirrorDistance3() { + assertThat(new Solution().mirrorDistance(7), equalTo(0)); + } +} diff --git a/src/test/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/SolutionTest.java b/src/test/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/SolutionTest.java new file mode 100644 index 000000000..340d9b555 --- /dev/null +++ b/src/test/java/g3701_3800/s3784_minimum_deletion_cost_to_make_all_characters_equal/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3784_minimum_deletion_cost_to_make_all_characters_equal; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minCost() { + assertThat(new Solution().minCost("aabaac", new int[] {1, 2, 3, 4, 1, 10}), equalTo(11L)); + } + + @Test + void minCost2() { + assertThat(new Solution().minCost("abc", new int[] {10, 5, 8}), equalTo(13L)); + } + + @Test + void minCost3() { + assertThat(new Solution().minCost("zzzzz", new int[] {67, 67, 67, 67, 67}), equalTo(0L)); + } +} diff --git a/src/test/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/SolutionTest.java b/src/test/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/SolutionTest.java new file mode 100644 index 000000000..f62722b8d --- /dev/null +++ b/src/test/java/g3701_3800/s3785_minimum_swaps_to_avoid_forbidden_values/SolutionTest.java @@ -0,0 +1,30 @@ +package g3701_3800.s3785_minimum_swaps_to_avoid_forbidden_values; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minSwaps() { + assertThat(new Solution().minSwaps(new int[] {1, 2, 3}, new int[] {3, 2, 1}), equalTo(1)); + } + + @Test + void minSwaps2() { + assertThat( + new Solution().minSwaps(new int[] {4, 6, 6, 5}, new int[] {4, 6, 5, 5}), + equalTo(2)); + } + + @Test + void minSwaps3() { + assertThat(new Solution().minSwaps(new int[] {7, 7}, new int[] {8, 7}), equalTo(-1)); + } + + @Test + void minSwaps4() { + assertThat(new Solution().minSwaps(new int[] {1, 2}, new int[] {2, 1}), equalTo(0)); + } +} diff --git a/src/test/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/SolutionTest.java b/src/test/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/SolutionTest.java new file mode 100644 index 000000000..612c39f55 --- /dev/null +++ b/src/test/java/g3701_3800/s3786_total_sum_of_interaction_cost_in_tree_groups/SolutionTest.java @@ -0,0 +1,40 @@ +package g3701_3800.s3786_total_sum_of_interaction_cost_in_tree_groups; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void interactionCosts() { + assertThat( + new Solution() + .interactionCosts(3, new int[][] {{0, 1}, {1, 2}}, new int[] {1, 1, 1}), + equalTo(4L)); + } + + @Test + void interactionCosts2() { + assertThat( + new Solution() + .interactionCosts(3, new int[][] {{0, 1}, {1, 2}}, new int[] {3, 2, 3}), + equalTo(2L)); + } + + @Test + void interactionCosts3() { + assertThat( + new Solution() + .interactionCosts( + 4, new int[][] {{0, 1}, {0, 2}, {0, 3}}, new int[] {1, 1, 4, 4}), + equalTo(3L)); + } + + @Test + void interactionCosts4() { + assertThat( + new Solution().interactionCosts(2, new int[][] {{0, 1}}, new int[] {9, 8}), + equalTo(0L)); + } +} diff --git a/src/test/java/g3701_3800/s3788_maximum_score_of_a_split/SolutionTest.java b/src/test/java/g3701_3800/s3788_maximum_score_of_a_split/SolutionTest.java new file mode 100644 index 000000000..488eb2d06 --- /dev/null +++ b/src/test/java/g3701_3800/s3788_maximum_score_of_a_split/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3788_maximum_score_of_a_split; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void maximumScore() { + assertThat(new Solution().maximumScore(new int[] {10, -1, 3, -4, -5}), equalTo(17L)); + } + + @Test + void maximumScore2() { + assertThat(new Solution().maximumScore(new int[] {-7, -5, 3}), equalTo(-2L)); + } + + @Test + void maximumScore3() { + assertThat(new Solution().maximumScore(new int[] {1, 1}), equalTo(0L)); + } +} diff --git a/src/test/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/SolutionTest.java b/src/test/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/SolutionTest.java new file mode 100644 index 000000000..82a47d855 --- /dev/null +++ b/src/test/java/g3701_3800/s3789_minimum_cost_to_acquire_required_items/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3789_minimum_cost_to_acquire_required_items; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minimumCost() { + assertThat(new Solution().minimumCost(3, 2, 1, 3, 2), equalTo(3L)); + } + + @Test + void minimumCost2() { + assertThat(new Solution().minimumCost(5, 4, 15, 2, 3), equalTo(22L)); + } + + @Test + void minimumCost3() { + assertThat(new Solution().minimumCost(5, 4, 15, 0, 0), equalTo(0L)); + } +} diff --git a/src/test/java/g3701_3800/s3790_smallest_all_ones_multiple/SolutionTest.java b/src/test/java/g3701_3800/s3790_smallest_all_ones_multiple/SolutionTest.java new file mode 100644 index 000000000..fa7d6d4f5 --- /dev/null +++ b/src/test/java/g3701_3800/s3790_smallest_all_ones_multiple/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3790_smallest_all_ones_multiple; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minAllOneMultiple() { + assertThat(new Solution().minAllOneMultiple(3), equalTo(3)); + } + + @Test + void minAllOneMultiple2() { + assertThat(new Solution().minAllOneMultiple(7), equalTo(6)); + } + + @Test + void minAllOneMultiple3() { + assertThat(new Solution().minAllOneMultiple(2), equalTo(-1)); + } +} diff --git a/src/test/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/SolutionTest.java b/src/test/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/SolutionTest.java new file mode 100644 index 000000000..cc0019291 --- /dev/null +++ b/src/test/java/g3701_3800/s3791_number_of_balanced_integers_in_a_range/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3791_number_of_balanced_integers_in_a_range; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countBalanced() { + assertThat(new Solution().countBalanced(1, 100), equalTo(9L)); + } + + @Test + void countBalanced2() { + assertThat(new Solution().countBalanced(120, 129), equalTo(1L)); + } + + @Test + void countBalanced3() { + assertThat(new Solution().countBalanced(1234, 1234), equalTo(0L)); + } +} diff --git a/src/test/java/g3701_3800/s3793_find_users_with_high_token_usage/MysqlTest.java b/src/test/java/g3701_3800/s3793_find_users_with_high_token_usage/MysqlTest.java new file mode 100644 index 000000000..63d0903a8 --- /dev/null +++ b/src/test/java/g3701_3800/s3793_find_users_with_high_token_usage/MysqlTest.java @@ -0,0 +1,73 @@ +package g3701_3800.s3793_find_users_with_high_token_usage; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import javax.sql.DataSource; +import org.junit.jupiter.api.Test; +import org.zapodot.junit.db.annotations.EmbeddedDatabase; +import org.zapodot.junit.db.annotations.EmbeddedDatabaseTest; +import org.zapodot.junit.db.common.CompatibilityMode; + +@EmbeddedDatabaseTest( + compatibilityMode = CompatibilityMode.MySQL, + initialSqls = + "CREATE TABLE prompts (" + + " user_id INTEGER," + + " prompt VARCHAR(512)," + + " tokens INTEGER," + + " PRIMARY KEY (user_id, prompt)" + + ");" + + "INSERT INTO prompts (user_id, prompt, tokens) VALUES" + + "(1, 'Write a blog outline', 120)," + + "(1, 'Generate SQL query', 80)," + + "(1, 'Summarize an article', 200)," + + "(2, 'Create resume bullet', 60)," + + "(2, 'Improve LinkedIn bio', 70)," + + "(3, 'Explain neural networks', 300)," + + "(3, 'Generate interview Q&A', 250)," + + "(3, 'Write cover letter', 180)," + + "(3, 'Optimize Python code', 220);") +class MysqlTest { + @Test + void testScript(@EmbeddedDatabase DataSource dataSource) + throws SQLException, FileNotFoundException { + try (final Connection connection = dataSource.getConnection()) { + try (final Statement statement = connection.createStatement(); + final ResultSet resultSet = + statement.executeQuery( + new BufferedReader( + new FileReader( + "src/main/java/g3701_3800/" + + "s3793_find_users_with_high_token_usage/" + + "script.sql")) + .lines() + .collect(Collectors.joining("\n")) + .replaceAll("#.*?\\r?\\n", ""))) { + List actualRows = new ArrayList<>(); + while (resultSet.next()) { + actualRows.add( + resultSet.getString(1) + + "|" + + resultSet.getString(2) + + "|" + + resultSet.getString(3)); + } + + List expectedRows = Arrays.asList("3|4|237.5", "1|3|133.33"); + assertThat(actualRows, equalTo(expectedRows)); + } + } + } +} diff --git a/src/test/java/g3701_3800/s3794_reverse_string_prefix/SolutionTest.java b/src/test/java/g3701_3800/s3794_reverse_string_prefix/SolutionTest.java new file mode 100644 index 000000000..921f2eb96 --- /dev/null +++ b/src/test/java/g3701_3800/s3794_reverse_string_prefix/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3794_reverse_string_prefix; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void reversePrefix() { + assertThat(new Solution().reversePrefix("abcd", 2), equalTo("bacd")); + } + + @Test + void reversePrefix2() { + assertThat(new Solution().reversePrefix("xyz", 3), equalTo("zyx")); + } + + @Test + void reversePrefix3() { + assertThat(new Solution().reversePrefix("hey", 1), equalTo("hey")); + } +} diff --git a/src/test/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/SolutionTest.java b/src/test/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/SolutionTest.java new file mode 100644 index 000000000..75aab4dd9 --- /dev/null +++ b/src/test/java/g3701_3800/s3795_minimum_subarray_length_with_distinct_sum_at_least_k/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3795_minimum_subarray_length_with_distinct_sum_at_least_k; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minLength() { + assertThat(new Solution().minLength(new int[] {2, 2, 3, 1}, 4), equalTo(2)); + } + + @Test + void minLength2() { + assertThat(new Solution().minLength(new int[] {3, 2, 3, 4}, 5), equalTo(2)); + } + + @Test + void minLength3() { + assertThat(new Solution().minLength(new int[] {5, 5, 4}, 5), equalTo(1)); + } +} diff --git a/src/test/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/SolutionTest.java b/src/test/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/SolutionTest.java new file mode 100644 index 000000000..d1f5e30af --- /dev/null +++ b/src/test/java/g3701_3800/s3796_find_maximum_value_in_a_constrained_sequence/SolutionTest.java @@ -0,0 +1,26 @@ +package g3701_3800.s3796_find_maximum_value_in_a_constrained_sequence; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void findMaxVal() { + assertThat( + new Solution() + .findMaxVal( + 10, + new int[][] {{3, 1}, {8, 1}}, + new int[] {2, 2, 3, 1, 4, 5, 1, 1, 2}), + equalTo(6)); + } + + @Test + void findMaxVal2() { + assertThat( + new Solution().findMaxVal(8, new int[][] {{3, 2}}, new int[] {3, 5, 2, 4, 2, 3, 1}), + equalTo(12)); + } +} diff --git a/src/test/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/SolutionTest.java b/src/test/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/SolutionTest.java new file mode 100644 index 000000000..dc8aae9cb --- /dev/null +++ b/src/test/java/g3701_3800/s3797_count_routes_to_climb_a_rectangular_grid/SolutionTest.java @@ -0,0 +1,28 @@ +package g3701_3800.s3797_count_routes_to_climb_a_rectangular_grid; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void numberOfRoutes() { + assertThat(new Solution().numberOfRoutes(new String[] {"..", "#."}, 1), equalTo(2)); + } + + @Test + void numberOfRoutes2() { + assertThat(new Solution().numberOfRoutes(new String[] {"..", "#."}, 2), equalTo(4)); + } + + @Test + void numberOfRoutes3() { + assertThat(new Solution().numberOfRoutes(new String[] {"#"}, 750), equalTo(0)); + } + + @Test + void numberOfRoutes4() { + assertThat(new Solution().numberOfRoutes(new String[] {".."}, 1), equalTo(4)); + } +} diff --git a/src/test/java/g3701_3800/s3798_largest_even_number/SolutionTest.java b/src/test/java/g3701_3800/s3798_largest_even_number/SolutionTest.java new file mode 100644 index 000000000..529a91bbd --- /dev/null +++ b/src/test/java/g3701_3800/s3798_largest_even_number/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3798_largest_even_number; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void largestEven() { + assertThat(new Solution().largestEven("1112"), equalTo("1112")); + } + + @Test + void largestEven2() { + assertThat(new Solution().largestEven("221"), equalTo("22")); + } + + @Test + void largestEven3() { + assertThat(new Solution().largestEven("1"), equalTo("")); + } +} diff --git a/src/test/java/g3701_3800/s3799_word_squares_ii/SolutionTest.java b/src/test/java/g3701_3800/s3799_word_squares_ii/SolutionTest.java new file mode 100644 index 000000000..27aad4968 --- /dev/null +++ b/src/test/java/g3701_3800/s3799_word_squares_ii/SolutionTest.java @@ -0,0 +1,29 @@ +package g3701_3800.s3799_word_squares_ii; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void wordSquares() { + List> result = + new Solution().wordSquares(new String[] {"able", "area", "echo", "also"}); + assertThat( + result, + equalTo( + Arrays.asList( + Arrays.asList("able", "area", "echo", "also"), + Arrays.asList("area", "able", "also", "echo")))); + } + + @Test + void wordSquares2() { + assertThat( + new Solution().wordSquares(new String[] {"code", "cafe", "eden", "edge"}), + equalTo(Arrays.asList())); + } +} diff --git a/src/test/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/SolutionTest.java b/src/test/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/SolutionTest.java new file mode 100644 index 000000000..0c160a72b --- /dev/null +++ b/src/test/java/g3701_3800/s3800_minimum_cost_to_make_two_binary_strings_equal/SolutionTest.java @@ -0,0 +1,23 @@ +package g3701_3800.s3800_minimum_cost_to_make_two_binary_strings_equal; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minimumCost() { + assertThat(new Solution().minimumCost("01000", "10111", 10, 2, 2), equalTo(16L)); + } + + @Test + void minimumCost2() { + assertThat(new Solution().minimumCost("001", "110", 2, 100, 100), equalTo(6L)); + } + + @Test + void minimumCost3() { + assertThat(new Solution().minimumCost("1010", "1010", 5, 5, 5), equalTo(0L)); + } +} diff --git a/src/test/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/SolutionTest.java b/src/test/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/SolutionTest.java new file mode 100644 index 000000000..99b2cf30d --- /dev/null +++ b/src/test/java/g3801_3900/s3801_minimum_cost_to_merge_sorted_lists/SolutionTest.java @@ -0,0 +1,31 @@ +package g3801_3900.s3801_minimum_cost_to_merge_sorted_lists; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void minMergeCost() { + assertThat( + new Solution().minMergeCost(new int[][] {{1, 3, 5}, {2, 4}, {6, 7, 8}}), + equalTo(18L)); + } + + @Test + void minMergeCost2() { + assertThat( + new Solution().minMergeCost(new int[][] {{1, 1, 5}, {1, 4, 7, 8}}), equalTo(10L)); + } + + @Test + void minMergeCost3() { + assertThat(new Solution().minMergeCost(new int[][] {{1}, {3}}), equalTo(4L)); + } + + @Test + void minMergeCost4() { + assertThat(new Solution().minMergeCost(new int[][] {{1}, {1}}), equalTo(2L)); + } +} diff --git a/src/test/java/g3801_3900/s3803_count_residue_prefixes/SolutionTest.java b/src/test/java/g3801_3900/s3803_count_residue_prefixes/SolutionTest.java new file mode 100644 index 000000000..d09c3f3f6 --- /dev/null +++ b/src/test/java/g3801_3900/s3803_count_residue_prefixes/SolutionTest.java @@ -0,0 +1,23 @@ +package g3801_3900.s3803_count_residue_prefixes; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void residuePrefixes() { + assertThat(new Solution().residuePrefixes("abc"), equalTo(2)); + } + + @Test + void residuePrefixes2() { + assertThat(new Solution().residuePrefixes("dd"), equalTo(1)); + } + + @Test + void residuePrefixes3() { + assertThat(new Solution().residuePrefixes("bob"), equalTo(2)); + } +} diff --git a/src/test/java/g3801_3900/s3804_number_of_centered_subarrays/SolutionTest.java b/src/test/java/g3801_3900/s3804_number_of_centered_subarrays/SolutionTest.java new file mode 100644 index 000000000..1dc8b981c --- /dev/null +++ b/src/test/java/g3801_3900/s3804_number_of_centered_subarrays/SolutionTest.java @@ -0,0 +1,18 @@ +package g3801_3900.s3804_number_of_centered_subarrays; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void centeredSubarrays() { + assertThat(new Solution().centeredSubarrays(new int[] {-1, 1, 0}), equalTo(5)); + } + + @Test + void centeredSubarrays2() { + assertThat(new Solution().centeredSubarrays(new int[] {2, -3}), equalTo(2)); + } +} diff --git a/src/test/java/g3801_3900/s3805_count_caesar_cipher_pairs/SolutionTest.java b/src/test/java/g3801_3900/s3805_count_caesar_cipher_pairs/SolutionTest.java new file mode 100644 index 000000000..c8f166f2b --- /dev/null +++ b/src/test/java/g3801_3900/s3805_count_caesar_cipher_pairs/SolutionTest.java @@ -0,0 +1,18 @@ +package g3801_3900.s3805_count_caesar_cipher_pairs; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +class SolutionTest { + @Test + void countPairs() { + assertThat(new Solution().countPairs(new String[] {"fusion", "layout"}), equalTo(1L)); + } + + @Test + void countPairs2() { + assertThat(new Solution().countPairs(new String[] {"ab", "aa", "za", "aa"}), equalTo(2L)); + } +}