studentharsha
BAN USER- 0of 0 votes
AnswersImplement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
My version of code is this,static boolean giveresult(String s) { boolean answer=true; for(int i=0;i<s.length();i++) { char x = s.charAt(i); if(s.substring(i+1).contains(x+"")) {answer=false; break; } } return answer; }
Can I know what would be the time complexity.?
- studentharsha in United States| Report Duplicate | Flag | PURGE
N/A None - 0of 0 votes
AnswerImplement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
- studentharsha in United States
My version of code is this,
static boolean giveresult(String s)
{
boolean answer=true;
for(int i=0;i<s.length();i++)
{
char x = s.charAt(i);
if(s.substring(i+1).contains(x+""))
{answer=false;
break;
}
}
return answer;
}
Can I know what would be the time complexity.?| Report Duplicate | Flag | PURGE
N/A None