2023/01/09~2023/03/01【Sr. SDE TPE】未錄取
題目為 LeetCode 93. Restore IP Addressesopen_in_new。
面試官是 base 新加坡的 DevOps 技術主管,開頭首先是雙方自介。Jerome 表示 AICS(發音:艾斯)部門成立約4年,旨在開創華碩的軟體新事業,經過幾次嘗試之後,產品方向收斂在醫療產業的資訊管理,也介紹了目前使用的技術,包含:Vue, Typescript, 少量 Python, Mongodb, Kubernetes。
在技術類的題目被問到了:
另外,筆者有提到自己帶人的經驗,因此有被問到一些管理相關的問題:
口頭交流結束之後便開始一題 Live Coding,語言隨意(或部分 pseudo code),不需要可執行,題目如下:
Write a simple calculator to calculate an equation without considering the order of operators.
Examples:
Test case #1Input: "1-2*3-4"Output: -7Explain: 1-2*3-4 = -1*3-4 = -3-4 = -7
Test case #2Input: "100-1000*2"Output: -1800Explain: 100-1000*2 = -900*2= -1800
Constraints:Only ['-', '*'] operators and digitsAll numbers within 32bit integerNo brackets & white spaces
Followups 包含:
最後面試結束前的問答,Jerome 提到目前的困難處包括 Domain Knowhow 較深,以及技術上需要承受長時間新舊系統並存的狀況。
在二面結束約兩週後由獵頭轉達未錄取,同時公司也有提供對於人選的回饋:
- His performance in coding testing is not satisfying even considering him as a SDE.
- His knowledge in various technologies is broad but not deep, which means we need extra effort to train him.
- we think he is not an engineer who is careful about the details, which might make him hard to manage and work with.
火藥味雖然濃厚,但至少有給評價,知道未來改善的方向。
面試當下僅寫出屍體,時限內沒有處理好 leading zeros 的部分,程式碼如下:
from typing import List
def solve(ip_str: str): ans = set() def backtracking(current: List[str], remaining_ip_str: str): if len(current) == 4: if len(remaining_ip_str) == 0: ans.add(".".join(current)) else: return for i in range(1, 4): left, right = remaining_ip_str[:i], remaining_ip_str[i:] if 1 <= len(left) <= 3 and 0 <= int(left) <= 255: backtracking([*current, left], right) backtracking([], ip_str) return [ip for ip in ans] print(solve("25525511135"))print(solve("0000"))print('case 3:', solve("55555555555"))print('case 4:', solve("28003892"))print('case 5:', solve("2803892"))
def evaluate(expression): if expression == "": return 0
numer_queue = [] operator_queue = []
if expression[0] == "-": n_str = "-" expression = expression[1:] else: n_str = ""
for c in expression: if c in ['-', '*']: numer_queue.append(int(n_str)) n_str = "" operator_queue.append(c) # numer_queue = [1, 2, 3] # operator_queue = ['-', '*', '-'] else: n_str = n_str + c numer_queue.append(int(n_str)) # numer_queue = [1, 2, 3, 4] # numer_queue = [1, 2, 3, 4] # operator_queue = ['-', '*', '-']
for op in operator_queue: operand1 = numer_queue.pop(0) operand2 = numer_queue.pop(0) if op == '-': numer_queue.insert(0, operand1 - operand2) elif op == '*': numer_queue.insert(0, operand1 * operand2)
return numer_queue[0]
print(evaluate("")) # -> 0print(evaluate("2")) # -> 2print(evaluate("1-2*3-4")) # -7print(evaluate("-1"))