※ 引述《NTUmaki (西木野真姬)》之銘言:
: 事情是這樣的,今天下午面了 ByteDance 2023 的缺 (Algorithm Engineer)
: 考了 leetcode 3. Longest Substring Without Repeating Characters
: (https://reurl.cc/WqNV8k)
: 我的解法:
: https://i.imgur.com/o5wrRMo.png
這題應該是用dict,而不是set。用dict來紀錄字元的位置,這樣就不用while來重找。
面試官對你很好,提示你不要用while,讓你想其它方法,可惜你卡在n2,2n的問題上。