题意: 面试题 16.01. 交换数字
/**
* @param {number[]} numbers
* @return {number[]}
*/
var swapNumbers = function(numbers) {
numbers.push(numbers.shift());
return numbers;
};
题意: 1365. 有多少小于当前数字的数字
/**
* @param {number[]} nums
* @return {number[]}
*/
var smallerNumbersThanCurrent = function(nums) {
let len = nums.length;
let arr = [];
for(let i = 0; i < len; i++){
let sum = 0;
for(let j = 0; j < len; j++)
if (nums[j] < nums[i]) sum++;
arr[i] = sum;
}
return arr;
}