Guys hard to do intermediate algorithms, need advice

Guyz, what happened to me? hard to find solution to an intermediate algorithmic questions. Do I need to read some books about algorithmic thinkings or just continue exercise though?

Just try to write down some steps on paper first and then try to put those ideas in code. If you get stuck, reply back here and paste your code into a post.

Remember to precede code with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard.