当前位置: 首页 > news >正文 leetcode之字符串中的第一个唯一字符 news 2024/5/20 3:10:07 题目描述 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 案例 s = "leetcode" 返回 0.s = "loveleetcode", 返回 2. 源代码 class Solution:def firstUniqChar(self, s):""":type s: str:rtype: int"""for i in range(len(s)):if s[i] not in s[i+1:] and s[i] not in s[:i]:return ireturn -1 查看全文 http://www.taodudu.cc/news/show-1782109.html 相关文章: 【physx/wasm】在physx中添加自定义接口并重新编译wasm excel---常用操作 Lora训练Windows[笔记] linux基础指令讲解(ls、pwd、cd、touch、mkdir) InnoDB 事务处理机制 启明云端ESP32 C3 模组WT32C3通过 MQTT 连接 AWS 哈希表中处理冲突的方法 SENet算法解析 SNIP物体检测算法理解 yolov3聚类自己数据的anchor box Ubuntu下安装qt57creator-plugin-ros,在QT中进行ROS开发(亲测有效) ROS下面调用自定义的头文件和.cpp/.so文件(亲测有效) C++调用编译好的darknet来进行物体监测 hard-negative mining详细介绍 yolov3中如何进行聚类得到anchor box的 ubuntu16.04下编译安装Autoware catkin_make和cmake 深度学习三种分割定义 基于激光雷达点云数据的目标检测 递归和循环两种方式求解连续数的相加 PCL中把txt文件转换成.pcd文件(很简单) pcl对点云进行直通滤波 error: (-205:Formats of input arguments do not match) All the matrices must have the same data type ubuntu16.04下Qt无法输入中文注释 ROS下sensor_msgs::ImagePtr到sensor_msgs::Image之间的转换 ROS下同时接收多个话题并实现相机和雷达的数据融合 柱状图之最大矩形面积 哈希函数的构造方法以及哈希表解决冲突的方式 回旋镖的数量 伪代码之KMeans和DBSCAN leetcode之有效的括号 leetcode之每日温度 leetcode之逆波兰表达式 leetcode之二叉树的中序遍历 机器学习深度学习面试宝典-深度学习500问 leetcode之删除排序数组中的重复项
题目描述 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 案例 s = "leetcode" 返回 0.s = "loveleetcode", 返回 2. 源代码 class Solution:def firstUniqChar(self, s):""":type s: str:rtype: int"""for i in range(len(s)):if s[i] not in s[i+1:] and s[i] not in s[:i]:return ireturn -1