avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • Resume
  • Archives
  • Categories
  • Photos
  • Music



{{ date }}

{{ time }}

avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • 主页
  • Resume
  • Archives
  • Categories
  • Photos
  • Music

2325Decrypt One question daily

  2024-01-01        
字数统计: 160字   |   阅读时长: 1min

2023-02-01 (1).png
2325. Decrypt

Thought:

Simple hash mapping table,pythonUse ascii_lowercase[] Directly obtain a lowercase letter。
Golang Look at the answer of Lingshen,

“Imam on the space to the space,In this way, you don’t need to judge the space。”

Code:

python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from string import ascii_lowercase

class Solution:
def decodeMessage(self, key: str, message: str) -> str:
str1 = ''
dict1 = {}
index = 0
for i in key.replace(' ', ''):
if i not in dict1:
dict1[i] = ascii_lowercase[index]
index += 1
for i in message:
if i in dict1:
str1 += dict1[i]
else:
str1 += ' '
return str1
golang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
func decodeMessage(key string, message string) string {
mp := ['z' + 1]byte{' ': ' '}
cur := byte('a')
for _, c := range key {
if mp[c] == 0 {
mp[c] = cur
cur += 1
}
}
s := []byte(message)
for i, c := range s {
s[i] = mp[c]
}
return string(s)
}

  • Python
  • answer
  • Hash table
  • One question daily
  • golang

扫一扫,分享到微信

微信分享二维码
2315. Statistical star number One question daily
2319Determine whether the matrix is ​​one X matrix One question daily
目录
  1. 1. Thought:
  2. 2. Code:

150 篇 | 131.7k
次 | 人
这里自动载入天数这里自动载入时分秒
2022-2025 loong loong | 新南威尔士龙龙号