Skip to content

Latest commit

 

History

History
54 lines (41 loc) · 1.26 KB

0316-remove-duplicate-letters.adoc

File metadata and controls

54 lines (41 loc) · 1.26 KB

316. Remove Duplicate Letters

{leetcode}/problems/remove-duplicate-letters/[LeetCode - Remove Duplicate Letters^]

Given a string which contains only lowercase letters, 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.

Example 1:

Input: "bcabc"
Output: "abc"

Example 2:

Input: "cbacdcbc"
Output: "acdb"

思路分析

先遍历字符串,统计每个字符的出现次数。

一刷
link:{sourcedir}/_0316_RemoveDuplicateLetters.java[role=include]