No387FirstUniqueCharacterInAString

来源:互联网 发布:sqlserver 认证 编辑:程序博客网 时间:2024/06/06 05:06

思路

  • First one is two loops to find. Two pointers.
    • Logic Loopholes
      • String s = “z”
      • Only compares the i behind is not right. You have to check every one
      • not time efficient
  • Second thought, inspired by others, use frequency
    • Logic Loophole: after the frequency is got. you have to return the index of the character, not the character itself
  • Third thought is the optimization of the second thought. use just one loop
  • Forth, use bitMap
  • Fifth, Use map and set together
0 0
原创粉丝点击