[小米OJ] 11. 构建短字符串
思路
排序后对两个字符串遍历
function solution(line) { var str = line.split(" "); var str1 = str[0].split("").sort(); var str2 = str[1].split("").sort(); var i = 0, j = 0; while (j < str2.length && i < str1.length) { if (str1[i] == str2[j]) { i++; j++; } else if (str1[i] < str2[j]) { break; } else { j++; } } return i < str1.length ? false + "" : true + ""; }