得物笔试
有道算法题是求两个字符串中的最小字串,求大佬帮忙看下是哪里出错了一直提交0%?我自己的测试集都过了,实在不明白为什么会0%
#得物春招##得物app##笔经#
class LongestSubstring { public: int findLongest(string A, int n, string B, int m) { // write code here int aLeft,aRight; int maxLen = 0; for(aLeft = 0,aRight = 0; aLeft < n; aLeft++){ for(int i = 0; i < m; i++){ if(aRight == n){ if(maxLen < aRight-aLeft-1){ maxLen = aRight-aLeft-1; } aRight = aLeft; break; } if(A[aRight] == B[i]){ aRight++; } else{ if(maxLen < aRight-aLeft){ maxLen = aRight-aLeft; } aRight = aLeft; } } } return maxLen; } };
#得物春招##得物app##笔经#