Imagine you're building a B2B SaaS product (Notion, Linear, Datadog): each customer is a company with isolated users, data, and config. The question: share infra across tenants, or isolate per tenant?
你在读一段没有空格的日文/中文:"applepenapple"。手里有词典 {apple, pen}。能不能从左到右贪心地找词?不行 — "aalanda" 可能切成 "aa / lan / da" 或 "aal / an / da",贪心会漏情况。所以要 DP:"前 i 个字符能否切分" 只依赖于 "是否存在切点 j 使得前 j 个能切分 且 s[j:i] 是词"。
问题 / Problem
Given s and a wordDict, return True if s can be segmented into a space-separated sequence of dictionary words.
s = "leetcode", wordDict = ["leet","code"] → True ("leet code")
s = "applepenapple", wordDict = ["apple","pen"] → True
s = "catsandog", wordDict = ["cats","dog","sand","and","cat"] → False
映射到模板 / Map to template
def wordBreak(s: str, wordDict: list[str]) -> bool:
word_set = set(wordDict) # O(1) lookup
max_len = max(map(len, wordDict)) # prune inner loop
n = len(s)
dp = [False] * (n + 1)
dp[0] = True# BASE CASE: empty prefix is "segmentable"for i in range(1, n + 1):
# TRANSITION: try every split point j; only check j within max_lenfor j in range(max(0, i - max_len), i):
if dp[j] and s[j:i] in word_set:
dp[i] = Truebreak# one witness is enoughreturn dp[n]
Trace: s = "leetcode", dict = {leet, code}
i=0: dp[0]=True (base)
i=1..3: no word matches s[0:1..3] → dp=F
i=4: j=0, s[0:4]="leet" ∈ dict, dp[0]=T → dp[4]=True ✅
i=5..7: try all j; need dp[j]=T and s[j:i]∈dict → none
i=8: j=4, s[4:8]="code" ∈ dict, dp[4]=T → dp[8]=True ✅
return dp[8] = True
Complexity
Time: O(n² · k) where k = avg word length (for s[j:i] hash). With max_len prune → O(n · max_len · k).
A VP announces at all-hands a cool-sounding but technically bad idea (e.g., "migrate everything to Rust next quarter", "AI-ify every feature"). No consultation. PMs are planning, hiring is spinning up. What do you do?
"Q3 we had an all-hands where our SVP of Eng announced we'd standardize on gRPC across all 40+ services within 6 months. My team owned 8 of the services closest to the user-facing APIs where REST was deeply embedded in 3rd-party integrations."
T (Task): 你的角色和"冲突"是什么。
"I agreed with the direction but the timeline and scope would've blown up ongoing roadmap commitments and broken partner contracts. I needed to influence a reset — without making the SVP lose face publicly."
Give the leader a win. 把 counter-proposal 包装成"扩展他的愿景"而不是"推翻":"Your north star is right; here's how we get there without a cliff."
R (Result): 具体可量化的结果。
"SVP accepted the phased plan at the next leadership meeting. We hit 100% new-service compliance in Q4 and migrated 6 of 8 legacy services by H2 next year. Zero partner escalations. The grpc-gateway pattern became a company-wide standard."
❌ Bad vs ✅ Good
❌ Bad:
"The VP's idea was dumb and I told him it wouldn't work. He wouldn't listen so I just did the minimum."
Why bad: performative disagreement, no empathy for the problem the VP was solving, no data, no alternative, bad outcome.
❌ Also bad (over-correction):
"The VP decided it, so we executed it. We missed our roadmap but the migration happened."
Why bad: no technical leadership. Staff+ engineers are expected to push back with signal.
✅ Good:
"I started by understanding what pain the VP was really solving — schema drift and polyglot client confusion. Then I built a one-pager comparing the all-in migration (12 person-months, 28 partner contracts to renegotiate) with a phased approach (new services gRPC-first, legacy via a gateway). Shared it with my manager first, then with the VP in a 1:1 before escalating. The VP appreciated the data and we aligned on the phased plan."
Senior/Staff 面试加分点 / What interviewers want to hear
"Disagree and commit" 的成熟版本: 先 disagree 用数据,决定后 commit — 不是沉默服从。
Prefill is compute-bound (GPU math units saturated). Decode is memory-bound (GPU idling, DRAM thrashing). KV cache is the single most important optimization for decode.