diff --git "a/LeetCode/1821-1830/1823. \346\211\276\345\207\272\346\270\270\346\210\217\347\232\204\350\216\267\350\203\234\350\200\205\357\274\210\344\270\255\347\255\211\357\274\211.md" "b/LeetCode/1821-1830/1823. \346\211\276\345\207\272\346\270\270\346\210\217\347\232\204\350\216\267\350\203\234\350\200\205\357\274\210\344\270\255\347\255\211\357\274\211.md" index 75e4c32c..eaa9b5e6 100644 --- "a/LeetCode/1821-1830/1823. \346\211\276\345\207\272\346\270\270\346\210\217\347\232\204\350\216\267\350\203\234\350\200\205\357\274\210\344\270\255\347\255\211\357\274\211.md" +++ "b/LeetCode/1821-1830/1823. \346\211\276\345\207\272\346\270\270\346\210\217\347\232\204\350\216\267\350\203\234\350\200\205\357\274\210\344\270\255\347\255\211\357\274\211.md" @@ -86,6 +86,8 @@ class Solution { 这还是一道约瑟夫环经典题。 +> 另外一道同款题在 [这里](https://mp.weixin.qq.com/s?__biz=MzU4NDE3MTEyMA==&mid=2247490948&idx=1&sn=a71c4ec3529277ad119702d7dacf510e&chksm=fd9cb69bcaeb3f8d5461518a15d969b45a13558a4c5810100f40200a12aac66f1876f2ef6de7&token=831443013&lang=zh_CN#rd) 🎉🎉 + 每次往同一方向,以固定步长 $k$ 进行消数。由于下一次操作的发起点为消除位置的下一个点(即前后两次操作发起点在原序列下标中相差 $k$),同时问题规模会从 $n$ 变为 $n - 1$,因此原问题答案等价于 `findTheWinner(n - 1, k) + k`。 一些细节,由于编号从 $1$ 开始,在返回答案时我们需要将结果为 $0$ 的值映射回编号 $n$。 diff --git "a/LeetCode/2331-2340/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277\357\274\210\347\256\200\345\215\225\357\274\211.md" "b/LeetCode/2331-2340/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277\357\274\210\347\256\200\345\215\225\357\274\211.md" index 2e81894d..7df054a9 100644 --- "a/LeetCode/2331-2340/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277\357\274\210\347\256\200\345\215\225\357\274\211.md" +++ "b/LeetCode/2331-2340/2335. \350\243\205\346\273\241\346\235\257\345\255\220\351\234\200\350\246\201\347\232\204\346\234\200\347\237\255\346\200\273\346\227\266\351\225\277\357\274\210\347\256\200\345\215\225\357\274\211.md" @@ -2,7 +2,7 @@ 这是 LeetCode 上的 **[2335. 装满杯子需要的最短总时长]()** ,难度为 **简单**。 -Tag : 「递归」、「贪心」、「数学」、「排序」 +Tag : 「排序」、「递归」、「模拟」、「贪心」、「数学」 @@ -55,7 +55,7 @@ Tag : 「递归」、「贪心」、「数学」、「排序」 --- -### 递归 +### 排序 + 递归 水的种类固定为 `3`,且每种水的数据范围只有 $100$,可直接使用递归进行求解。 @@ -67,7 +67,7 @@ class Solution { public int fillCups(int[] amount) { Arrays.sort(amount); if (amount[1] == 0) return amount[2]; - amount[1] -= 1; amount[2] -= 1; + amount[1]--; amount[2]--; return 1 + fillCups(amount); } } diff --git a/README.md b/README.md index fd9bd31a..9e4a3795 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,5 @@ 有任何问题欢迎你给我提 issue(issues 页有 [惊喜](https://github.com/SharingSource/LogicStack-LeetCode/issues/5)) 🤣 -![宫水三叶的刷题日记](https://oscimg.oschina.net/oscnet/up-19688dc1af05cf8bdea43b2a863038ab9e5.png) +![宫水三叶的刷题日记](https://s1.ax1x.com/2023/06/25/pCN6HOJ.png) +