Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Solution {
- public static String hasUnique(String str) {
- int n = str.length();
- boolean count = true;
- int []s= new int[26];
- int []l= new int[26];
- for(int i=0;i<26;i++){
- s[i]=0;
- l[i]=0;
- }
- for(int i=0;i<n;i++){
- if(str.charAt(i)>='a' && str.charAt(i)<='z')s[str.charAt(i)-'a']++;
- }
- for(int i=0;i<n;i++){
- if(str.charAt(i)>='A' && str.charAt(i)<='Z')l[str.charAt(i)-'A']++;
- }
- for(int i=0;i<26;i++){
- if(s[i]>1 || l[i]>1)count=false;
- }
- if(count==true){
- return ("Yes");
- }
- else{
- return ("No");
- }
- }
- }
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String str = sc.nextLine();
- Solution Obj = new Solution();
- System.out.println(Obj.hasUnique(str));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement