This are the Steps i follow when i solve algorithms
First of and most importantly
- I try to understand the problem what input do i expect ?
- What are the given constraints?
- what Output is expected from me?
when i feel i do in fact understand the what the input , constraints and output are i then tell myself ,
- based on what i already know how can i approach this problem?
- Does this problem look Like Something that uses loops or recursion(trust me must problems require some kind of iteration)
- Is there any place certain decisons have to be made based on different inpute?
- What are the important calculations that would ensure i get my desired out put?
- i then try to construct each step mentally
Note: Depending on the size of the problem , i might choose to break it down into smaller problems or solve it as a whole(most questions that involve advanced DSA require some form of breaking down especcially if the are unfamiliar to you)
when i've satisfied all this cases i code