Find the first un-repeated character in a string

后端 未结 30 1292
猫巷女王i
猫巷女王i 2020-11-27 18:29

What is the quickest way to find the first character which only appears once in a string?

30条回答
  •  失恋的感觉
    2020-11-27 19:18

    In Mathematica one might write this:

    string = "conservationist deliberately treasures analytical";
    
    Cases[Gather @ Characters @ string, {_}, 1, 1][[1]]
    
    {"v"}
    

提交回复
热议问题