Sunday, July 1, 2018

Leetcode 316: Remove duplicate letters

July 1, 2018

Introduction


It is my second hard level algorithm on July 1 2018 Canada day. It is called Remove duplicate letters. I like to work on the algorithm 30 minutes. Now it is 1:39 PM, I like to work until 2:10 PM.

Remove duplicate letters


Now it is 1:50 PM. I am thinking about using stack to store chars and then I can do backtracking to clean up the stack and put the smallest char in the stack first. Of course I can do some calculation first, count the number for each characters.

Now it is 1:52 PM. Let me check the answer.

One of solutions


Here is the blog I read for the solution. It is similar to the sliding window.



No comments:

Post a Comment