Longest Substring Without Repeating Characters[leetcode],repeatingleetcode

來源:互聯網
上載者:User

Longest Substring Without Repeating Characters[leetcode],repeatingleetcode

記錄最大的起始位置+hash

int lengthOfLongestSubstring(string s) {        map<char, int> charMap;        int curLen, maxLen = 0,lastIndex = -1;        for (int i = 0; i < s.size(); i++)        {            if (charMap.find(s[i]) != charMap.end() && lastIndex < charMap[s[i]])                    lastIndex = charMap[s[i]];            curLen = i - lastIndex;            maxLen = max(maxLen,curLen);            charMap[s[i]] = i;        }        return maxLen;    }



leetcode是什

裡面有很編程多面試的題目,可以線上編譯運行。難度比較高。如果自己能都做出來,對面大公司很有協助。我就是做的那裡的題目。
 
leetcode中multiply strings出現runtime error,解

leetcode的定位是面試題,不是ACM題
也就是說題目並不是以AC與否來判斷你的答案正確與否的
更重要的是面試的時候給別人的感覺

這本來是一道考察字串表示大數和大叔乘法的題,po主卻用上了stringstream和vector
在面試裡面這樣的答案哪怕最後能得到正確的結果,也不會給面試官留下好的印象。

我會幫你偵錯工具,但是我還是覺得你重新寫一份簡單易懂的更好,避免使用STL和流
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.