在字符串中找到第一个不重复的字符。 例:对于字符串“hellohehe”,第一个不重复的字符是“o”。 如果每个字符都有重复,则抛出运行时异常。
示例1
输入
"hellohehe"
输出
o
备注:
允许使用集合类
加载中...
import java.util.*; public class Solution { /** * * @param str string字符串 * @return char字符型 */ public char findFirstNonRepeatChar (String str) { // write code here } }
class Solution { public: /** * * @param str string字符串 * @return char字符型 */ char findFirstNonRepeatChar(string str) { // write code here } };
# # # @param str string字符串 # @return char字符型 # class Solution: def findFirstNonRepeatChar(self , str ): # write code here
/** * * @param str string字符串 * @return char字符型 */ function findFirstNonRepeatChar( str ) { // write code here } module.exports = { findFirstNonRepeatChar : findFirstNonRepeatChar };
# # # @param str string字符串 # @return char字符型 # class Solution: def findFirstNonRepeatChar(self , str ): # write code here
package main /** * * @param str string字符串 * @return char字符型 */ func findFirstNonRepeatChar( str string ) byte { // write code here }
/** * * @param str string字符串 * @return char字符型 */ char findFirstNonRepeatChar(char* str ) { // write code here }
"hellohehe"
o