1395. 统计作战单位数 发表于 2021-07-02 更新于 2025-02-26 分类于 algorithm-practice , leetcode 本文字数: 77 阅读时长 ≈ 1 分钟12345678910111213141516171819202122/** * @param {number[]} rating * @return {number} */var numTeams = function (rating) { var count = 0; for (let i = 1; i < rating.length - 1; i++) { let ri = rating[i]; let countx1 = 0, countx2 = 0; let county1 = 0, county2 = 0; for (let x = 0; x < i; x++) { if (rating[x] < ri) countx1++; if (rating[x] > ri) countx2++; } for (let x = i + 1; x < rating.length; x++) { if (rating[x] < ri) county1++; if (rating[x] > ri) county2++; } count += countx1 * county2 + countx2 * county1; } return count;};
1833. 雪糕的最大数量 发表于 2021-07-02 更新于 2025-02-26 分类于 algorithm-practice , leetcode 本文字数: 43 阅读时长 ≈ 1 分钟排序123456789101112131415161718/** * @param {number[]} costs * @param {number} coins * @return {number} */var maxIceCream = function (costs, coins) { costs.sort((a, b) => a - b); let count = 0; for (var i = 0; i < costs.length; i++) { if (costs[i] <= coins) { coins -= costs[i]; count++; } else { break; } } return count;};
python 自定义 JSON Encoder 发表于 2021-06-15 更新于 2025-02-26 分类于 daily , 2021 本文字数: 60 阅读时长 ≈ 1 分钟python 自定义 JSON Encoder继承 json.JSONEncoder 类, 重载 default 方法
Numpy, SciPy, Matplotlib 和 Pandas 学习 发表于 2021-03-14 更新于 2025-02-26 分类于 daily , 2021 本文字数: 116 阅读时长 ≈ 1 分钟时间过的真快啊,转眼间已经是 3 4 月了!Python 数据科学常用的库
5. 最长回文子串 发表于 2021-03-01 更新于 2025-02-26 分类于 algorithm-practice , leetcode 本文字数: 121 阅读时长 ≈ 1 分钟#思路动态规划 < 中心扩展算法 < manacher
25. K 个一组翻转链表 发表于 2021-03-01 更新于 2025-02-26 分类于 algorithm-practice , leetcode 本文字数: 83 阅读时长 ≈ 1 分钟12345678910111213141516171819202122232425262728293031323334353637class Solution{ public: ListNode *reverseKGroup(ListNode *head, int k) { ListNode _header(0, head); ListNode *last = &_header; head = last; int count = 0; while (head) { head = head->next; count++; if (head && count == k) { count -= k; ListNode *tmp_last_next = last->next; reverseK(last, k); head = last = tmp_last_next; } } return _header.next; } void reverseK(ListNode *start, int k) { ListNode *cur = start, *next = start->next; int count = 0; while (count < k) { ListNode *tmp = next->next; next->next = cur; cur = next; next = tmp; count++; } start->next->next = next; start->next = cur; }};
3. 无重复字符的最长子串 发表于 2021-03-01 更新于 2025-02-26 分类于 algorithm-practice , leetcode 本文字数: 61 阅读时长 ≈ 1 分钟#思路滑动窗口
日本语1 发表于 2021-02-15 更新于 2025-02-26 分类于 misc , japanese 本文字数: 190 阅读时长 ≈ 1 分钟What is Japanese#Japanese Sound System