/images/avatar.jpg

ARST打卡第141周[141/521]

Algorithm lc382_链表随机节点 蓄水池算法 https://leetcode-cn.com/problems/linked-list-random-node/solution/lian-biao-sui-ji-jie-dian-by-leetcode-so-x6it/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class Solution { ListNode *head; public: Solution(ListNode *head) { this->head = head; } int getRandom() { int i = 1, ans = 0; for (auto node = head; node; node = node->next)

ARST打卡第140周[140/521]

Algorithm lc1629_按键持续时间最长的键 直接遍历维护按键时间数组 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 class Solution { public: char slowestKey(vector<int>& releaseTimes, string keysPressed) { int n = releaseTimes.size(); char ans = keysPressed[0]; int maxTime = releaseTimes[0]; for

ARST打卡第139周[139/521]

Algorithm lc390_消除游戏 模拟,或者找规律,应该是找规律 模拟找规律: 巧妙利用每次左边界跳动的值。处理好数组中还剩的数组数,以及相邻数之差 https://leetcode-cn.com/problems/elimination-game/solution/xiao-chu-you-xi-by-leetcode-solution-ydpb/ 1 2 3

ARST打卡第137周[137/521]

Algorithm lc419_甲板上的战舰 简单基础的bfs + vis数组 可以处理这个题目 但是没有用到这个题目的特性,用到这个题目的特性 相连,并且只有2中类型 的