首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
第一个只出现一次的字符
[编程题]第一个只出现一次的字符
热度指数:561351
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
在一个长为
字符串中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写).(从0开始计数)
数据范围:
,且字符串只有字母组成。
要求:空间复杂度
,时间复杂度
示例1
输入
"google"
输出
4
示例2
输入
"aa"
输出
-1
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(741)
邀请回答
收藏(1096)
分享
提交结果有问题?
0个回答
242篇题解
添加回答
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
字符串
难度:
0条回答
1096收藏
173536浏览
热门推荐
通过挑战的用户
查看代码
Champ.Ping
2023-02-22 16:37:24
但化芳菲骈蝶舞
2023-02-14 19:56:11
夏桑哥哥
2023-02-03 01:02:32
Tangeri...
2023-01-11 18:27:56
勿忘5
2022-12-16 20:07:12
相关试题
未来工作城市的选择是怎样的?
通用能力
评论
(1)
你说在销售运营这个岗位上会涉及到一...
评论
(1)
“乔布斯不做调查,张小龙不看数据。...
用户研究
评论
(1)
相关性分析有哪些?
评论
(1)
如何检验聚类分析结果
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ public int FirstNotRepeatingChar (String str) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ int FirstNotRepeatingChar(string str) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return int整型 # class Solution: def FirstNotRepeatingChar(self , str ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ public int FirstNotRepeatingChar (string str) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ function FirstNotRepeatingChar( str ) { // write code here } module.exports = { FirstNotRepeatingChar : FirstNotRepeatingChar };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return int整型 # class Solution: def FirstNotRepeatingChar(self , str: str) -> int: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ func FirstNotRepeatingChar( str string ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ int FirstNotRepeatingChar(char* str ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return int整型 # class Solution def FirstNotRepeatingChar(str) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ def FirstNotRepeatingChar(str: String): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ fun FirstNotRepeatingChar(str: String): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ public int FirstNotRepeatingChar (String str) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ export function FirstNotRepeatingChar(str: string): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ func FirstNotRepeatingChar ( _ str: String) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return int整型 */ pub fn FirstNotRepeatingChar(&self, str: String) -> i32 { // write code here } }
"google"
4
"aa"
-1