how should i solve problems which asks me to find the minimum no of swaps required to make a string from one form to another …the swapping can be like adjacent elements,or elements from any place,only even or odd indexed elements can be swapped…idk if dp can be used her or not…can u tell me if these kind of problems have a specified approach to be followed
How can i solve these kind of problems?
Hey @neha_153 this totally depends upon question, but mostly these types of questions are greedy/implementation based. Hence to be good at them you should practice.
can u tell me some common good techniques or resources on how to solve…i dont find them in coding block assignments…like if u see such a problem wht is first thing which comes to your brain
Follow the question and see that is it always beneficial to solve for current index first, if it is then its a greedy problem, else you have to think DP(considering every possibility)
eg: https://www.hackerrank.com/challenges/minimum-swaps-2/problem?h_l=interview&playlist_slugs[]=interview-preparation-kit&playlist_slugs[]=arrays
this is greedy one.
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.