We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
@AbshishekVermaIIT - As you mentioned in point 6:
If we always need to pick the lowest character seen so far, unless it is critically required to be placed, consider the scenario for "beiouuoieb".
In this case, while traversing right to left, smallest character seen so far is till index 4(u -> right to left) is 'b'.
we may hold this character and never hold e (after that).
as b < e and b is also not critically required as we will consider it for final result at last character at index 9.
so the output will become - 'buoie'
We would need a backtracking here which is missing in this algo right?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse Shuffle Merge
You are viewing a single comment's thread. Return to all comments →
@AbshishekVermaIIT - As you mentioned in point 6: If we always need to pick the lowest character seen so far, unless it is critically required to be placed, consider the scenario for "beiouuoieb".
In this case, while traversing right to left, smallest character seen so far is till index 4(u -> right to left) is 'b'. we may hold this character and never hold e (after that). as b < e and b is also not critically required as we will consider it for final result at last character at index 9.
so the output will become - 'buoie' We would need a backtracking here which is missing in this algo right?