Skip to content

Commit

Permalink
[arts] 2027.07.26
Browse files Browse the repository at this point in the history
  • Loading branch information
iEverX committed Jul 28, 2024
1 parent 620d661 commit 33a2f1a
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions content/arts/2024/07.28.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
+++
title = "ARTS 2024.07.26"
date = 2024-07-28

[taxonomies]
tags = ["ARTS"]
+++

## Algorithm

[2865. 美丽塔 I - 力扣(LeetCode)](https://leetcode.cn/problems/beautiful-towers-i/description/)

单调栈。从前往后,记录当前高度下,左边允许的最大的高度和。注意,如果当前高度大于前一个,可以则高度和增加,如果当前高度小于前边,找到第一个小于自己的下标k,高度和为 headSum[k] + (i - k) * h,i为当前坐标。这是一个单调栈

```java
class Solution {
public long maximumSumOfHeights(int[] heights) {
// height, index, sum
Deque<long[]> stk = new ArrayDeque<>();
stk.addFirst(new long[]{0, -1, 0});
long[] sums = new long[heights.length];
int len = heights.length;
for (int i = 0; i < len; i++) {
long h = heights[i];
while (h <= stk.peekFirst()[0]) {
stk.removeFirst();
}
long[] peek = stk.peekFirst();
long sum = peek[2] + h * (i - peek[1]);
sums[i] = sum;
stk.addFirst(new long[]{h, i, sum});
}

stk.clear();
stk.addFirst(new long[]{0, len, 0});
long ret = 0;
for (int i = len - 1; i >= 0; i--) {
long h = heights[i];
while (h <= stk.peekFirst()[0]) {
stk.removeFirst();
}
long[] peek = stk.peekFirst();
long sum = peek[2] + h * (peek[1] - i);
stk.addFirst(new long[]{h, i, sum});
ret = Math.max(ret, sum + sums[i] - h);
}
return ret;
}
}
```

## Review

- <https://news.ycombinator.com/item?id=41060102>
- <https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github>

Github fork 网络的底层机制,导致用户删除commit、删除repo、private fork的行为与普通用户的认知不一致,删除的数据仍然可以通过存在的fork访问到。

Github了解这个问题,并且在文档中做了说明,但问题仍然是问题

## Tips

## Share

[基本功 | 一文讲清多线程和多线程同步 (qq.com)](https://mp.weixin.qq.com/s?__biz=MjM5NjQ5MTI5OA==&mid=2651778446&idx=1&sn=44306b644777a4d939730e7774071541)

多线程和多线程同步介绍的一篇文章,篇幅很长,涉及到一些cpu底层细节,值得一看

0 comments on commit 33a2f1a

Please sign in to comment.