Skip to content

Commit 4691d2f

Browse files
authored
Updated readme
1 parent 634b88a commit 4691d2f

File tree

14 files changed

+111
-135
lines changed
  • src/main/kotlin
    • g0901_1000
    • g1001_1100
    • g1201_1300/s1235_maximum_profit_in_job_scheduling
    • g1301_1400
      • s1353_maximum_number_of_events_that_can_be_attended
      • s1366_rank_teams_by_votes
      • s1383_maximum_performance_of_a_team
      • s1387_sort_integers_by_the_power_value
    • g1401_1500/s1489_find_critical_and_pseudo_critical_edges_in_minimum_spanning_tree

14 files changed

+111
-135
lines changed

README.md

+97-97
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork)
33
> ["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)
44

5-
* [Programming Skills I](#programming-skills-i)
65
* [Programming Skills II](#programming-skills-ii)
76
* [Graph Theory I](#graph-theory-i)
87
* [SQL I](#sql-i)
@@ -16,102 +15,7 @@
1615
* [Binary Search I](#binary-search-i)
1716
* [Binary Search II](#binary-search-ii)
1817
* [Dynamic Programming I](#dynamic-programming-i)
19-
20-
### Programming Skills I
21-
22-
#### Day 1 Basic Data Type
23-
24-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
25-
|-|-|-|-|-|-
26-
| 1523 |[Count Odd Numbers in an Interval Range](src/main/kotlin/g1501_1600/s1523_count_odd_numbers_in_an_interval_range)| Easy | Math | 114 | 97.22
27-
| 1491 |[Average Salary Excluding the Minimum and Maximum Salary](src/main/kotlin/g1401_1500/s1491_average_salary_excluding_the_minimum_and_maximum_salary)| Easy | Array, Sorting | 165 | 27.87
28-
29-
#### Day 2 Operator
30-
31-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
32-
|-|-|-|-|-|-
33-
| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44
34-
| 1281 |[Subtract the Product and Sum of Digits of an Integer](src/main/kotlin/g1201_1300/s1281_subtract_the_product_and_sum_of_digits_of_an_integer)| Easy | Math | 128 | 61.82
35-
36-
#### Day 3 Conditional Statements
37-
38-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
39-
|-|-|-|-|-|-
40-
| 0976 |[Largest Perimeter Triangle](src/main/kotlin/g0901_1000/s0976_largest_perimeter_triangle)| Easy | Array, Math, Sorting, Greedy | 304 | 33.33
41-
| 1779 |[Find Nearest Point That Has the Same X or Y Coordinate](src/main/kotlin/g1701_1800/s1779_find_nearest_point_that_has_the_same_x_or_y_coordinate)| Easy | Array | 364 | 100.00
42-
43-
#### Day 4 Loop
44-
45-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
46-
|-|-|-|-|-|-
47-
| 1822 |[Sign of the Product of an Array](src/main/kotlin/g1801_1900/s1822_sign_of_the_product_of_an_array)| Easy | Array, Math | 170 | 92.51
48-
| 1502 |[Can Make Arithmetic Progression From Sequence](src/main/kotlin/g1501_1600/s1502_can_make_arithmetic_progression_from_sequence)| Easy | Array, Sorting | 156 | 94.82
49-
| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08
50-
| 1790 |[Check if One String Swap Can Make Strings Equal](src/main/kotlin/g1701_1800/s1790_check_if_one_string_swap_can_make_strings_equal)| Easy | String, Hash_Table, Counting | 138 | 100.00
51-
52-
#### Day 5 Function
53-
54-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
55-
|-|-|-|-|-|-
56-
| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02
57-
| 0496 |[Next Greater Element I](src/main/kotlin/g0401_0500/s0496_next_greater_element_i)| Easy | Array, Hash_Table, Stack, Monotonic_Stack | 171 | 100.00
58-
| 1232 |[Check If It Is a Straight Line](src/main/kotlin/g1201_1300/s1232_check_if_it_is_a_straight_line)| Easy | Array, Math, Geometry | 152 | 95.38
59-
60-
#### Day 6 Array
61-
62-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
63-
|-|-|-|-|-|-
64-
| 1588 |[Sum of All Odd Length Subarrays](src/main/kotlin/g1501_1600/s1588_sum_of_all_odd_length_subarrays)| Easy | Array, Math, Prefix_Sum | 157 | 64.00
65-
| 0283 |[Move Zeroes](src/main/kotlin/g0201_0300/s0283_move_zeroes)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 516 | 79.07
66-
| 1672 |[Richest Customer Wealth](src/main/kotlin/g1601_1700/s1672_richest_customer_wealth)| Easy | Array, Matrix | 155 | 94.54
67-
68-
#### Day 7 Array
69-
70-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
71-
|-|-|-|-|-|-
72-
| 1572 |[Matrix Diagonal Sum](src/main/kotlin/g1501_1600/s1572_matrix_diagonal_sum)| Easy | Array, Matrix | 221 | 67.61
73-
| 0566 |[Reshape the Matrix](src/main/kotlin/g0501_0600/s0566_reshape_the_matrix)| Easy | Array, Matrix, Simulation | 239 | 99.05
74-
75-
#### Day 8 String
76-
77-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
78-
|-|-|-|-|-|-
79-
| 1768 |[Merge Strings Alternately](src/main/kotlin/g1701_1800/s1768_merge_strings_alternately)| Easy | String, Two_Pointers | 138 | 93.81
80-
| 1678 |[Goal Parser Interpretation](src/main/kotlin/g1601_1700/s1678_goal_parser_interpretation)| Easy | String | 136 | 88.24
81-
| 0389 |[Find the Difference](src/main/kotlin/g0301_0400/s0389_find_the_difference)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 256 | 64.81
82-
83-
#### Day 9 String
84-
85-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
86-
|-|-|-|-|-|-
87-
| 0709 |[To Lower Case](src/main/kotlin/g0701_0800/s0709_to_lower_case)| Easy | String | 142 | 98.68
88-
| 1309 |[Decrypt String from Alphabet to Integer Mapping](src/main/kotlin/g1301_1400/s1309_decrypt_string_from_alphabet_to_integer_mapping)| Easy | String | 129 | 95.45
89-
| 0953 |[Verifying an Alien Dictionary](src/main/kotlin/g0901_1000/s0953_verifying_an_alien_dictionary)| Easy | Array, String, Hash_Table | 137 | 100.00
90-
91-
#### Day 10 Linked List and Tree
92-
93-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
94-
|-|-|-|-|-|-
95-
| 1290 |[Convert Binary Number in a Linked List to Integer](src/main/kotlin/g1201_1300/s1290_convert_binary_number_in_a_linked_list_to_integer)| Easy | Math, Linked_List | 145 | 25.93
96-
| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52
97-
| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 166 | 83.53
98-
| 0404 |[Sum of Left Leaves](src/main/kotlin/g0401_0500/s0404_sum_of_left_leaves)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 173 | 86.05
99-
100-
#### Day 11 Containers and Libraries
101-
102-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
103-
|-|-|-|-|-|-
104-
| 1356 |[Sort Integers by The Number of 1 Bits](src/main/kotlin/g1301_1400/s1356_sort_integers_by_the_number_of_1_bits)| Easy | Array, Sorting, Bit_Manipulation, Counting | 236 | 92.31
105-
| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86
106-
| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | String, Hash_Table, Sorting | 251 | 87.65
107-
| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49
108-
109-
#### Day 12 Class and Object
110-
111-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
112-
|-|-|-|-|-|-
113-
| 1603 |[Design Parking System](src/main/kotlin/g1601_1700/s1603_design_parking_system)| Easy | Design, Simulation, Counting | 376 | 31.83
114-
| 0303 |[Range Sum Query - Immutable](src/main/kotlin/g0301_0400/s0303_range_sum_query_immutable)| Easy | Array, Design, Prefix_Sum | 472 | 63.64
18+
* [Programming Skills I](#programming-skills-i)
11519

11620
### Programming Skills II
11721

@@ -1812,6 +1716,102 @@
18121716
| 0343 |[Integer Break](src/main/kotlin/g0301_0400/s0343_integer_break)| Medium | Dynamic_Programming, Math | 218 | 63.89
18131717
| 0279 |[Perfect Squares](src/main/kotlin/g0201_0300/s0279_perfect_squares)| Medium | Dynamic_Programming, Math, Breadth_First_Search | 176 | 98.80
18141718

1719+
### Programming Skills I
1720+
1721+
#### Day 1 Basic Data Type
1722+
1723+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1724+
|-|-|-|-|-|-
1725+
| 1523 |[Count Odd Numbers in an Interval Range](src/main/kotlin/g1501_1600/s1523_count_odd_numbers_in_an_interval_range)| Easy | Math | 114 | 97.22
1726+
| 1491 |[Average Salary Excluding the Minimum and Maximum Salary](src/main/kotlin/g1401_1500/s1491_average_salary_excluding_the_minimum_and_maximum_salary)| Easy | Array, Sorting | 165 | 27.87
1727+
1728+
#### Day 2 Operator
1729+
1730+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1731+
|-|-|-|-|-|-
1732+
| 0191 |[Number of 1 Bits](src/main/kotlin/g0101_0200/s0191_number_of_1_bits)| Easy | Top_Interview_Questions, Bit_Manipulation | 237 | 68.44
1733+
| 1281 |[Subtract the Product and Sum of Digits of an Integer](src/main/kotlin/g1201_1300/s1281_subtract_the_product_and_sum_of_digits_of_an_integer)| Easy | Math | 128 | 61.82
1734+
1735+
#### Day 3 Conditional Statements
1736+
1737+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1738+
|-|-|-|-|-|-
1739+
| 0976 |[Largest Perimeter Triangle](src/main/kotlin/g0901_1000/s0976_largest_perimeter_triangle)| Easy | Array, Math, Sorting, Greedy | 304 | 33.33
1740+
| 1779 |[Find Nearest Point That Has the Same X or Y Coordinate](src/main/kotlin/g1701_1800/s1779_find_nearest_point_that_has_the_same_x_or_y_coordinate)| Easy | Array | 364 | 100.00
1741+
1742+
#### Day 4 Loop
1743+
1744+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1745+
|-|-|-|-|-|-
1746+
| 1822 |[Sign of the Product of an Array](src/main/kotlin/g1801_1900/s1822_sign_of_the_product_of_an_array)| Easy | Array, Math | 170 | 92.51
1747+
| 1502 |[Can Make Arithmetic Progression From Sequence](src/main/kotlin/g1501_1600/s1502_can_make_arithmetic_progression_from_sequence)| Easy | Array, Sorting | 156 | 94.82
1748+
| 0202 |[Happy Number](src/main/kotlin/g0201_0300/s0202_happy_number)| Easy | Top_Interview_Questions, Hash_Table, Math, Two_Pointers | 261 | 45.08
1749+
| 1790 |[Check if One String Swap Can Make Strings Equal](src/main/kotlin/g1701_1800/s1790_check_if_one_string_swap_can_make_strings_equal)| Easy | String, Hash_Table, Counting | 138 | 100.00
1750+
1751+
#### Day 5 Function
1752+
1753+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1754+
|-|-|-|-|-|-
1755+
| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02
1756+
| 0496 |[Next Greater Element I](src/main/kotlin/g0401_0500/s0496_next_greater_element_i)| Easy | Array, Hash_Table, Stack, Monotonic_Stack | 171 | 100.00
1757+
| 1232 |[Check If It Is a Straight Line](src/main/kotlin/g1201_1300/s1232_check_if_it_is_a_straight_line)| Easy | Array, Math, Geometry | 152 | 95.38
1758+
1759+
#### Day 6 Array
1760+
1761+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1762+
|-|-|-|-|-|-
1763+
| 1588 |[Sum of All Odd Length Subarrays](src/main/kotlin/g1501_1600/s1588_sum_of_all_odd_length_subarrays)| Easy | Array, Math, Prefix_Sum | 157 | 64.00
1764+
| 0283 |[Move Zeroes](src/main/kotlin/g0201_0300/s0283_move_zeroes)| Easy | Top_100_Liked_Questions, Array, Two_Pointers, Big_O_Time_O(n)_Space_O(1) | 516 | 79.07
1765+
| 1672 |[Richest Customer Wealth](src/main/kotlin/g1601_1700/s1672_richest_customer_wealth)| Easy | Array, Matrix | 155 | 94.54
1766+
1767+
#### Day 7 Array
1768+
1769+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1770+
|-|-|-|-|-|-
1771+
| 1572 |[Matrix Diagonal Sum](src/main/kotlin/g1501_1600/s1572_matrix_diagonal_sum)| Easy | Array, Matrix | 221 | 67.61
1772+
| 0566 |[Reshape the Matrix](src/main/kotlin/g0501_0600/s0566_reshape_the_matrix)| Easy | Array, Matrix, Simulation | 239 | 99.05
1773+
1774+
#### Day 8 String
1775+
1776+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1777+
|-|-|-|-|-|-
1778+
| 1768 |[Merge Strings Alternately](src/main/kotlin/g1701_1800/s1768_merge_strings_alternately)| Easy | String, Two_Pointers | 138 | 93.81
1779+
| 1678 |[Goal Parser Interpretation](src/main/kotlin/g1601_1700/s1678_goal_parser_interpretation)| Easy | String | 136 | 88.24
1780+
| 0389 |[Find the Difference](src/main/kotlin/g0301_0400/s0389_find_the_difference)| Easy | String, Hash_Table, Sorting, Bit_Manipulation | 256 | 64.81
1781+
1782+
#### Day 9 String
1783+
1784+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1785+
|-|-|-|-|-|-
1786+
| 0709 |[To Lower Case](src/main/kotlin/g0701_0800/s0709_to_lower_case)| Easy | String | 142 | 98.68
1787+
| 1309 |[Decrypt String from Alphabet to Integer Mapping](src/main/kotlin/g1301_1400/s1309_decrypt_string_from_alphabet_to_integer_mapping)| Easy | String | 129 | 95.45
1788+
| 0953 |[Verifying an Alien Dictionary](src/main/kotlin/g0901_1000/s0953_verifying_an_alien_dictionary)| Easy | Array, String, Hash_Table | 137 | 100.00
1789+
1790+
#### Day 10 Linked List and Tree
1791+
1792+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1793+
|-|-|-|-|-|-
1794+
| 1290 |[Convert Binary Number in a Linked List to Integer](src/main/kotlin/g1201_1300/s1290_convert_binary_number_in_a_linked_list_to_integer)| Easy | Math, Linked_List | 145 | 25.93
1795+
| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52
1796+
| 0104 |[Maximum Depth of Binary Tree](src/main/kotlin/g0101_0200/s0104_maximum_depth_of_binary_tree)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(H) | 166 | 83.53
1797+
| 0404 |[Sum of Left Leaves](src/main/kotlin/g0401_0500/s0404_sum_of_left_leaves)| Easy | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree | 173 | 86.05
1798+
1799+
#### Day 11 Containers and Libraries
1800+
1801+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1802+
|-|-|-|-|-|-
1803+
| 1356 |[Sort Integers by The Number of 1 Bits](src/main/kotlin/g1301_1400/s1356_sort_integers_by_the_number_of_1_bits)| Easy | Array, Sorting, Bit_Manipulation, Counting | 236 | 92.31
1804+
| 0232 |[Implement Queue using Stacks](src/main/kotlin/g0201_0300/s0232_implement_queue_using_stacks)| Easy | Stack, Design, Queue | 258 | 70.86
1805+
| 0242 |[Valid Anagram](src/main/kotlin/g0201_0300/s0242_valid_anagram)| Easy | String, Hash_Table, Sorting | 251 | 87.65
1806+
| 0217 |[Contains Duplicate](src/main/kotlin/g0201_0300/s0217_contains_duplicate)| Easy | Top_Interview_Questions, Array, Hash_Table, Sorting | 719 | 73.49
1807+
1808+
#### Day 12 Class and Object
1809+
1810+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1811+
|-|-|-|-|-|-
1812+
| 1603 |[Design Parking System](src/main/kotlin/g1601_1700/s1603_design_parking_system)| Easy | Design, Simulation, Counting | 376 | 31.83
1813+
| 0303 |[Range Sum Query - Immutable](src/main/kotlin/g0301_0400/s0303_range_sum_query_immutable)| Easy | Array, Design, Prefix_Sum | 472 | 63.64
1814+
18151815
## Algorithms
18161816

18171817
| # | Title | Difficulty | Tag | Time, ms | Time, %

src/main/kotlin/g0901_1000/s0939_minimum_area_rectangle/readme.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Return _the minimum area of a rectangle formed from these points, with sides par
3535
## Solution
3636

3737
```kotlin
38-
import java.util.Arrays
3938
import kotlin.math.abs
4039

4140
class Solution {
@@ -48,9 +47,7 @@ class Solution {
4847
map.putIfAbsent(p[0], HashSet())
4948
map.getValue(p[0]).add(p[1])
5049
}
51-
Arrays.sort(
52-
points
53-
) { a: IntArray, b: IntArray ->
50+
points.sortWith { a: IntArray, b: IntArray ->
5451
if (a[0] == b[0]) Integer.compare(
5552
a[1],
5653
b[1]

src/main/kotlin/g0901_1000/s0956_tallest_billboard/readme.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,14 @@ Return _the largest possible height of your billboard installation_. If you cann
4444
## Solution
4545

4646
```kotlin
47-
import java.util.Arrays
48-
4947
class Solution {
5048
fun tallestBillboard(rods: IntArray): Int {
5149
var maxDiff = 0
5250
for (rod in rods) {
5351
maxDiff += rod
5452
}
5553
val dp = IntArray(maxDiff + 1)
56-
Arrays.fill(dp, -1)
54+
dp.fill(-1)
5755
dp[0] = 0
5856
for (l in rods) {
5957
val dpOld = IntArray(maxDiff + 1)

src/main/kotlin/g0901_1000/s0957_prison_cells_after_n_days/readme.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Day 7: [0, 0, 1, 1, 0, 0, 0, 0]
5757
## Solution
5858

5959
```kotlin
60-
import java.util.Arrays
61-
6260
@Suppress("NAME_SHADOWING")
6361
class Solution {
6462
fun prisonAfterNDays(cells: IntArray, n: Int): IntArray {
@@ -74,7 +72,7 @@ class Solution {
7472
day++
7573
n--
7674
val next = getNextDay(prev)
77-
if (Arrays.equals(next, first)) {
75+
if (next.contentEquals(first)) {
7876
period = day - 1
7977
n %= period
8078
}

src/main/kotlin/g1001_1100/s1024_video_stitching/readme.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 1
5454
## Solution
5555

5656
```kotlin
57-
import java.util.Arrays
58-
5957
class Solution {
6058
fun videoStitching(clips: Array<IntArray>, time: Int): Int {
61-
Arrays.sort(clips) { a: IntArray, b: IntArray ->
59+
clips.sortWith { a: IntArray, b: IntArray ->
6260
if (a[0] == b[0]
6361
) a[1] - b[1] else a[0] - b[0]
6462
}

src/main/kotlin/g1001_1100/s1027_longest_arithmetic_subsequence/readme.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ Given an array `nums` of integers, return _the length of the longest arithmetic
3838
## Solution
3939

4040
```kotlin
41-
import java.util.Arrays
42-
4341
class Solution {
4442
fun longestArithSeqLength(nums: IntArray): Int {
4543
val max = maxElement(nums)
@@ -48,7 +46,7 @@ class Solution {
4846
val n = nums.size
4947
val dp = Array(n) { IntArray(2 * diff + 2) }
5048
for (d in dp) {
51-
Arrays.fill(d, 1)
49+
d.fill(1)
5250
}
5351
var ans = 0
5452
for (i in 0 until n) {

src/main/kotlin/g1001_1100/s1029_two_city_scheduling/readme.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interv
4949
## Solution
5050

5151
```kotlin
52-
import java.util.Arrays
53-
5452
class Solution {
5553
fun twoCitySchedCost(costs: Array<IntArray>): Int {
56-
Arrays.sort(costs) { a: IntArray, b: IntArray ->
54+
costs.sortWith { a: IntArray, b: IntArray ->
5755
a[0] - a[1] - (b[0] - b[1])
5856
}
5957
var cost = 0

src/main/kotlin/g1001_1100/s1081_smallest_subsequence_of_distinct_characters/readme.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Given a string `s`, return _the_ _lexicographically smallest_ _subsequence_ _of_
2929
## Solution
3030

3131
```kotlin
32-
import java.util.Arrays
3332
import java.util.Deque
3433
import java.util.LinkedList
3534

@@ -39,7 +38,7 @@ class Solution {
3938
val stk: Deque<Char> = LinkedList()
4039
val freq = IntArray(26)
4140
val exist = BooleanArray(26)
42-
Arrays.fill(exist, false)
41+
exist.fill(false)
4342
for (ch in s.toCharArray()) {
4443
freq[ch.code - 'a'.code]++
4544
}

src/main/kotlin/g1201_1300/s1235_maximum_profit_in_job_scheduling/readme.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ If you choose a job that ends at time `X` you will be able to start another job
4848
## Solution
4949

5050
```kotlin
51-
import java.util.Arrays
52-
5351
class Solution {
5452
fun jobScheduling(startTime: IntArray, endTime: IntArray, profit: IntArray): Int {
5553
val n = startTime.size
@@ -59,7 +57,7 @@ class Solution {
5957
time[i][1] = endTime[i]
6058
time[i][2] = profit[i]
6159
}
62-
Arrays.sort(time, { a: IntArray, b: IntArray -> a[1].compareTo(b[1]) })
60+
time.sortWith { a: IntArray, b: IntArray -> a[1].compareTo(b[1]) }
6361
val maxP = Array(n) { IntArray(2) }
6462
var lastPos = -1
6563
var currProfit: Int

src/main/kotlin/g1301_1400/s1353_maximum_number_of_events_that_can_be_attended/readme.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ Attend the third event on day 3.
4444
## Solution
4545

4646
```kotlin
47-
import java.util.Arrays
4847
import java.util.PriorityQueue
4948

5049
class Solution {
5150
fun maxEvents(events: Array<IntArray>): Int {
52-
Arrays.sort(events) { a: IntArray, b: IntArray -> a[0] - b[0] }
51+
events.sortWith { a: IntArray, b: IntArray -> a[0] - b[0] }
5352
var ans = 0
5453
var i = 0
5554
val pq = PriorityQueue<Int>()

src/main/kotlin/g1301_1400/s1366_rank_teams_by_votes/readme.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ As most of the voters ranked C second, team C is the second team and team B is t
5555
## Solution
5656

5757
```kotlin
58-
import java.util.Arrays
59-
6058
class Solution {
6159
internal class Node(var c: Char) {
6260
var count = IntArray(26)
@@ -72,9 +70,8 @@ class Solution {
7270
nodes[vote[i].code - 'A'.code]!!.count[i]++
7371
}
7472
}
75-
Arrays.sort(
76-
nodes
77-
) { o1: Node?, o2: Node? ->
73+
74+
nodes.sortWith sort@{ o1: Node?, o2: Node? ->
7875
for (i in 0..25) {
7976
if (o1!!.count[i] != o2!!.count[i]) {
8077
return@sort o2.count[i] - o1.count[i]

0 commit comments

Comments
 (0)