Contents

ARST打卡第349周

Algorithm

lc85_最大矩形

思路:将每一行视作直方图的底部,统计每列历史连续1的高度,然后对每一行利用单调栈求最大矩形面积。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Solution {
public:
    int maximalRectangle(vector<vector<char>>& matrix) {
        if(matrix.empty() || matrix[0].empty()) return 0;
        int m = matrix.size(), n = matrix[0].size();
        vector<int> heights(n, 0);
        int maxArea = 0;
        for(int i = 0; i < m; ++i) {
            // 统计本行对应的heights
            for(int j = 0; j < n; ++j) {
                if(matrix[i][j] == '1') 
                    heights[j] += 1;
                else
                    heights[j] = 0;
            }
            // 对heights这一行用单调栈求最大矩形
            maxArea = max(maxArea, largestRectangleArea(heights));
        }
        return maxArea;
    }
private:
    int largestRectangleArea(vector<int>& heights) {
        int n = heights.size();
        vector<int> newHeights = heights;
        newHeights.insert(newHeights.begin(), 0);
        newHeights.push_back(0);
        stack<int> st;
        int maxArea = 0;
        for(int i = 0; i < newHeights.size(); ++i) {
            while(!st.empty() && newHeights[i] < newHeights[st.top()]) {
                int h = newHeights[st.top()];
                st.pop();
                int w = i - st.top() - 1;
                maxArea = max(maxArea, h * w);
            }
            st.push(i);
        }
        return maxArea;
    }
};

Review

如何从工作中重拾我们的生活?【TED演讲】

不要让工作定义你,而是让自己定义自己。

除了工作,也要学会更好的生活。

What do you like to do? Just do it。

当然如果mess up活不下去了,也可以做一下job赚点生活费。

人只活一次,做点想做的,mess it up, and learn something,享受过程。

Tip

AntManager Tools,可充分利用多个号的tokens,且可跑终端

有部分安全风险,不要在安全环境使用

Share_Hysteria替换WireGuard解决udpQos问题

Hysteria 使用 QUIC (UDP),为什么不会像 WireGuard 一样被封?

特性 WireGuard Hysteria 2
协议 WireGuard 专有协议 (UDP) QUIC (UDP),伪装成 HTTPS
端口 自定义端口 (如 12709) 443 (标准 HTTPS 端口)
流量特征 明显的 WireGuard 握手包 TLS 1.3 + HTTP/3,看起来像访问网站
伪装 SNI 伪装为 bing.com,被识别为正常 HTTPS 流量

关键区别:Hysteria 2 将流量伪装成访问 Bing 的请求,GFW 难以区分。而 WireGuard 的协议特征明显,容易被识别和封锁。