首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

CareerTop Question 一

2012-10-07 
CareerTop Question 1Data Structures - Arrays and Strings:Implement an algorithm to determine if a s

CareerTop Question 1

Data Structures - Arrays and Strings:

Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?

My Original Solution:

private static boolean isUniqueStr(String str) {int checker = 0;for (int i = 0; i < str.length(); i++) {int val = str.charAt(i) - 'a';if ((checker & (i << val)) > 0) {return false;}checker |= (1 << val);}return true;}

?

Have no idea about how to check unique string without any data structure.

热点排行