Algorithm
本周选择的算法题是:Remove Palindromic Subsequences。
规则
You are given a string s
consisting only of letters 'a'
and 'b'
. In a single step you can remove one palindromic subsequence from s
.
Return the minimum number of steps to make the given string empty.
A string is a subsequence of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does not necessarily need to be contiguous.
A string is called palindrome if is one that reads the same backward as well as forward.
Example 1:
Input: s = "ababa"
Output: 1
Explanation: s is already a palindrome, so its entirety can be removed in a single step.
Example 2:
Input: s = "abb"
Output: 2
Explanation: "abb" -> "bb" -> "".
Remove palindromic subsequence "a" then "bb".
Example 3:
Input: s = "baabb"
Output: 2
Explanation: "baabb" -> "b" -> "".
Remove palindromic subsequence "baab" then "b".
Constraints:
1 <= s.length <= 1000
s[i]
is either'a'
or'b'
.
Solution
class Solution:
def removePalindromeSub(self, s: str) -> int:
return 1 if s == s[::-1] else 2
Review
3 月 22 日的文章,还算比较新,作者介绍了一些 Rust 资源:
很多知名产品,如 1Password、PingCAP、Sentry、Dropbox、Firefox、Lark 等也引入了 Rust,这几年 Rust 生态发展的很快,或许现在正是开始使用它的好时机。
Tip
学习 Rust 的 zero-cost abstractions:
Rust has a focus on safety and speed. It accomplishes these goals through many ‘zero-cost abstractions’, which means that in Rust, abstractions cost as little as possible in order to make them work. The ownership system is a prime example of a zero-cost abstraction. All of the analysis we’ll talk about in this guide is done at compile time. You do not pay any run-time cost for any of these features.
However, this system does have a certain cost: learning curve. Many new users to Rust experience something we like to call ‘fighting with the borrow checker’, where the Rust compiler refuses to compile a program that the author thinks is valid. This often happens because the programmer’s mental model of how ownership should work doesn’t match the actual rules that Rust implements. You probably will experience similar things at first. There is good news, however: more experienced Rust developers report that once they work with the rules of the ownership system for a period of time, they fight the borrow checker less and less.
改天写个例子分享下。
Share
两种团队协作方式:
- 指令式组织
- 全连接协同
抽象表示如下:
图中每个圆球代表一个团队成员,圆球的大小代表该团队成员同其他团队成员的协作总量,圆球越大,表示该团队成员在团队中越活跃,同其他团队成员的协同性越好;每两个圆球之间有一个连接线条,线条的粗细代表两个团队成员之间的协作紧密度,线条越粗,表示两个团队成员协作越密切。
高绩效团队的特征是内部具备高度的协同性,背后的理论基础是激励协作带来的价值收益通常是激励个体价值收益的 4 倍。
所以,要尽可能地将团队协作社交化,比如目标制定中引入 OKR 全员评审(OKR 集市 + OKR反馈),给文档引入协作工具(如 Confluence),给一线团队更多的决策权(Context,not Control)等,通过充分的互动和协同激发团队成员的效能,使团队成为高绩效团队。