We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ce9443 commit ea2bc23Copy full SHA for ea2bc23
src/test/kotlin/com/sample/umar/leetcodemediums/okx/TwoStringOfSame.kt
@@ -20,15 +20,12 @@ fun main() {
20
}
21
22
fun minOperationsToMakeEqual(A: String, B: String): Int {
23
- if (A.length != B.length) return -1
24
-
25
var count01 = 0
26
var count10 = 0
27
28
for (i in A.indices) {
29
if (A[i] == '0' && B[i] == '1') count01++
30
if (A[i] == '1' && B[i] == '0') count10++
31
32
33
- return if (count01 == count10) count01 else -1
+ return maxOf(count01, count10)
34
0 commit comments