Skip to content

Commit f9a7e81

Browse files
committed
Added tasks 3492-3495
1 parent ed00724 commit f9a7e81

File tree

32 files changed

+555
-198
lines changed
  • src/main/kotlin
    • g0001_0100
      • s0034_find_first_and_last_position_of_element_in_sorted_array
      • s0068_text_justification
    • g0201_0300
    • g0301_0400
    • g0401_0500/s0409_longest_palindrome
    • g0701_0800/s0770_basic_calculator_iv
    • g0801_0900/s0811_subdomain_visit_count
    • g0901_1000/s0989_add_to_array_form_of_integer
    • g1001_1100/s1048_longest_string_chain
    • g1601_1700/s1639_number_of_ways_to_form_a_target_string_given_a_dictionary
    • g1701_1800
    • g2001_2100/s2019_the_score_of_students_solving_math_expression
    • g2201_2300
      • s2213_longest_substring_of_one_repeating_character
      • s2281_sum_of_total_strength_of_wizards
    • g2401_2500/s2452_words_within_two_edits_of_dictionary
    • g2501_2600
      • s2553_separate_the_digits_in_an_array
      • s2574_left_and_right_sum_differences
    • g2701_2800/s2729_check_if_the_number_is_fascinating
    • g3201_3300
      • s3245_alternating_groups_iii
      • s3283_maximum_number_of_moves_to_kill_all_pawns
    • g3401_3500
      • s3486_longest_special_path_ii
      • s3490_count_beautiful_numbers
      • s3492_maximum_containers_on_a_ship
      • s3493_properties_graph
      • s3494_find_the_minimum_amount_of_time_to_brew_potions
      • s3495_minimum_operations_to_make_array_elements_zero

32 files changed

+555
-198
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,10 @@
20882088

20892089
| # | Title | Difficulty | Tag | Time, ms | Time, %
20902090
|------|----------------|-------------|-------------|----------|--------
2091+
| 3495 |[Minimum Operations to Make Array Elements Zero](src/main/kotlin/g3401_3500/s3495_minimum_operations_to_make_array_elements_zero)| Hard | Array, Math, Bit_Manipulation | 12 | 100.00
2092+
| 3494 |[Find the Minimum Amount of Time to Brew Potions](src/main/kotlin/g3401_3500/s3494_find_the_minimum_amount_of_time_to_brew_potions)| Medium | Array, Simulation, Prefix_Sum | 70 | 100.00
2093+
| 3493 |[Properties Graph](src/main/kotlin/g3401_3500/s3493_properties_graph)| Medium | Array, Hash_Table, Depth_First_Search, Breadth_First_Search, Graph, Union_Find | 45 | 100.00
2094+
| 3492 |[Maximum Containers on a Ship](src/main/kotlin/g3401_3500/s3492_maximum_containers_on_a_ship)| Easy | Math | 0 | 100.00
20912095
| 3490 |[Count Beautiful Numbers](src/main/kotlin/g3401_3500/s3490_count_beautiful_numbers)| Hard | Dynamic_Programming | 246 | 100.00
20922096
| 3489 |[Zero Array Transformation IV](src/main/kotlin/g3401_3500/s3489_zero_array_transformation_iv)| Medium | Array, Dynamic_Programming | 104 | 100.00
20932097
| 3488 |[Closest Equal Element Queries](src/main/kotlin/g3401_3500/s3488_closest_equal_element_queries)| Medium | Array, Hash_Table, Binary_Search | 93 | 100.00
@@ -2259,7 +2263,7 @@
22592263
| 3287 |[Find the Maximum Sequence Value of Array](src/main/kotlin/g3201_3300/s3287_find_the_maximum_sequence_value_of_array)| Hard | Array, Dynamic_Programming, Bit_Manipulation | 2893 | 33.33
22602264
| 3286 |[Find a Safe Walk Through a Grid](src/main/kotlin/g3201_3300/s3286_find_a_safe_walk_through_a_grid)| Medium | Array, Breadth_First_Search, Matrix, Heap_Priority_Queue, Graph, Shortest_Path | 357 | 48.28
22612265
| 3285 |[Find Indices of Stable Mountains](src/main/kotlin/g3201_3300/s3285_find_indices_of_stable_mountains)| Easy | Array | 195 | 92.68
2262-
| 3283 |[Maximum Number of Moves to Kill All Pawns](src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns)| Hard | Array, Math, Breadth_First_Search, Bit_Manipulation, Bitmask, Game_Theory | 638 | 100.00
2266+
| 3283 |[Maximum Number of Moves to Kill All Pawns](src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns)| Hard | Array, Math, Breadth_First_Search, Bit_Manipulation, Bitmask, Game_Theory | 147 | 100.00
22632267
| 3282 |[Reach End of Array With Max Score](src/main/kotlin/g3201_3300/s3282_reach_end_of_array_with_max_score)| Medium | Array, Greedy | 789 | 90.91
22642268
| 3281 |[Maximize Score of Numbers in Ranges](src/main/kotlin/g3201_3300/s3281_maximize_score_of_numbers_in_ranges)| Medium | Array, Sorting, Greedy, Binary_Search | 710 | 88.24
22652269
| 3280 |[Convert Date to Binary](src/main/kotlin/g3201_3300/s3280_convert_date_to_binary)| Easy | String, Math | 174 | 79.31
@@ -3087,7 +3091,7 @@
30873091
| 2217 |[Find Palindrome With Fixed Length](src/main/kotlin/g2201_2300/s2217_find_palindrome_with_fixed_length)| Medium | Array, Math | 541 | 100.00
30883092
| 2216 |[Minimum Deletions to Make Array Beautiful](src/main/kotlin/g2201_2300/s2216_minimum_deletions_to_make_array_beautiful)| Medium | Array, Greedy, Stack | 567 | 66.67
30893093
| 2215 |[Find the Difference of Two Arrays](src/main/kotlin/g2201_2300/s2215_find_the_difference_of_two_arrays)| Easy | Array, Hash_Table | 352 | 98.63
3090-
| 2213 |[Longest Substring of One Repeating Character](src/main/kotlin/g2201_2300/s2213_longest_substring_of_one_repeating_character)| Hard | Array, String, Ordered_Set, Segment_Tree | 879 | 100.00
3094+
| 2213 |[Longest Substring of One Repeating Character](src/main/kotlin/g2201_2300/s2213_longest_substring_of_one_repeating_character)| Hard | Array, String, Ordered_Set, Segment_Tree | 73 | 100.00
30913095
| 2212 |[Maximum Points in an Archery Competition](src/main/kotlin/g2201_2300/s2212_maximum_points_in_an_archery_competition)| Medium | Array, Bit_Manipulation, Recursion, Enumeration | 210 | 100.00
30923096
| 2211 |[Count Collisions on a Road](src/main/kotlin/g2201_2300/s2211_count_collisions_on_a_road)| Medium | String, Stack | 325 | 100.00
30933097
| 2210 |[Count Hills and Valleys in an Array](src/main/kotlin/g2201_2300/s2210_count_hills_and_valleys_in_an_array)| Easy | Array | 153 | 80.00

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You must write an algorithm with `O(log n)` runtime complexity.
3939
## Solution
4040

4141
```kotlin
42-
class Solution constructor() {
42+
class Solution {
4343
fun searchRange(nums: IntArray, target: Int): IntArray {
4444
val ans = IntArray(2)
4545
ans[0] = helper(nums, target, false)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Solution {
102102
startWord = i + 1
103103
// resetting these to 0 for processing next line
104104
lineTotal = 0
105-
numWordsOnLine = lineTotal
105+
numWordsOnLine = 0
106106
// need a new StringBuilder for the next line
107107
sb = StringBuilder(maxWidth)
108108
}

src/main/kotlin/g0201_0300/s0289_game_of_life/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Solution {
9191
}
9292

9393
private fun compute(board: Array<IntArray>, r: Int, c: Int): Int {
94-
var ret: Int = 0
94+
var ret = 0
9595
for (arr in dim) {
9696
val row = arr[0] + r
9797
val col = arr[1] + c

src/main/kotlin/g0201_0300/s0292_nim_game/readme.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ Given `n`, the number of stones in the heap, return `true` _if you can win the g
4343
```kotlin
4444
class Solution {
4545
fun canWinNim(n: Int): Boolean {
46-
if (n % 4 == 0) {
47-
return false
48-
}
49-
return true
46+
return n % 4 != 0
5047
}
5148
}
5249
```

src/main/kotlin/g0301_0400/s0304_range_sum_query_2d_immutable/readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ Implement the NumMatrix class:
4646

4747
```kotlin
4848
class NumMatrix(matrix: Array<IntArray>) {
49-
private val M = matrix.size
50-
private val N = if (M > 0) matrix[0].size else 0
49+
private val m = matrix.size
50+
private val n = if (m > 0) matrix[0].size else 0
5151

52-
var array = Array<IntArray> (M + 1) { IntArray(N + 1) }
52+
var array = Array<IntArray> (m + 1) { IntArray(n + 1) }
5353

5454
init {
55-
for (i in 1..M) {
56-
for (j in 1..N) {
55+
for (i in 1..m) {
56+
for (j in 1..n) {
5757
array[i][j] = matrix[i - 1][j - 1] + array[i][j - 1] + array[i - 1][j] - array[i - 1][j - 1]
5858
}
5959
}

src/main/kotlin/g0301_0400/s0310_minimum_height_trees/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Solution {
5858
while (queue.isNotEmpty()) {
5959
val size = queue.size
6060
val newLeaves = mutableListOf<Int>()
61-
for (_sz in 0 until size) {
61+
for (sz in 0 until size) {
6262
val cur = queue.removeFirst()
6363
newLeaves.add(cur)
6464
for (next in graph[cur]) {

src/main/kotlin/g0301_0400/s0312_burst_balloons/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Solution {
5050
while (ei < nums.size) {
5151
val l = if (si - 1 == -1) 1 else nums[si - 1]
5252
val r = if (ei + 1 == nums.size) 1 else nums[ei + 1]
53-
var maxAns = -1e7.toInt()
53+
var maxAns = (-1e7).toInt()
5454
for (cut in si..ei) {
5555
val leftAns = if (si == cut) 0 else dp[si][cut - 1]
5656
val rightAns = if (ei == cut) 0 else dp[cut + 1][ei]

src/main/kotlin/g0401_0500/s0409_longest_palindrome/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Solution {
4141
for (c in s.toCharArray()) {
4242
set.flip(c.code - 'A'.code)
4343
}
44-
return if (set.isEmpty()) {
44+
return if (set.isEmpty) {
4545
s.length
4646
} else {
4747
s.length - set.cardinality() + 1

src/main/kotlin/g0701_0800/s0770_basic_calculator_iv/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class Solution {
155155
}
156156

157157
private fun make(cur: String): Node {
158-
val ans: Node = Node()
158+
val ans = Node()
159159
val tmp: MutableList<String> = ArrayList()
160160
if (Character.isDigit(cur[0])) {
161161
ans.update(tmp, Integer.valueOf(cur))

0 commit comments

Comments
 (0)