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 misunderstood the problem.
The "needle" string is given to you as the argument
str
. The "haystack" string is not given to you as an explicit value, but it is fixed, has a predetermined, well known form: it's a string created by concatenation of all narural numbers. It starts with"12345678910111213"
and continues up to infinity, or, if you prefer, as long as you need to find in it all numbers given to you as inputs.As said above, the
indexOf
will not work well for this problem, because the haystack is very, very, very large. If you want to, you can try to create it withstring.Join("", Enumerable.Range(1, Infinity))
, which, obviously, will not work, because there is not enough memory to build such a large string (you can replace theInfinity
with a sufficiently large numeric value, but it will be still too much to build such string).The whole trick to this difficult task is to not build the haystack, but to exploit its well known structure and find the answer without building the long string.
Did you just create any string you wanted? Well then it's wrong. The string (part of it) is given to you, but you have to expand it yourself. It's numbers from 1 to infinity, joined together in a string. Note that using this method, you will eventually run out of memory.
.
OK. i changed description to say
percentages of the total
...You need to represent the percentage of each element. For example, if the 6 values are [0, 2, 1, 2, 2, 3], then the percentages would be [0%, 20%, 10%, 20%, 20%, 30%] respectively.