-
Notifications
You must be signed in to change notification settings - Fork 94
Added tasks 1327, 1341, 1478, 1517, 1633 #1507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tasks 1327, 1341, 1478, 1517, 1633 #1507
Conversation
class SolutionTest { | ||
@Test | ||
void test() { | ||
assertThat(new Solution().decode(""), equalTo("")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests
internal class SolutionTest {
@Test
fun minFlips() {
assertThat(Solution().minFlips("10111"), equalTo(3))
}
@Test
fun minFlips2() {
assertThat(Solution().minFlips("101"), equalTo(3))
}
@Test
fun minFlips3() {
assertThat(Solution().minFlips("00000"), equalTo(0))
}
}
// #Medium #String #Greedy | ||
|
||
public class Solution { | ||
public String decode(String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add solution
class Solution {
fun minFlips(target: String): Int {
var flipCount = target[0].code - 48
var prev = target[0]
for (ch in target.toCharArray()) {
if (ch != prev) {
flipCount++
prev = ch
}
}
return flipCount
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solutions 1478 and 1529 are already existed
Kudos, SonarCloud Quality Gate passed!
|
✅ |
No description provided.