Codility | OA | Generate N letters that have odd counts
Anonymous User
516

The question was that you had to generate N characters for a string but each letter that was generated needed to have an odd count. Anyone that can help solve it as I failed it

Some examples are:
N=1 out="a"
N=5 out="abbbc"

N can go up to 200,000

Now I think about it, an easy solution maybe if N=odd then add N * "a" or if even had N-1 * "a" + "b" . I tried something different which did work but I think was too slow maybe

Q2) You have a String S and a cost array C, where S[i]'s cost of removal is C[i]. You needed to remove all characters which were next to duplicates of itself and at the most minimum cost. Then just output the cost of removing all the duplicates

Examples:

"aabbcc" [1,2,1,2,1,2] = 3

I got this question correct but probably failed as I messed up the easier question

Comments (2)