Featured image of post Weekly Report 2024.14

Weekly Report 2024.14

make your own choice

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# ~/.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

Licensed under CC BY-NC-SA 4.0
Last updated on Jan 09, 2024 11:32 CST
The older I get, the more I realize that most of life is a matter of what we pay attention to, of what we attend to [with focus].
Built with Hugo
Theme Stack designed by Jimmy