A General question on Greedy approach

We see that with some of the problems it is ideal to use this approach and it cover all the testcases but with most of the problem the greedy approach will fail for some scenarios. I want to know how we came to know when greedy approach is suitable for the problem

hello @abhi_11

by proving the logic mathematically ( in most of the cases it is tough )

using logical reasoning to convience youself why a particular step and why no any other step and strong intution ( comes by practice ) helps in identifying greedy solution.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.