我有一个包含“0123456789?”的字符串。我想
- if first char is not ' ' or '?' and the rest is " ", return the first char
- if last char is not ' ' or '?' and the rest is " ", return the last char
- if the string is only " ", return -1
- and else, return -2
我找到了几个解决方案,但没有一个在速度和良好的编码方面让我满意。谁能想到一个漂亮而优雅的解决方案,可以分享给我吗?!
谢谢你