int InversionNumber(char* s,int len) { int ans=0; //s逆序数 int A,C,G; //各个字母出现次数,T是最大的,无需计算T出现次数 A=C=G=0; for(int i=len-1;i>=0;i--) { switch(s[i]) { case 'A':A++;break; //A是最小的,无逆序数 case 'C': { C++; ans+=A; //当前C后面出现A的次数就是这个C的逆序数 break; } case 'G':…
本问题出自:微软2014实习生及秋令营技术类职位在线测试 (Microsoft Online Test for Core Technical Positions) Description Find a pair in an integer array that swapping them would maximally decrease the inversion count of the array. If such a pair exists, return the new inversio…