技术栈

[leetcode]first-unique-character-in-a-string 字符串中的第一个唯一字符

xiaocong19902024-06-30 17:51

. - 力扣(LeetCode)

复制代码
class Solution {
public:
    int firstUniqChar(string s) {
        unordered_map<int, int> frequency;
        for (char ch: s) {
            ++frequency[ch];
        }
        for (int i = 0; i < s.size(); ++i) {
            if (frequency[s[i]] == 1) {
                return i;
            }
        }
        return -1;
    }
};
上一篇:Java教程之IO模式精讲,NIO+BIO
下一篇:探索Perl的文件测试操作:深入掌握文件属性检查
相关推荐
踩坑记录
6 小时前
leetcode hot100 2.两数相加 链表 medium
leetcode·链表
历程里程碑
9 小时前
滑动窗口---- 无重复字符的最长子串
java·数据结构·c++·python·算法·leetcode·django
TracyCoder123
10 小时前
LeetCode Hot100(18/100)——160. 相交链表
算法·leetcode
放荡不羁的野指针
11 小时前
leetcode150题-滑动窗口
数据结构·算法·leetcode
TracyCoder123
12 小时前
LeetCode Hot100(13/100)——238. 除了自身以外数组的乘积
算法·leetcode
Anastasiozzzz
12 小时前
LeetCode Hot100 215. 数组中的第K个最大元素
数据结构·算法·leetcode
让我上个超影吧
12 小时前
【力扣76】最小覆盖子串
算法·leetcode·职场和发展
求梦820
14 小时前
【力扣hot100题】合并两个有序链表(22)
算法·leetcode·链表
踩坑记录
14 小时前
leetcode hot100 21.合并两个有序链表 链表 easy
leetcode
IT_Octopus
14 小时前
力扣热题100 20. 有效的括号
算法·leetcode
热门推荐
01GitHub 镜像站点02OpenCode 入门教程:介绍 · 安装 · 配置第三方 API (如 Claude)03Clawdbot 中文汉化版 接入微信、飞书04一种新的LCA算法05Claude Code Skills 实用使用手册06【网络安全测试】Burp Suite工具使用说明、配置及常见问题(有关必回)07在Trae中使用Pencil MCP08零门槛部署本地 AI 助手:Clawdbot/Meltbot 部署深度保姆级教程09UV安装并设置国内源10struts2 XML外部实体注入漏洞复现(CVE-2025-68493)