Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
XmchxUp committed May 18, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent a20c86f commit 120bca2
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ The best thing to do is have fun.

- [列表 - 韩立的修炼](/)
- [Hobby Projects](/hobby_projects.md)
- [Kata](/kata.md)
- **2024-05**
- [如何搭建新个网段,并配有一台机器挂载](/2024/05/new_nic_with_hub_switch.md)
- [RC-incubator-answer 论坛](/2024/05/incubator-answer.md)
42 changes: 42 additions & 0 deletions kata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# What can i say

## [114. Flatten Binary Tree to Linked List](https://leetcode.cn/problems/flatten-binary-tree-to-linked-list/)

如果使用 O(n) space 比较简单,前序遍历回放即可。

O(1) space 的话,利用递归思想 flatten(left), flatten(right),最后再将 right, left 合并。

## [199. Binary Tree Right Side View](https://leetcode.cn/problems/binary-tree-right-side-view/)

层序遍历,每层取最后一个元素

## [2462. Total Cost to Hire K Workers](https://leetcode.cn/problems/total-cost-to-hire-k-workers/)

使用两个堆一个维护前面的,一个维护后面的最小 cost
需要注意两个堆中元素不能重复即(2\*candidates+k<=n),如果元素不足,而可以直接排序取。

## [1329. Sort the Matrix Diagonally](https://leetcode.cn/problems/sort-the-matrix-diagonally/)

对角线特性,同一对角线的元素 i-j 都相等,可以先收集,排序,放回。

[数学解法](https://leetcode.cn/problems/sort-the-matrix-diagonally/solutions/2760094/dui-jiao-xian-pai-xu-fu-yuan-di-pai-xu-p-uts8/)

## [1. Two Sum](https://leetcode.cn/problems/two-sum/)

字典运用

## [1017. Convert to Base -2](https://leetcode.cn/problems/convert-to-base-2/)

十进制 转 X 进制

```
n = a * (x)^5 + b * (x)^4 + c * (x)^3 + d * (x)^2 + e * (x)^1 + f * (x)^0
```

本质就是求 abcdef,可以每次求出 f(n%x),然后 n-f,n//=x 就是下一个

## [2007. Find Original Array From Doubled Array](https://leetcode.cn/problems/find-original-array-from-doubled-array/)

首先排序,每次配对最小的元素

## [Training on Decode the Morse code | Codewars](https://www.codewars.com/kata/54b724efac3d5402db00065e/train/go)

0 comments on commit 120bca2

Please sign in to comment.