Algorithm
本周选择的算法题是:Path Sum。
规则
Given the root
of a binary tree and an integer targetSum
, return true
if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum
.
A leaf is a node with no children.
Example 1:
Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
Output: true
Explanation: The root-to-leaf path with the target sum is shown.
Example 2:
Input: root = [1,2,3], targetSum = 5
Output: false
Explanation: There two root-to-leaf paths in the tree:
(1 --> 2): The sum is 3.
(1 --> 3): The sum is 4.
There is no root-to-leaf path with sum = 5.
Example 3:
Input: root = [], targetSum = 0
Output: false
Explanation: Since the tree is empty, there are no root-to-leaf paths.
Constraints:
- The number of nodes in the tree is in the range
[0, 5000]
. -1000 <= Node.val <= 1000
-1000 <= targetSum <= 1000
Solution
class Solution:
def hasPathSum(self, root: Optional[TreeNode], targetSum: int) -> bool:
if not root: return False
targetSum -= root.val
if not (root.left or root.right):
return targetSum == 0
else:
return self.hasPathSum(root.left, targetSum) or self.hasPathSum(root.right, targetSum)
Review
How we reduced our iOS AppStore binary size
作者从 dsym 开始引出了 bitcode 对包大小的影响,然后进一步从实践角度出发提出需要解决的问题:
- 由于 Apple 会重新编译 app,CI 需要有一个环节从 Apple 下载对应的 dsym 文件
- 三方库的 framework 需要包含 bitcode 符号表文件 bcsymbolmap
对开启 bitcode 的好处是不言而喻的,安装大小和下载大小都会有不同程度的好转。
Tip
在 Shell 捕获异常的方法:
until
echo "use python3.9"
python3.9 -u ~/ci-work/run_build.py
[ "$?" -ne 127 ]
do
echo "use python3"
python3 -u ~/ci-work/run_build.py
break
done
Share
什么是简历中的亮点?
作为面试官的你,在简历的大海里看一个项目描述,最吸引你眼球的是什么呢?是像 Gradle、Hybrid、架构调优、性能优化这类关键字?还是一句话就让你想到这件事的复杂性,和这个系统带来的巨大价值?
举个简历中的实际例子让大家感受下:
- A:维护和搭建 CI/CD,支持内网下载安装App(即OTA),大幅度提高了团队工作效率
- B:建设公司内部的 DevOps 团队,通过 CI/CD 的工作流,优化了迭代效率,交付从每月→ 每两周,自动化测试覆盖率 0% → 70%,同时将发布、环境切换、快速回滚能力平台化,保证了线上环境稳定性,并每周产出研发效能报告
如果你是面试官,遇到 A/B 两种情况会如何选择?
会用 Gradle 不算亮点,甚至写一个 Gradle 也不算亮点,但如果能把 Gradle 中的某些算法、解决方案应用到项目中,解决项目的实际问题,这才是亮点。
有些同学会觉得知道这么多有什么用,实际工作不还是 if else,但是 if else 也分鲜花和牛粪,有的人写的是 [].reduce,而有的人写的是:
var temp = '';
for(x in xx) {
temp += x;
}
如果不知道原理,那么类似 Gradle/CocoaPods 这种明星级的技术产品,将永远与你无缘。冷静下来想想,Gradle 难道不也是 if else 吗?是的,但又不全是。
从面试官角色延伸到项目角色,更好的技术思考和设计,一定能给你带来更多的可能性,而系统的优雅程度,一定不是靠业务代码的堆砌,而是作为技术核心的你,如何去思考。