FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

minimum lexicographical rotation · gnaleep/Algorithm-Code-Library@2fcf4bc · GitHub

Commit 2fcf4bc

Browse files
committed
minimum lexicographical rotation
1 parent 07038f4 commit 2fcf4bc

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
int minmove(char *inp,int len){
2+
int ret=0,l=0,idx=1;
3+
while(ret+l+1<len && idx<len){
4+
int cp=inp[ret+l]-inp[(idx+l)%len];
5+
if(!cp) l++;
6+
else if(cp<0) idx+=l+1,l=0;
7+
else ret=max(ret+l+1,idx), idx=ret+1, l=0;
8+
}
9+
return ret;
10+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL