Nested ternary operators are a hell to maintain. Not a good practice.
still better than those hacky stream solutions
I can't see any updates to the Java test code?
Shouldn't be that array final then ?
This comment is hidden because it contains spoiler information about the solution
Hi. What is the value of string here? There are tests which check the edge case where there are less than n occurrences (which I think is what you're getting at?); can you give a link to a solution that passes all the tests that you believe is incorrect? It may be the case that the random tests need to be improved to ensure this is also checked there, but as it stands your issue hasn't got enough info for me to do anything about it (FYI am only speaking for Python, haven't checked the position for the C translation).
This solution does not honour "If there are less than n occurrences of the substring, return -1". It will fail e.g. for FindOccurrence.findNthOccurrence("a", "aaa", 5) where it returns 0 instead of -1.
FindOccurrence.findNthOccurrence("a", "aaa", 5)
Doen't work properly with e.g. FindOccurrence.findNthOccurrence("a", "aaaaa", 5) where it returns 3 instead of 4. :-)
FindOccurrence.findNthOccurrence("a", "aaaaa", 5)
Can someone clarify why he is using "% modulus"? Could it be left without it?
Could you explain, what do you mean?
Are there any examples?
Wow, a nice example of how much difference the choice of programming language can make. Thanks for the explanation. So I'm going to correct myself: It's not the kata. But it's the Java translation (or the language itself) which makes things very difficult.
Java. The description says "The integer will be a whole number between 1 and 50" but fixedTests() and randomTests() also include zero.