Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
算逆序数可以O(n)完成的int count_inver(char *str, int len) { int i; int cnt = 0; int a[4] = {0}; for(i = len - 1; i >= 0; i--) { switch (str[i]) { case 'A': a[1]++; a[2]++; a[3]++; break; case 'C': a[2]++; a[3]++; cnt += a[1]; break; case 'G': a[3]++; cnt += a[2]; break; case 'T': cnt += a[3]; } } return cnt; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator