Remove Duplicate Letters -- LeetCode Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Example: Given"bcabc" Return"abc...
1 class Solution { 2 public String removeDuplicateLetters(String s) { 3 int [] last = new int[26]; 4 for(int i = 0; i<s.length(); i++){ 5 last[s.charAt(i)-'a'] = i; 6 } 7 8 Stack<Character> stk = new Stack<>(); 9 boolean [] used = new boolean[26]; 10 for...
Given a strings, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Note: This question is the same as 1081:https://leetcode.com/problems/smallest-subsequence-of-distinct-...
Given a strings, remove duplicate letters so that every letter appears once and only once. You must make sure your result isthe smallest in lexicographical orderamong all possible results. Note:This question is the same as 1081:https://leetcode.com/problems/smallest-subsequence-of-distinct-chara...
Returns a newly constructed string object with its value initialized to a copy of a substring of this object.The substring is the portion of the object that starts at character position pos and spans len characters (or until the end of the string, whichever comes first)....