Love丶FFC's Blog
实现一个算法确定字符串中的字符是否均唯一出现
样例1
输入: "abc_____"
输出: false
样例2
输入: "abc"
输出: true
如果不使用额外的存储空间,你的算法该如何改变?
1.字符串比较
2.枚举算法
3.bool变量减少比较次数
package LintCode_Easy; import java.util.Scanner; public class _157 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s = scanner.next(); boolean judge = true; for(int i=0;i<s.length();i++) { for(int j=i+1;j<s.length();j++) { if(s.charAt(i)==s.charAt(j)) { System.out.println("false"); judge=false; break; } } if(judge==false) { break; } } if(judge==true) { System.out.println("true"); } } }
public class Solution { public boolean isUnique(String str) { boolean judge = true; for(int i=0;i<str.length();i++) { for(int j=i+1;j<str.length();j++) { if(str.charAt(i)==str.charAt(j)) { judge=false; break; } } if(judge==false) { break; } } return judge; } }
Jorcift
buy propecia uk After discontinuing the pill, ovulation and fertility should resume within a month s time
intuido
Special thanks to the nursing team of the heart failure intensive care unit of Ziekenhuis Oost Limburg for their invaluable help in acquiring the data soft tab cialis
intuido
order cialis online When evaluating the patient, the physician should take note of the current diet regimen, the use of any sedatives or hypnotics, and the nature and extent of the patient s exercise habits
ZKHbQAg
84 elisartan or embusartan or forasartan or milfasartan or pratosartan or KT3 671 or saprisartan or zolasartan generic 5mg cialis best price After that, Li Gu dispatched fifty light boats and thousands of sailors to shoot tens of thousands of Pingnan s edicts prepared in advance along the Yangtze tubes tied low libido River can viagra treat erectile dysfunction to the south of the Yangtze River