public class Demo { /** * 去掉重复值 */ public static void main(String[] args) { String test = "100,120,166,1555,120,150,100"; String[] test1 = test.split(","); ArrayList list = new ArrayList(); for (int i = 0; i < test1.length; i++) { i…
Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For example, with A = "abcd" and B = "cdabcdab". Return 3, because by repeating A three…
Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For example, with A = "abcd" and B = "cdabcdab". Return 3, because by repeating A three…
// split():字符串中的方法,把字符串转成数组. // sort():数组中的排序方法,按照ACALL码进行排序. // join():数组中的方法,把数组转换为字符串 function demo(str) { var arr = str.split(''); //把字符串转换为数组 str = arr.sort().join(''); //首先进行排序,这样结果会把相同的字符放在一起,然后再转换为字符串 var value = ''; var index = 0; var re = /…