I recently just spent 2 days trying to solve an algorithm using the sliding window pattern, I couldn’t do it, so I solved it the only way I knew (using nested loops), but that solution didn’t meet the requirements. Just like you I asked for advice, I was suggested not to spend a whole day tackling an algorithm, I know it’s tempting and that you really want to solve it to prove to yourself that you can do it, but honestly, don’t. Use that time for something more productive, like continuing with your lessons.
If you are as stubborn as me, try not to spend more than 3 hours a day on a specific algorithm, you can always come back the next day to tackle it again and spend another hour or so, but do not spend the whole day because it’s a tremendous waste of time. Here’s a quote from the person who gave me the advice:
Time management and learning when to give up and ask for help is an important life skill to learn as well
When you give up on an algorithm ( which is totally fina by the way) look at other’s people code and go line by line and try to understand their code and the logic they used, if there’s something you don’t understand, research on Google or ask for help, it’s very important that you understand every piece of code when you look at someone else’s solution. Understand the solution, memorize it then come back to the same problem in a week and do it yourself to make sure you understand it.