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.
You've got to find an optimal approach mathematically and logically speaking to not go through all numbers one by one
it's in the description
Well, you are saving each digits to an array. If you look at the sample tests,
36123011
will results in277872985
(277 million) digits. Array cannot store that many items. You need to look for alternative way to count them.U have to return a pair of strings not a single one. U didnt read the description carefully. It sayz return odds and even indexes capitalized. Check again.
I am unsure if you have fixed you issue or not, but when I attempt to run your code, I get this: no viable conversion from 'std::string' (aka 'basic_string') to 'pair<std::string, std::string>' (aka 'pair<basic_string, basic_string >')
pair<string,string> actual = capitalize(s);
Why?
The reason for this is because your function, which you have named capitalize; does not match it's output with what the test requires. The test requires an output of std::pair<std::string, std::string>, not simple an std::string.
that just means there are more tests in the section of the full test suite. Print the inputs to the console.
Write a better code.
I am facing the timeout issue. But when I tried the same code in leetcode, there's no issue. Could you give me a hint to optimize my code.
You'd better use markdown tags to format your code or it's very discomfortable to read, see: how-to-format-code-in-markdown.
Hard to say what caused undefined behaviour without seeing your code. You may post it (with a spoiler flag) and maybe receive more help.
There is a problem with initial code, there are already open issues about that. You need to include some additional header for random tests to pass, for example
#include <cstring>
.Hi, please say which language you're using and use markdown tags to format your code or it's very discomfortable to read, see: how-to-format-code-in-markdown. Your code is incomplete, it's hard to check anything.
Please mark your post as having spoiler content next time and read this too: https://docs.codewars.com/training/troubleshooting#post-discourse