Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xjq7 committed Sep 27, 2024
1 parent 25a3e69 commit 86d607d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export default [
text: '扫盲',
link: '/Knowledge/Literacy',
},
{
text: '架构',
link: '/Knowledge/Architect',
},
],
},
{
Expand Down
5 changes: 5 additions & 0 deletions docs/Knowledge/Architect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[toc]]

# 架构

## 常见的架构设计
26 changes: 26 additions & 0 deletions docs/Knowledge/Base.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,3 +878,29 @@ djb2 是一个产生随机分布的的哈希函数
return edge * edge
};
```

- :yellow_circle: [53. 最大子数组和](https://leetcode.cn/problems/maximum-subarray/description/)

状态转移方程: dp[i] = max(dp[i-1]+nums[i], nums[i]), 如果 i 之前的最大值 dp[i-1] 加上当前元素还没有 nums[i] 大
那更新 dp[i] 为 nums[i], 也就是抛弃 i 之前的数字, 因为加上它们 结果反而更小了

```Js
/**
* @param {number[]} nums
* @return {number}
*/
var maxSubArray = function(nums) {
const n = nums.length;
const dp = new Array(n).fill(0);
dp[0] = nums[0];
let ans = dp[0];
for(let i=1;i<n;i++){
dp[i] = Math.max(dp[i-1]+nums[i], nums[i]);
ans = Math.max(ans, dp[i]);
}
return ans
};
```
3 changes: 3 additions & 0 deletions docs/Knowledge/Literacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
// 允许从没有设置默认导出的模块中默认导入, 不影响代码输出, 仅作为类型检查
"allowSyntheticDefaultImports": false,

// 通过为导入内容创建命名空间, 实现 CommonJS 和 ES 模块之间的互操作性
"esModuleInterop": false,

// 不报告执行不到的代码错误
"allowUnreachableCode": false,

Expand Down
1 change: 1 addition & 0 deletions docs/Knowledge/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
- [性能优化专题](./Performance.html)
- [前端工程化](./Engineer.html)
- [扫盲](./Literacy.html)
- [架构](./Architect.html)
- [其他](./Other.html)

0 comments on commit 86d607d

Please sign in to comment.