- Difficulty: Hard
- Given a string consisting of characters 'a', 'b' and/or '?', replace each '?' with 'a' or 'b' so that the longest fragment of the resulting string consisting of equal letters is as short as possible.
- https://app.codility.com/programmers/challenges/gamers_2021/
- https://app.codility.com/programmers/task/fill_the_gaps/
- Result
Good
: Correctness 100%, Performance 100%.OK
: Correctness 100%, Performance <100%.Fail
: Correctness <100%, Performance <100%.
- File naming convention
- Code
A
:Gamers2021A.java
- etc
- Code
File | Complexity | Result | Report |
---|---|---|---|
A |
O(N * log(N)) or O(N) |
Good |
N7PTWR |
File | Complexity | Result | Report |
---|---|---|---|
B |
O(N * log(N)) or O(N) |
Good |
6WTXMU |
- Solution provided by Codility is written in Python and using
yield
command which not available in Java. So no java version implemented as it can't be compared fairly. - Both
A
,B
and Codility solutions are same concepts. A
although earn a Gold award, but actually contains a bug, which failed the following scenario:- input: '
aaaa?bbb?aaa?bbb?aaa?bbb?aaaa
', expected5
(the program returns 4)
- input: '
B
is the bug fix version ofA