File tree Expand file tree Collapse file tree 8 files changed +20
-18
lines changed
src/main/kotlin/g3101_3200
s3127_make_a_square_with_the_same_color
s3129_find_all_possible_stable_binary_arrays_i
s3130_find_all_possible_stable_binary_arrays_ii
s3131_find_the_integer_added_to_array_i
s3132_find_the_integer_added_to_array_ii
s3134_find_the_median_of_the_uniqueness_array Expand file tree Collapse file tree 8 files changed +20
-18
lines changed Original file line number Diff line number Diff line change 1
1
package g3101_3200.s3127_make_a_square_with_the_same_color
2
2
3
- // #Easy #Array #Matrix #Enumeration #2024_05_02_Time_0_ms_(100 .00%)_Space_41.7_MB_(64.59 %)
3
+ // #Easy #Array #Matrix #Enumeration #2024_05_02_Time_149_ms_(80 .00%)_Space_35.1_MB_(40.00 %)
4
4
5
5
class Solution {
6
6
fun canMakeSquare (grid : Array <CharArray >): Boolean {
Original file line number Diff line number Diff line change 1
- package g3101_3200.s3128_right_triangles // #Medium #Array #Hash_Table #Math #Counting #Combinatorics
2
- // #2024_05_02_Time_6_ms_(100.00%)_Space_145.9_MB_(90.67%)
1
+ package g3101_3200.s3128_right_triangles
2
+
3
+ // #Medium #Array #Hash_Table #Math #Counting #Combinatorics
4
+ // #2024_05_02_Time_975_ms_(40.63%)_Space_217.6_MB_(56.25%)
3
5
4
6
class Solution {
5
7
fun numberOfRightTriangles (grid : Array <IntArray >): Long {
Original file line number Diff line number Diff line change 1
1
package g3101_3200.s3129_find_all_possible_stable_binary_arrays_i
2
2
3
+ // #Medium #Dynamic_Programming #Prefix_Sum #2024_05_02_Time_169_ms_(92.86%)_Space_36.3_MB_(100.00%)
4
+
3
5
import kotlin.math.abs
4
6
import kotlin.math.max
5
7
import kotlin.math.min
6
8
7
- // #Medium #Dynamic_Programming #Prefix_Sum #2024_05_02_Time_3_ms_(100.00%)_Space_44.1_MB_(98.38%)
8
-
9
9
class Solution {
10
10
private fun add (x : Int , y : Int ): Int {
11
11
return (x + y) % MODULUS
@@ -21,10 +21,10 @@ class Solution {
21
21
22
22
fun numberOfStableArrays (zero : Int , one : Int , limit : Int ): Int {
23
23
if (limit == 1 ) {
24
- return max((2 - abs((zero - one).toDouble())).toDouble() , 0.0 ).toInt( )
24
+ return max((2 - abs((zero - one))) , 0 )
25
25
}
26
- val max = max(zero.toDouble() , one.toDouble()).toInt( )
27
- val min = min(zero.toDouble() , one.toDouble()).toInt( )
26
+ val max = max(zero, one)
27
+ val min = min(zero, one)
28
28
val lcn = Array (max + 1 ) { IntArray (max + 1 ) }
29
29
var row0 = lcn[0 ]
30
30
var row1: IntArray
Original file line number Diff line number Diff line change 1
1
package g3101_3200.s3130_find_all_possible_stable_binary_arrays_ii
2
2
3
- // #Hard #Dynamic_Programming #Prefix_Sum #2024_05_02_Time_3_ms_ (100.00%)_Space_40.6_MB_ (100.00%)
3
+ // #Hard #Dynamic_Programming #Prefix_Sum #2024_05_02_Time_242_ms_ (100.00%)_Space_36.7_MB_ (100.00%)
4
4
5
5
import kotlin.math.max
6
6
import kotlin.math.min
@@ -24,9 +24,9 @@ class Solution {
24
24
}
25
25
var ans: Long = 0
26
26
val s = LongArray (one + 1 )
27
- val n = (min(zero.toDouble() , one.toDouble() ) + 1 ).toInt()
27
+ val n = (min(zero, one) + 1 ).toInt()
28
28
for (
29
- groups0 in (zero + limit - 1 ) / limit.. min(zero.toDouble() , n.toDouble() )
29
+ groups0 in (zero + limit - 1 ) / limit.. min(zero, n)
30
30
.toInt()
31
31
) {
32
32
val s0 = calc(groups0, zero, limit)
Original file line number Diff line number Diff line change 1
1
package g3101_3200.s3131_find_the_integer_added_to_array_i
2
2
3
- // #Easy #Array #2024_05_02_Time_0_ms_(100.00%)_Space_43_MB_(75.29 %)
3
+ // #Easy #Array #2024_05_02_Time_162_ms_(98.15%)_Space_36.3_MB_(100.00 %)
4
4
5
5
class Solution {
6
6
fun addedInteger (nums1 : IntArray , nums2 : IntArray ): Int {
Original file line number Diff line number Diff line change 1
1
package g3101_3200.s3132_find_the_integer_added_to_array_ii
2
2
3
3
// #Medium #Array #Sorting #Two_Pointers #Enumeration
4
- // #2024_05_02_Time_2_ms_(100.00%)_Space_42.3_MB_(96.46 %)
4
+ // #2024_05_02_Time_189_ms_(84.85%)_Space_40.2_MB_(57.58 %)
5
5
6
6
@Suppress(" NAME_SHADOWING" )
7
7
class Solution {
Original file line number Diff line number Diff line change 1
1
package g3101_3200.s3133_minimum_array_end
2
2
3
- // #Medium #Bit_Manipulation #2024_05_02_Time_1_ms_(92.38%)_Space_40.8_MB_(58.58 %)
3
+ // #Medium #Bit_Manipulation #2024_05_02_Time_131_ms_(90.91%)_Space_33.9_MB_(59.09 %)
4
4
5
5
@Suppress(" NAME_SHADOWING" )
6
6
class Solution {
Original file line number Diff line number Diff line change 1
1
package g3101_3200.s3134_find_the_median_of_the_uniqueness_array
2
2
3
- import kotlin.math.max
4
-
5
3
// #Hard #Array #Hash_Table #Binary_Search #Sliding_Window
6
- // #2024_05_02_Time_47_ms_(100.00%)_Space_56.8_MB_(91.38%)
4
+ // #2024_05_02_Time_733_ms_(100.00%)_Space_75.5_MB_(16.67%)
5
+
6
+ import kotlin.math.max
7
7
8
8
class Solution {
9
9
fun medianOfUniquenessArray (nums : IntArray ): Int {
10
10
var max = 0
11
11
for (x in nums) {
12
- max = max(max.toDouble() , x.toDouble()).toInt( )
12
+ max = max(max, x)
13
13
}
14
14
val n = nums.size
15
15
val k = (n.toLong() * (n + 1 ) / 2 + 1 ) / 2
You can’t perform that action at this time.
0 commit comments