/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class nonStatic
{
public boolean isUnique(String str)
{
if(str.length() > 256)
return false;
boolean[] charset = new boolean[256];
for (int i =0;i<str.length();i++)
{
int val = str.charAt(i);
if(charset[val])
return false;
charset[val] = true;
}
return true;
}
}
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
boolean t;
nonStatic n = new nonStatic();
t = n.isUnique("sd");
System.out.println("hi" + t);
}
}
No comments:
Post a Comment