0
点赞
收藏
分享

微信扫一扫

力扣——判断字符是否唯一

深夜瞎琢磨 2022-03-12 阅读 45

在这里插入图片描述

package 力扣;

import java.util.Scanner;

public class 判断字符是否唯一 {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int head = 0;
		int temp = 0;
		boolean bool = true;
	
		while(head<s.length()-1) {
			temp++;
			if(s.charAt(head)==s.charAt(temp))
			{
				bool = false;
				break;
			}
			if(temp == s.length()-1) {
				head++;
				temp = head;
			}
		}
		System.out.println(bool);
	}	
	
}

举报

相关推荐

0 条评论