剑指offer
第一个只出现一次的字符
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:471193
本题知识点:
字符串
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写).(从0开始计数)
示例1
输入
复制
"google"
"google"
返回值
复制
4
4
上一题
下一题
登录
/
注册
我的提交
编辑器加载中...
public class Solution { public int FirstNotRepeatingChar(String str) { return 0; } }
class Solution { public: int FirstNotRepeatingChar(string str) { } };
# -*- coding:utf-8 -*- class Solution: def FirstNotRepeatingChar(self, s): # write code here
class Solution { public int FirstNotRepeatingChar(string str) { // write code here } }
function FirstNotRepeatingChar(str) { // write code here } module.exports = { FirstNotRepeatingChar : FirstNotRepeatingChar };
function FirstNotRepeatingChar(str) { // write code here }
package main /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param str string字符串 * @return int整型 */ func FirstNotRepeatingChar( str string ) int { // 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