Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
When counting you ignore case, but when building the result string you don't.
Also,
given == ""
is not how you compare strings in C.Hi! While I was looking at my solution, I changed something not important and it said all tests are passed and accepted my solution; however, after I tried the same solution it accepted, it gave error at the 7th test case again as usual.
It might be an issue or I was lucky. Nevertheless, I have no clue what is going on.
This comment is hidden because it contains spoiler information about the solution
Thank you so much for your feedback!!! I've learned a lot!!
In the random tests
arr2
is the expected solution,arr
is the result of yourDuplicateEncoder
function.!strcmp(arr, arr2)
is false if the two don't match.I just submitted my solution successfully, and also didn't see an obvious error in the tests.
If your problem persists, please post your solution here (and make sure to mark it as "having spoiler content").
There are several problems with your approach:
malloc(strlen(str))
doesn't allocate enough space for the string and the terminating'\0'
.p[i]
andp[j]
you only convert the first one to lowercase.DuplicateEncoder("aA")
andDuplicateEncoder("AA")
should both return"))"
.*(res + i)
accesses unknown data, possibly even a')'
.Also, why the complicated
memset(res + i, ')', 1);
instead ofres[i] = ')';
?Did you modify the argument instead of allocating space for the result?
In C:
The expression !strcmp(arr, arr2) is false.
Still, I get all the test cases correctly. Is there something wrong?