题解 | #构建短字符串#
构建短字符串
http://www.nowcoder.com/practice/a83e1893f5df4285a1796b34e1e7c9b3
利用好 StringBuffer 就解决了 没啥撒获得 看代码吧
import java.util.*; public class Main{ public static void main(String[] args){ int i,j,k; StringBuffer a,b; Scanner sc = new Scanner(System.in); a = new StringBuffer(); b = new StringBuffer(); a.append(sc.next()); b.append(sc.next()); boolean flag = false; for(i=0;i<a.length();i++){ String t = ""+a.charAt(i); if(b.indexOf(t)==-1){ flag = true; break; }else{ b.deleteCharAt(b.indexOf(t)); } } if(flag){ System.out.println("false"); }else{ System.out.println("true"); } } }