マツシタのお勉強

316. Remove Duplicate Letters : Past Google Coding Interview

Problem

leetcode.com

How to Solve

This problem is solved by the following steps.

  1. find out index that each letter appears int the last position
  2. have the indexes calculating at step 1 in a array
  3. sort the arrays created at step2 4 check the string in the adjustment range and find out minimum value

find out index that each letter appears int the last position

this index guarantees that the letter appears the last position. This means that the letter have to be taken by the range to the index. So, I can find out the minimum value in the range.

above steps are like this

Source Code