ZigZag Convertion
"What’s Your Scope?" from The Staff Engineer’s Path
Delete word in vim
Recent Trial on Cursor
Algorithm - ZigZag Convertion
class Solution:
def convert1(self, s: str, numRows: int) -> str:
"""
space: O(numRows * numCols) -> O(numRows * n)
time: O(numRows * numCols) -> O(numRows * n)
Create a matrix to store the traverse results
1. Move down
2. Move up
3. Traverse the matrix from left to right, and then read from up to down.
"""
if numRows == 1:
return s
n = len(s)
each_section = 2 * numRows - 2
num_sections = n // each_section if n % each_section == 0 else n // each_section + 1
num_cols = num_sections * (numRows - 1)
matrix = [["" for i in range(num_cols)] for j in range(numRows)]
cur_row, cur_col = 0, 0
cur_idx = 0
while cur_idx < n:
# move down
while cur_row < numRows and cur_idx < n:
matrix[cur_row][cur_col] = s[cur_idx]
cur_row += 1
cur_idx += 1
cur_col += 1
cur_row -= 2
# move up
while cur_row > 0 and cur_idx < n:
matrix[cur_row][cur_col] = s[cur_idx]
cur_idx += 1
cur_row -= 1
cur_col += 1
res = []
for row in range(numRows):
for col in range(num_cols):
res.append(matrix[row][col])
return "".join(res)
def convert2(self, s: str, numRows: int) -> str:
"""
space: O(n)
time: O(n)
Mathematical way to calculate how the index changes by row
1. To jump to the next section, we jump by K steps. K = 2 * numRows - 2
2. However, this only applies to the first and last rows
3. For the middle rows, they need to jump by K - 2 * row_num, and them jump by
K steps again.
"""
if numRows == 1:
return s
n = len(s)
each_section = 2 * numRows - 2
res = []
for cur_row in range(numRows):
cur_idx = cur_row
while cur_idx < n:
res.append(s[cur_idx])
# if cur_row is not the first or last row
if cur_row != 0 and cur_row != numRows - 1:
chars_in_between = each_section - 2 * cur_row
second_idx = cur_idx + chars_in_between
if second_idx < n:
res.append(s[second_idx])
cur_idx += each_section
return "".join(res)
Review - What’s Your Scope? from The Staff Engineer Path
Clear your scope! And don’t stay in your lane forever.
Inside your scope, you should have some influence on both short-term and long-term goals
The manager might expect you to devote the majority of your skills and energy to solving problems that fall within their domain.
Be prepared to ignore your scope when there’s crisis.
You should also have a level comfort with stepping outside your day-to-day experience, leading when needed.
A scope is too broad or undefined
Problem:
Lack of impact and full of side quests
Becoming a bottleneck, the team can’t manage without you.
Decision fatigue. Have the constant cost of deciding which things to do.
Hard to have enough regular contact to build friendly relationship that make it easier to get things done.
Solution
Choose an area, build influence, and have some success there.
Devote your time to solve some problems entirely.
A scope is too narrow
Problem:
e.g. a staff engineer is part of a single team, reporting to a line manager.
Lack of impact with spending time on the work that doesn’t need the expertise and focus of a staff engineer. A staff engineer should belong to a core component, a mission-critical team.
Opportunity cost. Have less chance to be exposed for solving a problem in the organization, or the manager won’t let you go.
Overshadowing other engineers. A narrow scope can mean that there’s no enough work to keep busy, and we may take the learning chance from less experienced engineers.
Over-engineering. An engineer who’s not busy can be inclined to make work for themselves.
Solution
Some technical domains and projects are deep enough that an engineer can spend their whole career there and never run out of opportunities. Just be very clear about whether you’re in one of those spaces.
Tips - Delete word in vim
:dw
delete forward:db
delete backward:diw
delete the word:diW
Delete the connected until whitespace
Share - Recent Trial on Cursor
Within 2 hours, I am able to build a draft of simple frontend service without any knowledge. It is just a simple project but still very impressive. However, I can’t learn anything through the project.
The world builds faster with it but we need make full use of it to learn faster in the same time
What it has done
Create a layout to calculate
Keep the layout stable, even with language change the width and height of the component won’t change.
Add input forms
Color theme change, and fix icon visibility issue with theme change.
Multi-language support
Refine several places in the codebase, beautify the icons.
Some struggles
However here are some struggles I faced to make the things right:
A correct layout for sections. I have separated the layout with A, B, C, D sections but it’s hard to tell Cursor how to arrange the layout horizonally and vertically.
Need to give clear defnition of unchangeable layout.
Some Thoughts
I still don’t know how things work. I didn’t learn much knowledge from the project.
Learning a new thing during vibe coding is not easy. And I think usually people won’t do that, otherwise, why do we want to do vibe coding. We want to get things done even though we don’t have the specific knowledge.
A specific routine or procedure is needed to build and learn better with our new tool.