JAVASCRIPT ||Effective Solution || Easy To Understand || With Explanation ||Beginner Friendly||
\nvar removeDuplicateLetters = function(s) {\n    let stk = []; // Create a stack ie, an array\n    for(let i = 0; i < s.length; i++){ //loop through the string
```\nvar removeDuplicateLetters = function(s) {\n    let stk = []; // Create a stack ie, an array\n    for(let i = 0; i < s.length; i++){ //loop through the string\n        let letter = s[i]; \n        if(stk.includes(letter))  //if the stk already contains the letter skip \n            continue;\n        while(stk[stk.length-1] > letter && s.substring(i).includes(stk[stk.length-1]))  \n\t\t{\n\t\t/*peek stack and check if the top letter has higher order than incoming letter and\n\t\tthe top letter must be present in the remaining sub-sting. */\n            stk.pop(); //pop all such elements\n\t\t}\n        stk.push(letter); //push the letter\n    }\n    return stk.join(\'\'); //convert the stk into a string and return it.\n};\n```\n\nIts okay if you did not get the solution in the first try, don\'t give up!\nPlease do UPVOTE if you find it helpfull.... I know this is not the best solution to this problem but this is what I came up with.\nHave fun Coding!! Cheers!
['Monotonic Stack', 'JavaScript']