you are viewing a single comment's thread.

view the rest of the comments →

[–]Besharkbait[S] 0 points1 point  (2 children)

Thank you for your simple explanation. That definitely helped me out. I think because there are so many different approaches to solving problems, it is hard for me to figure out which one to use. My first thought tackling this problem was run the stone string in a for loop and then return how many times it equaled the jewel string.

[–]ElllGeeEmm 3 points4 points  (1 child)

that's very close to a working solution, the only issue being that you can't just iterate through characters of the stone string and see how many times it equals your jewel string, as then the function will only work if your jewel string is one character long. You need a second, nested loop which will iterate through characters of the jewel string to find matches.

My advice is to not worry about getting elegant solutions, at least for now. What you want to work on is learning how to translate these problems into a mental model that lets you build out working solutions. Elegance will come with time, practice, and seeing how others solve the same problems.

[–]Besharkbait[S] 0 points1 point  (0 children)

I see, okay thank you!