One of the most important part of solving any problem is the way to or a strategy approach or decompose a problem.There are also different Algorithm Paradigms like Dynamic Programming,Divide and Conquer,Backtracking,etc.Realising which Data Structure to use for a given problem and lots of other stuff
1)So PLZ share your strategy of approaching a problem or decomposing a problem below as answer.
2)Also how do u realise that which sort of Data Structure to use for a given problem.
If I get your question right, you’re asking how do we identify what data structure to use?
Well, if you want tips, then I think these helped me-
Be conceptually aware of different data structures of C++. You cannot think of what you dont know.
Practice. sometimes a problem in contest is nothing but twisted version of some known problem. Experience and intuition grows with practice.
Reduce the problem to a, perhaps mathematical, formal statement. By formal as in, remove the story and ask, “What do I have to code for?”. Is it asking like, I need a the minimum/maximum element along with needing to insert and remove elements? Its priority queue! Is it something like, only the few recent elements matter, and we have to support deletion ? Might be stack.
Paradigm is tricky. At times, even pro coders get confused if its a dp problem, or simple greedy. Only practice and intuition helps here. I know, rough path.
Its practice. I am working hard on programming contests nowadays and I can solve some questions now so I think I can answer this question. You study a data structure, then you solve multiple questions on it and then you encounter something like a property.
For example, when I studied stack I remember that one question where I had to find immediate largest to the right of an element, and now whenever I think maybe it can be done like this stacks come to mind. Same goes for different data structures.
Now coming to thinking approaches in contests can only be developed when you participate in them, practise regularly and read editorials to understand more. There was a time I used to be able to solve only div2 A on codeforces and now with the help of god, I can sometimes able to solve up to div2 D. It is practice and practice only. You will just develop an eye to identify data structures when you practice them, brainstorm in the contest and then think calmly of the problem post contest and then implement it. It is a process, give it some time.