解决Foobar挑战(二)

Posted on Sat 22 April 2023 in Computer Science • Tagged with Google Foobar

接上回书,我们来到了Foobar挑战的第三层。每一层都比上一层更加困难。这篇文章给出了Foobar Level 3 的三道题 Queue To Do, Hey, Fuel Injection Perfection 和 Doomsday Fuel 的解题思路和python代码。这一层要求我们掌握一些位运算,贪心算法,线性代数和概率论的知识。


Continue reading

解决Foobar挑战(一)

Posted on Fri 21 April 2023 in Computer Science • Tagged with Google Foobar

因为机缘巧合,我偶然点开了Google的Foobar Challenge页面,发现自己仍然可以登陆并继续Foobar旅程。这篇文章简单介绍了Foobar挑战的机制,并给出了Foobar Level 2 的两道题 Gearing Up for Destruction 和 Hey, I Already Did That! 两道题的解题思路和python代码。


Continue reading

【Leetcode题解】Weekly Contest 341 周赛题目解析

Posted on Wed 19 April 2023 in Leetcode • Tagged with Contest

2023-04 Leetcode Weekly Contest 341 第 341 场力扣周赛 | 2643. Row With Maximum Ones 一最多的行 | 2644. Find the Maximum Divisibility Score 找出可整除性得分最大的整数 | 2645. Minimum Additions to Make Valid String 构造有效字符串的最少插入数 | 2646. Minimize the Total Price of the Trips 最小化旅行的价格总和 | Solution to contest problems 赛题讲解 | 状态机 State Machine | 树 Tree | Depth First Search | 最近公共祖先 Lowest Common Ancestor


Continue reading

【Leetcode题解】Biweekly Contest 102 双周赛题目解析

Posted on Sun 16 April 2023 in Leetcode • Tagged with Contest

2023-04 Leetcode Biweekly Contest 102 | 2639. Find the Width of Columns of a Grid 查询网格图中每一列的宽度 | 2640. Find the Score of All Prefixes of an Array 一个数组所有前缀的分数 | 2641. Cousins in Binary Tree II 使子数组元素和相等 | 2642. Design Graph With Shortest Path Calculator 设计可以求最短路径的图类 | Solution to contest problems 赛题讲解 | Prefix Sum 前缀和 | BFS 广度优先搜索 | Dijkstra's Algorithm 狄克斯特拉算法 | Floyd-Warshall's Algorithm 算法 | Bianry Tree Traversal 二叉树的遍历


Continue reading

【Leetcode题解】Weekly Contest 340 周赛题目解析

Posted on Sun 09 April 2023 in Leetcode • Tagged with Contest

2023-04 Leetcode Weekly Contest 340 第 340 场力扣周赛 | 2614. Prime In Diagonal 对角线上的质数 | 2615. Sum of Distances 等值距离和 | 2616. Minimize the Maximum Difference of Pairs 最小化数对的最大差值 | 2617. Minimum Number of Visited Cells in a Grid 网格图中最少访问的格子数 | Solution to contest problems 赛题讲解 | Prefix Sum 前缀和 | Binary Search 二分搜索 | BFS 广度优先搜索


Continue reading

【Leetcode题解】2604. Minimum Time to Eat All Grains

Posted on Fri 07 April 2023 in Leetcode

Leetcode Hard 2604 Minimum Time to Eat All Grains My Solution 我的解题思路。


Continue reading

【Leetcode题解】Weekly Contest 339 周赛题目解析

Posted on Sun 02 April 2023 in Leetcode • Tagged with Contest

2023-04 Leetcode Weekly Contest 339 | 2600. K Items With the Maximum Sum K 件物品的最大和 | 2610. Convert an Array Into a 2D Array With Conditions 转换二维数组 | 2611. Mice and Cheese 老鼠和奶酪 | 2612. Minimum Reverse Operations 最少翻转操作数| My solution 我的题目解析


Continue reading

【Leetcode题解】Biweekly Contest 101 双周赛题目解析

Posted on Sun 02 April 2023 in Leetcode • Tagged with Contest

2023-04 Leetcode Biweekly Contest 101 | 2605. Form Smallest Number From Two Digit Arrays 从两个数字数组里生成最小数字 | 2606. Find the Substring With Maximum Cost 找到最大开销的子字符串 | 2607. Make K-Subarray Sums Equal 使子数组元素和相等 | 2608. Shortest Cycle in a Graph 图中的最短环 | My solution 我的题目解析


Continue reading

【Leetcode题解】Weekly Contest 338 周赛题目解析

Posted on Mon 27 March 2023 in Leetcode • Tagged with Contest

2023-03 Leetcode Weekly Contest 338 | 2600. K Items With the Maximum Sum K 件物品的最大和 | 2601. Prime Subtraction Operation 质数减法运算 | 2602. Minimum Operations to Make All Array Elements Equal 使数组元素全部相等的最少操作次数 | 2603. Collect Coins in a Tree 收集树中金币| My solution 我的题目解析


Continue reading

【Leetcode题解】2599. Make the Prefix Sum Non-negative

Posted on Thu 23 March 2023 in Leetcode

Leetcode 2599 Make the Prefix Sum Non-negative My Solution 我的解题思路。这道题主要用贪心算法(greedy)和最小堆(min-heap)结合起来去求解。


Continue reading