Skip to content

Commit 242f485

Browse files
authored
Added tasks 331-368.
1 parent fb26039 commit 242f485

File tree

34 files changed

+1463
-49
lines changed

34 files changed

+1463
-49
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262

263263
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
264264
|-|-|-|-|-|-
265+
| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math | 218 | 63.89
265266
| 0279 |[Perfect Squares](src/main/kotlin/g0201_0300/s0279_perfect_squares)| Medium | Top_Interview_Questions, Dynamic_Programming, Math, Breadth_First_Search | 176 | 98.80
266267

267268
### Programming Skills I
@@ -512,6 +513,7 @@
512513

513514
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
514515
|-|-|-|-|-|-
516+
| 0365 |[Water and Jug Problem](src/main/kotlin/g0301_0400/s0365_water_and_jug_problem)| Medium | Math, Depth_First_Search, Breadth_First_Search | 130 | 100.00
515517

516518
#### Day 12 Breadth First Search
517519

@@ -835,6 +837,7 @@
835837

836838
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
837839
|-|-|-|-|-|-
840+
| 0344 |[Reverse String](src/main/kotlin/g0301_0400/s0344_reverse_string)| Easy | Top_Interview_Questions, String, Two_Pointers, Recursion | 445 | 69.75
838841
| 0014 |[Longest Common Prefix](src/main/kotlin/g0001_0100/s0014_longest_common_prefix)| Easy | Top_Interview_Questions, String | 209 | 88.86
839842
| 0187 |[Repeated DNA Sequences](src/main/kotlin/g0101_0200/s0187_repeated_dna_sequences)| Medium | String, Hash_Table, Bit_Manipulation, Sliding_Window, Hash_Function, Rolling_Hash | 319 | 79.03
840843
| 0003 |[Longest Substring Without Repeating Characters](src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window | 258 | 91.09
@@ -941,6 +944,7 @@
941944
| 0297 |[Serialize and Deserialize Binary Tree](src/main/kotlin/g0201_0300/s0297_serialize_and_deserialize_binary_tree)| Hard | Top_Interview_Questions, String, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Design | 475 | 78.85
942945
| 0124 |[Binary Tree Maximum Path Sum](src/main/kotlin/g0101_0200/s0124_binary_tree_maximum_path_sum)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 331 | 74.42
943946
| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 330 | 41.38
947+
| 0337 |[House Robber III](src/main/kotlin/g0301_0400/s0337_house_robber_iii)| Medium | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree | 282 | 84.62
944948
| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/kotlin/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree | 386 | 45.21
945949

946950
#### Udemy Trie and Heap
@@ -1021,6 +1025,7 @@
10211025

10221026
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
10231027
|-|-|-|-|-|-
1028+
| 0350 |[Intersection of Two Arrays II](src/main/kotlin/g0301_0400/s0350_intersection_of_two_arrays_ii)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 321 | 73.37
10241029
| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming | 609 | 94.06
10251030

10261031
#### Day 4 Array
@@ -1134,6 +1139,7 @@
11341139

11351140
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
11361141
|-|-|-|-|-|-
1142+
| 0334 |[Increasing Triplet Subsequence](src/main/kotlin/g0301_0400/s0334_increasing_triplet_subsequence)| Medium | Top_Interview_Questions, Array, Greedy | 672 | 60.61
11371143
| 0238 |[Product of Array Except Self](src/main/kotlin/g0201_0300/s0238_product_of_array_except_self)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Prefix_Sum | 669 | 48.96
11381144
| 0560 |[Subarray Sum Equals K](src/main/kotlin/g0501_0600/s0560_subarray_sum_equals_k)| Medium | Top_100_Liked_Questions, Array, Hash_Table, Prefix_Sum | 692 | 53.27
11391145

@@ -1268,6 +1274,7 @@
12681274

12691275
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
12701276
|-|-|-|-|-|-
1277+
| 0344 |[Reverse String](src/main/kotlin/g0301_0400/s0344_reverse_string)| Easy | Top_Interview_Questions, String, Two_Pointers, Recursion | 445 | 69.75
12711278

12721279
#### Day 5 Two Pointers
12731280

@@ -1457,6 +1464,7 @@
14571464
|-|-|-|-|-|-
14581465
| 0072 |[Edit Distance](src/main/kotlin/g0001_0100/s0072_edit_distance)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming | 320 | 63.53
14591466
| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search | 332 | 50.68
1467+
| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math | 218 | 63.89
14601468

14611469
#### Day 19 Bit Manipulation
14621470

@@ -1493,6 +1501,7 @@
14931501

14941502
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
14951503
|-|-|-|-|-|-
1504+
| 0367 |[Valid Perfect Square](src/main/kotlin/g0301_0400/s0367_valid_perfect_square)| Easy | Math, Binary_Search | 137 | 94.55
14961505

14971506
#### Day 4
14981507

@@ -1533,6 +1542,7 @@
15331542

15341543
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
15351544
|-|-|-|-|-|-
1545+
| 0350 |[Intersection of Two Arrays II](src/main/kotlin/g0301_0400/s0350_intersection_of_two_arrays_ii)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 321 | 73.37
15361546

15371547
#### Day 11
15381548

@@ -1564,13 +1574,33 @@
15641574
| 0416 |[Partition Equal Subset Sum](src/main/kotlin/g0401_0500/s0416_partition_equal_subset_sum)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Level_2_Day_13_Dynamic_Programming | 509 | 57.56
15651575
| 0394 |[Decode String](src/main/kotlin/g0301_0400/s0394_decode_string)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Level_1_Day_14_Stack, Udemy_Strings | 224 | 64.86
15661576
| 0378 |[Kth Smallest Element in a Sorted Matrix](src/main/kotlin/g0301_0400/s0378_kth_smallest_element_in_a_sorted_matrix)| Medium | Top_Interview_Questions, Array, Sorting, Binary_Search, Matrix, Heap_Priority_Queue | 522 | 59.78
1577+
| 0368 |[Largest Divisible Subset](src/main/kotlin/g0301_0400/s0368_largest_divisible_subset)| Medium | Array, Dynamic_Programming, Math, Sorting | 412 | 73.33
1578+
| 0367 |[Valid Perfect Square](src/main/kotlin/g0301_0400/s0367_valid_perfect_square)| Easy | Math, Binary_Search, Binary_Search_I_Day_3 | 137 | 94.55
1579+
| 0365 |[Water and Jug Problem](src/main/kotlin/g0301_0400/s0365_water_and_jug_problem)| Medium | Math, Depth_First_Search, Breadth_First_Search, Graph_Theory_I_Day_11_Breadth_First_Search | 130 | 100.00
1580+
| 0363 |[Max Sum of Rectangle No Larger Than K](src/main/kotlin/g0301_0400/s0363_max_sum_of_rectangle_no_larger_than_k)| Hard | Array, Dynamic_Programming, Binary_Search, Matrix, Ordered_Set | 243 | 100.00
1581+
| 0357 |[Count Numbers with Unique Digits](src/main/kotlin/g0301_0400/s0357_count_numbers_with_unique_digits)| Medium | Dynamic_Programming, Math, Backtracking | 104 | 100.00
1582+
| 0355 |[Design Twitter](src/main/kotlin/g0301_0400/s0355_design_twitter)| Medium | Hash_Table, Design, Heap_Priority_Queue, Linked_List | 288 | 68.75
1583+
| 0354 |[Russian Doll Envelopes](src/main/kotlin/g0301_0400/s0354_russian_doll_envelopes)| Hard | Array, Dynamic_Programming, Sorting, Binary_Search | 788 | 100.00
1584+
| 0352 |[Data Stream as Disjoint Intervals](src/main/kotlin/g0301_0400/s0352_data_stream_as_disjoint_intervals)| Hard | Binary_Search, Design, Ordered_Set | 905 | 75.00
1585+
| 0350 |[Intersection of Two Arrays II](src/main/kotlin/g0301_0400/s0350_intersection_of_two_arrays_ii)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting, Binary_Search, Two_Pointers, Data_Structure_I_Day_3_Array, Binary_Search_I_Day_10 | 321 | 73.37
1586+
| 0349 |[Intersection of Two Arrays](src/main/kotlin/g0301_0400/s0349_intersection_of_two_arrays)| Easy | Array, Hash_Table, Sorting, Binary_Search, Two_Pointers | 346 | 66.99
15671587
| 0347 |[Top K Frequent Elements](src/main/kotlin/g0301_0400/s0347_top_k_frequent_elements)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Divide_and_Conquer, Quickselect, Bucket_Sort, Data_Structure_II_Day_20_Heap_Priority_Queue | 268 | 99.74
1588+
| 0345 |[Reverse Vowels of a String](src/main/kotlin/g0301_0400/s0345_reverse_vowels_of_a_string)| Easy | String, Two_Pointers | 349 | 80.63
1589+
| 0344 |[Reverse String](src/main/kotlin/g0301_0400/s0344_reverse_string)| Easy | Top_Interview_Questions, String, Two_Pointers, Recursion, Algorithm_I_Day_4_Two_Pointers, Udemy_Strings | 445 | 69.75
1590+
| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_21 | 218 | 63.89
1591+
| 0342 |[Power of Four](src/main/kotlin/g0301_0400/s0342_power_of_four)| Easy | Math, Bit_Manipulation, Recursion | 150 | 92.11
15681592
| 0338 |[Counting Bits](src/main/kotlin/g0301_0400/s0338_counting_bits)| Easy | Top_100_Liked_Questions, Dynamic_Programming, Bit_Manipulation, Udemy_Bit_Manipulation | 186 | 99.26
1593+
| 0337 |[House Robber III](src/main/kotlin/g0301_0400/s0337_house_robber_iii)| Medium | Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue | 282 | 84.62
1594+
| 0336 |[Palindrome Pairs](src/main/kotlin/g0301_0400/s0336_palindrome_pairs)| Hard | Array, String, Hash_Table, Trie | 2451 | 67.33
1595+
| 0335 |[Self Crossing](src/main/kotlin/g0301_0400/s0335_self_crossing)| Hard | Array, Math, Geometry | 477 | 100.00
1596+
| 0334 |[Increasing Triplet Subsequence](src/main/kotlin/g0301_0400/s0334_increasing_triplet_subsequence)| Medium | Top_Interview_Questions, Array, Greedy, Data_Structure_II_Day_5_Array | 672 | 60.61
1597+
| 0332 |[Reconstruct Itinerary](src/main/kotlin/g0301_0400/s0332_reconstruct_itinerary)| Hard | Depth_First_Search, Graph, Eulerian_Circuit | 240 | 93.88
1598+
| 0331 |[Verify Preorder Serialization of a Binary Tree](src/main/kotlin/g0301_0400/s0331_verify_preorder_serialization_of_a_binary_tree)| Medium | String, Tree, Binary_Tree, Stack | 335 | 70.00
15691599
| 0330 |[Patching Array](src/main/kotlin/g0301_0400/s0330_patching_array)| Hard | Array, Greedy | 201 | 100.00
15701600
| 0329 |[Longest Increasing Path in a Matrix](src/main/kotlin/g0301_0400/s0329_longest_increasing_path_in_a_matrix)| Hard | Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Breadth_First_Search, Graph, Memoization, Topological_Sort | 322 | 92.65
15711601
| 0328 |[Odd Even Linked List](src/main/kotlin/g0301_0400/s0328_odd_even_linked_list)| Medium | Top_Interview_Questions, Linked_List, Level_2_Day_4_Linked_List, Udemy_Linked_List | 216 | 86.96
15721602
| 0327 |[Count of Range Sum](src/main/kotlin/g0301_0400/s0327_count_of_range_sum)| Hard | Array, Binary_Search, Ordered_Set, Divide_and_Conquer, Segment_Tree, Binary_Indexed_Tree, Merge_Sort | 638 | 100.00
1573-
| 0326 |[Wiggle Sort II](src/main/kotlin/g0301_0400/s0326_power_of_three)| Easy | Top_Interview_Questions, Math, Recursion | 413 | 76.12
1603+
| 0326 |[Power of Three](src/main/kotlin/g0301_0400/s0326_power_of_three)| Easy | Top_Interview_Questions, Math, Recursion | 413 | 76.12
15741604
| 0324 |[Wiggle Sort II](src/main/kotlin/g0301_0400/s0324_wiggle_sort_ii)| Medium | Top_Interview_Questions, Array, Sorting, Divide_and_Conquer, Quickselect | 545 | 57.14
15751605
| 0322 |[Coin Change](src/main/kotlin/g0301_0400/s0322_coin_change)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Breadth_First_Search, Algorithm_II_Day_18_Dynamic_Programming, Dynamic_Programming_I_Day_20, Level_2_Day_12_Dynamic_Programming | 332 | 50.68
15761606
| 0321 |[Create Maximum Number](src/main/kotlin/g0301_0400/s0321_create_maximum_number)| Hard | Greedy, Stack, Monotonic_Stack | 209 | 100.00

src/main/kotlin/g0001_0100/s0015_3sum/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ Notice that the solution set must not contain duplicate triplets.
3535
## Solution
3636

3737
```kotlin
38-
import java.util.Arrays
3938
import kotlin.collections.ArrayList
4039

4140
class Solution {
4241
fun threeSum(nums: IntArray): List<List<Int>> {
43-
Arrays.sort(nums)
42+
nums.sort()
4443
val len = nums.size
4544
val result: MutableList<List<Int>> = ArrayList()
4645
var l: Int

src/main/kotlin/g0001_0100/s0016_3sum_closest/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ You may assume that each input would have exactly one solution.
3434
## Solution
3535

3636
```kotlin
37-
import java.util.Arrays
38-
3937
class Solution {
4038
fun threeSumClosest(nums: IntArray?, target: Int): Int {
4139
if (nums == null || nums.size < 3) {
@@ -44,7 +42,7 @@ class Solution {
4442
if (nums.size == 3) {
4543
return nums[0] + nums[1] + nums[2]
4644
}
47-
Arrays.sort(nums)
45+
nums.sort()
4846
val n = nums.size
4947
var sum = nums[0] + nums[1] + nums[2]
5048
for (i in 0 until n - 2) {

src/main/kotlin/g0001_0100/s0018_4sum/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ You may return the answer in **any order**.
3434
## Solution
3535

3636
```kotlin
37-
import java.util.Arrays
38-
3937
class Solution {
4038
fun fourSum(nums: IntArray, target: Int): List<List<Int>> {
4139
val ret: MutableList<List<Int>> = ArrayList()
@@ -45,7 +43,7 @@ class Solution {
4543
if (nums[0] == 1000000000 && nums[1] == 1000000000) {
4644
return ret
4745
}
48-
Arrays.sort(nums)
46+
nums.sort()
4947
for (i in 0 until nums.size - 3) {
5048
if (i != 0 && nums[i] == nums[i - 1]) {
5149
continue

src/main/kotlin/g0001_0100/s0040_combination_sum_ii/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ Each number in `candidates` may only be used **once** in the combination.
3232
## Solution
3333

3434
```kotlin
35-
import java.util.Arrays
3635
import java.util.LinkedList
3736

3837
class Solution {
3938
fun combinationSum2(candidates: IntArray, target: Int): List<List<Int>> {
4039
val sums: MutableList<List<Int>> = ArrayList()
4140
// optimize
42-
Arrays.sort(candidates)
41+
candidates.sort()
4342
combinationSum(candidates, target, 0, sums, LinkedList())
4443
return sums
4544
}

src/main/kotlin/g0001_0100/s0049_group_anagrams/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ An **Anagram** is a word or phrase formed by rearranging the letters of a differ
3636
## Solution
3737

3838
```kotlin
39-
import java.util.Arrays
40-
4139
class Solution {
4240
fun groupAnagrams(strs: Array<String>): List<List<String>> {
4341
val hm: MutableMap<String, MutableList<String>> = HashMap()
4442
for (s in strs) {
4543
val ch = s.toCharArray()
46-
Arrays.sort(ch)
44+
ch.sort()
4745
val temp = String(ch)
4846
hm.computeIfAbsent(
4947
temp

src/main/kotlin/g0001_0100/s0056_merge_intervals/readme.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@ Given an array of `intervals` where <code>intervals[i] = [start<sub>i</sub>, end
3232
## Solution
3333

3434
```kotlin
35-
import java.util.Arrays
36-
3735
class Solution {
3836
fun merge(intervals: Array<IntArray>): Array<IntArray> {
39-
Arrays.sort(
40-
intervals
41-
) { a: IntArray, b: IntArray ->
37+
intervals.sortWith { a: IntArray, b: IntArray ->
4238
Integer.compare(
4339
a[0],
4440
b[0]

src/main/kotlin/g0001_0100/s0090_subsets_ii/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ The solution set **must not** contain duplicate subsets. Return the solution in
2929
## Solution
3030

3131
```kotlin
32-
import java.util.Arrays
33-
3432
class Solution {
3533
var allComb: MutableList<List<Int>> = ArrayList()
3634
var comb: MutableList<Int> = ArrayList()
3735
lateinit var nums: IntArray
3836
fun subsetsWithDup(nums: IntArray): List<List<Int>> {
39-
Arrays.sort(nums)
37+
nums.sort()
4038
this.nums = nums
4139
dfs(0)
4240
allComb.add(ArrayList())

src/main/kotlin/g0101_0200/s0164_maximum_gap/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ You must write an algorithm that runs in linear time and uses linear extra space
3333
## Solution
3434

3535
```kotlin
36-
import java.util.Arrays
37-
3836
class Solution {
3937
fun maximumGap(nums: IntArray): Int {
4038
if (nums.size < 2) {
4139
return 0
4240
}
4341
var ret = Int.MIN_VALUE
44-
Arrays.sort(nums)
42+
nums.sort()
4543
for (i in 0 until nums.size - 1) {
4644
if (nums[i + 1] - nums[i] > ret) {
4745
ret = nums[i + 1] - nums[i]

src/main/kotlin/g0101_0200/s0179_largest_number/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@ Since the result may be very large, so you need to return a string instead of an
2929
## Solution
3030

3131
```kotlin
32-
import java.util.Arrays
33-
3432
class Solution {
3533
fun largestNumber(nums: IntArray): String {
3634
val n = nums.size
3735
val s = arrayOfNulls<String>(n)
3836
for (i in 0 until n) {
3937
s[i] = nums[i].toString()
4038
}
41-
Arrays.sort(s) { a: String?, b: String? ->
39+
s.sortWith { a: String?, b: String? ->
4240
(b + a).compareTo(
4341
a + b
4442
)

0 commit comments

Comments
 (0)