week report 2024.14

Explore more, and think twice, is this the life you want to live?
Entertainment¶
A trip to Fujiyama.
Learning¶
leetcode¶
identical problems and their solutions.
6. ZigZag Conversion¶
class Solution(object):
def convert(self, s: str, numRows: int) -> str:
n = len(s)
lines = [''] * numRows
index = 0
# switch direction while at 0 or numRows - 1
dir_ = (numRows == 1) - 1
for c in s:
lines[index] += c
if index == 0 or index == numRows - 1:
dir_ = -dir_
index += dir_
return "".join(lines)
3106. Lexicographically Smallest String After Operations With Constraint¶
class Solution {
public:
string getSmallestString(string s, int k) {
for (char &c: s) {
int l_dis = c - 'a';
int r_dis = 'z' - c + 1;
int min_dis = min(l_dis, r_dis);
if (k >= min_dis) {
k -= min_dis;
c = 'a';
} else {
k = 0;
c -= k;
}
}
return s;
}
}
life¶

- a trip to Mt. FUJI
- casusual working days, but still find it hard to solve leetcode problem by my own.
Sharing¶
Git Multiply Identity Management¶
~/.gitconfig: the git global configuration~/.gitconfig-github: user customized configuration
# ~/.gitconfig
[core]
autocrlf = input
editor = nvim
# include user-customized configuration by path-matching
[includeIf "gitdir:~/project/project-github"]
path = ~/.gitconfig-github
# ~/.gitconfig-github
[user]
name = haru
email = [email protected]
References¶
- https://leetcode.com/problems/zigzag-conversion
- https://leetcode.com/problems/lexicographically-smallest-string-after-operations-with-constraint/