C 筆試彙總(11)

2021-09-28 05:03:18 字數 778 閱讀 9068

求最長字元的無重複子串

(別的例子看不懂,就寫了個最簡單的暴力求解,對於有時間複雜度要求的題目不適用)

例 輸入:pwwkew

輸出:最長子串長度:3

最長子串為:wke

思路:首先對輸入求出所有的子串,然後對每乙個子串進行查重,並記錄下無重複子串的開始位置,最長長度。最後輸出。

#include

#include

#include

#include

using

namespace std;

intchachong

(vector<

char

> a)

;int

main()

if(chachong

(a)==0)

//對子串進行查重,若有重複則跳出這一次迴圈

else}}

} cout <<

"最長子串長度:"

<< max << endl;

cout <<

"最長子串為:"

;for

(int i = start; i < start + max; i++

) cout << endl;

system

("pause");

}//對子串進行查重,若有重複則返回0,

intchachong

(vector<

char

> a)

else}}

}}

c 筆試題彙總 2

1.以下三條輸出語句分別輸出什麼?char str1 abc char str2 abc const char str3 abc const char str4 abc const char str5 abc const char str6 abc cout str1 str2 cout cout ...

筆試題彙總

對於t n a t n b c n k t 1 c 這樣的遞迴關係,有這樣的結論 if a b k t n o n logb a logb a b為底a的對數 if a b k t n o n k logn if a b k t n o n k a 25 b 5 k 2 a b k 故t n o n...

微軟筆試題 彙總

1.臨界變數critical section的概念 還有semaphore,thread類似的這些 程序進入臨界區的排程原則是 如果有若干程序要求進入空閒的臨界區,一次僅允許乙個程序進入。任何時候,處於臨界區內的程序不可多於乙個。如已有程序進入自己的臨界區,則其它所有試圖進入臨界區的程序必須等待。進...