• 算法冲刺


    单调栈 stack

    https://leetcode-cn.com/problems/daily-tempratures/

    根据每日 气温 列表,请重新生成一个列表,对应位置的输入是你需要再等待多久温度才会升高超过该日的天数。如果之后都不会升高,请在该位置用 0 来代替。

    例如,给定一个列表 temperatures = [73, 74, 75, 71, 69, 72, 76, 73],你的输出应该是 [1, 1, 4, 2, 1, 1, 0, 0]。

    提示:气温 列表长度的范围是 [1, 30000]。每个气温的值的均为华氏度,都是在 [30, 100] 范围内的整数。


    使用单调递减stack

    class Solution(object):
        def dailyTemperatures(self, T):
            """
            :type T: List[int]
            :rtype: List[int]
            """
            stack = []
            ans = [0]*len(T)
            
            for i,t in enumerate(T):
                while stack and t > T[stack[-1]]:
                    ans[stack[-1]] = i-stack[-1]
                    stack.pop()            
                stack.append(i)
    
            return ans
    

     形象说明的例子:

    拓扑排序

    https://leetcode-cn.com/problems/queue-reconstruction-by-height/

    时间复杂度O(N^2)

    当然使用先排序再插入的思路也可以!!!时间复杂度一样。

     /**
         * 解题思路:先排序再插入
         * 1.排序规则:按照先H高度降序,K个数升序排序
         * 2.遍历排序后的数组,根据K插入到K的位置上
         *
         * 核心思想:高个子先站好位,矮个子插入到K位置上,前面肯定有K个高个子,矮个子再插到前面也满足K的要求
         *
         * @param people
         * @return
         */
        public int[][] reconstructQueue(int[][] people) {
            // [7,0], [7,1], [6,1], [5,0], [5,2], [4,4]
            // 再一个一个插入。
            // [7,0]
            // [7,0], [7,1]
            // [7,0], [6,1], [7,1]
            // [5,0], [7,0], [6,1], [7,1]
            // [5,0], [7,0], [5,2], [6,1], [7,1]
            // [5,0], [7,0], [5,2], [6,1], [4,4], [7,1]
            Arrays.sort(people, (o1, o2) -> o1[0] == o2[0] ? o1[1] - o2[1] : o2[0] - o1[0]);

            LinkedList<int[]> list = new LinkedList<>();
            for (int[] i : people) {
                list.add(i[1], i);
            }

            return list.toArray(new int[list.size()][2]);
        }

    DP类题目

    https://leetcode-cn.com/problems/as-far-from-land-as-possible/ 推导公式

    双指针题目

    https://leetcode-cn.com/problems/subarrays-with-k-different-integers/

    https://leetcode-cn.com/problems/game-of-life/

    https://leetcode-cn.com/problems/brick-wall/

    就一个trick,没啥说的。

    https://leetcode-cn.com/problems/task-scheduler/

    贪心,数学题目,非常死,不是好题目。

    https://leetcode-cn.com/problems/find-the-town-judge/

    https://leetcode-cn.com/problems/decrease-elements-to-make-array-zigzag/

    https://leetcode-cn.com/problems/find-words-that-can-be-formed-by-characters/ 属于简单题目 直接统计字母表 chars 中每个字母出现的次数,然后检查词汇表 words 中的每个单词,如果该单词中每个字母出现的次数都小于等于词汇表中对应字母出现的次数,就将该单词长度加入答案中。

    https://leetcode-cn.com/problems/subarrays-with-k-different-integers/

    题意理解完全无误即可简单解。

    二进制中最大的矩形

    https://leetcode-cn.com/problems/design-log-storage-system/ ???会员???貌似二分查找上下界

  • 相关阅读:
    Numpy
    Homer SIP capture and VoIP Monitoring Install Guide
    How to install FreeSWITCH in Centos 7
    Media Samples
    lavfi
    Jitsi Sip Communicator Source Code Build Guide for Windows
    How to install Asterisk 13 with WebRTC support in CentOS
    How to build PJSIP with WebRTC
    WebRTC & SIP: The Demo
    WebRTC tutorial using SIPML5
  • 原文地址:https://www.cnblogs.com/bonelee/p/12045947.html
Copyright © 2020-2023  润新知