1 Star 0 Fork 0

孤寂灬无痕/algorithm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
IsUnique.java 894 Bytes
一键复制 编辑 原始数据 按行查看 历史
孤寂灬无痕 提交于 5年前 . 转移
package com.youngdream.algorithm.simple.string;
/**
* @author YangDuan
* @date 2020/3/27 22:01
*/
public class IsUnique {
/**
* 实现一个算法,确定一个字符串 s 的所有字符是否全都不同。
* <p>
* 示例 1:
* 输入: s = "leetcode"
* 输出: false
* <p>
* 示例 2:
* 输入: s = "abc"
* 输出: true
* <p>
* 限制:
* 0 <= len(s) <= 100
* 如果你不使用额外的数据结构,会很加分。
*
* @param astr 给定字符串
* @return 字符是否唯一
*/
public boolean isUnique(String astr) {
for (int i = 0; i < astr.length(); i++) {
for (int j = i + 1; j < astr.length(); j++) {
if (astr.charAt(i) == astr.charAt(j)) {
return false;
}
}
}
return true;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/qq994300880/algorithm.git
git@gitee.com:qq994300880/algorithm.git
qq994300880
algorithm
algorithm
master

搜索帮助