原理:是临近的数字两两进行比较,按照从小到大或者从大到小的顺序进行交换, function bubbleClick() { var str = "50,1,4,6,9,76,43,22,2,44,7,66"; bubble(str); } function bubble(str) { var a = new Array(); a = str.split(',');//字符串数组, //var a = [50, 1, 4, 6, 9, 76, 43, 22, 2, 44, 7, 66]
A: Subsets 题目:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. 题意:求一个不重复的数组的所有不重复的子集 思路:使用递归的方式求解,在对一个长度为n的数组求所有不重复的子集时:先记录当前的结果集,循环调用n次,对应的情况有是否记录当前位置的值,