publicint[]prevPermOpt1(int[] arr){int len=arr.length;int l=-1,r=-1;int num=0;for(int i =1; i < len; i++){if(arr[i-1]>arr[i]&&(i+1==len||arr[i+1]>=arr[i])){
l = i -1;}if(i==len-1&&l==-1)return arr;}for(int i = l+1; i < len; i++){if(arr[i]<arr[l]&&arr[i]>num){
num=arr[i];
r=i;}}int temp=arr[l];
arr[l]=arr[r];
arr[r]=temp;return arr;}
1、爱生气的书店老板public int maxSatisfied(int[] customers, int[] grumpy, int X) { int len=grumpy.length; int sum=0; for (int i = 0; i < len; i++) { if (grumpy[i]==0) sum+=customers[i]; } int l=0,r=l; int maxThree=0; int max