美文网首页程序员
2020-05-24 Leetcode两日打卡 - 数组

2020-05-24 Leetcode两日打卡 - 数组

作者: 奥斯本 | 来源:发表于2020-05-24 23:31 被阅读0次

    【刷题汇报】5.23 - 2题

    #3 Sliding window,Hashmap. Can be optimized to at most n steps.

    #75 Three pointers. The first tracks the rightmost index of the 0 zones, the second is the current index being considered, and the third tracks the leftmost index of the 2 zones. The second pointer do not need to go through the whole list - the loop ends if the second pointer encounters the third pointer or the first pointer encounters the third pointer

    【刷题汇报】5.24 - 3题

    #88 Two pointers both starting from the end of the array. The reason to start from the end is to avoid replacing the original numbers on num1 (num1 are filled with unimportant numbers in the end). Space Complexity: O(1). Time Complexity: O(m+n)

    #125 Two pointers. One starts from the beginning of the array, the other starts from the end of the array. Whenever the lower case of the letters these pointers point to are not the same, the program returns false.

    #76 Sliding window. Use two hash maps. the first hash map is to store the required characters and the corresponding number of occurrences. The second one is to track the required characters and the number of occurrences during the traversal of s.

    相关文章

      网友评论

        本文标题:2020-05-24 Leetcode两日打卡 - 数组

        本文链接:https://www.haomeiwen.com/subject/fwosahtx.html