SHARE
TWEET

Untitled

Siri0n Oct 22nd, 2015 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function next(p){
  2.         var i = p.length - 1;
  3.         while(i + 1 && p[i] < p[--i]);
  4.         if(i + 1){
  5.                 var j = p.length;
  6.                 while(p[--j] < p[i]);
  7.                 var s = p[j];
  8.                 p[j] = p[i];
  9.                 p[i] = s;
  10.                 j = 1;
  11.                 while(i + 2*j < p.length){
  12.                         s = p[i + j];
  13.                         p[i + j] = p[p.length - j];
  14.                         p[p.length - j++] = s;
  15.                 }
  16.                 return p;      
  17.         }else{
  18.                 return null;
  19.         }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top