How can you remove duplicate characters in a string?

前端 未结 20 2289
离开以前
离开以前 2020-12-05 16:39

I have to implements a function that takes a string as an input and finds the non-duplicate character from this string.

So an an example is if I pass string str = \"

20条回答
  •  情书的邮戳
    2020-12-05 17:08

    It sounds like homework to me, so I'm just going to describe at a high level.

    • Loop over the string, examining each character
    • Check if you've seen the character before
      • if you have, remove it from the string
      • if you haven't, note that you've now seen that character

提交回复
热议问题