class Solution { public void nextPermutation(int[] nums) { int i=nums.length-1; while(i>0&&nums[i-1]>=nums[i])i--; if(i==0) { Arrays.sort(nums); return; } int j=i-1; i=nums.length-1; while(nums[j]>=nums[i])i--; swap(j, i, nums); i=nums.length-1; j++; while(j