I started working on String 2, and it was a bit weird for me. It was the first time that I had done Strings in almost over a quarter ! And so when I worked with them, I wasn't used to it. I had forgotten how to format strings. For example, when you want to say the length of the array you would say : nums.length.
But for a string, you would have to say : str.length(). You always have to add parameters to strings, so when I would want to take i, I would have to write str.substring(i), instead of nums[i]. In my opinion, writing arrays is much simpler than strings. I think that it will take me a bit of time to get used to the format of strings.
But either way, I still managed to complete a few problems. I had to go see Mr. Daly. And the problem that we had was, for the first time, a problem with the actual code, and not just the formatting of the code. It took us about 20 minutes to finally solve it.
But that's not the problem that I'll be showing today.
Here is today's problem:
----------------------------------------------------------------------------------------------------------------------------------
Return the number of times that the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count. countCode("aaacodebbb") → 1 countCode("codexxcode") → 2 countCode("cozexxcope") → 2 |
Looking forward to continuing with Strings tomorrow. |
No comments:
Post a Comment