Skip to content

Commit 5bc2a41

Browse files
committed
feat: add typescript solution to lc problem: No.2075
No.2075.Decode the Slanted Ciphertext
1 parent a7bbeb6 commit 5bc2a41

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

solution/2000-2099/2075.Decode the Slanted Ciphertext/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ class Solution {
120120
}
121121
```
122122

123+
### **TypeScript**
124+
125+
```ts
126+
function decodeCiphertext(encodedText: string, rows: number): string {
127+
const cols = Math.ceil(encodedText.length / rows);
128+
let ans = [];
129+
for (let k = 0; k <= cols; k++) {
130+
for (let i = 0, j = k; i < rows && j < cols; i++, j++) {
131+
ans.push(encodedText.charAt(i * cols + j));
132+
}
133+
}
134+
return ans.join('').trimEnd();
135+
};
136+
```
137+
123138
### **C++**
124139

125140
```cpp

solution/2000-2099/2075.Decode the Slanted Ciphertext/README_EN.md

+15
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ class Solution {
106106
}
107107
```
108108

109+
### **TypeScript**
110+
111+
```ts
112+
function decodeCiphertext(encodedText: string, rows: number): string {
113+
const cols = Math.ceil(encodedText.length / rows);
114+
let ans = [];
115+
for (let k = 0; k <= cols; k++) {
116+
for (let i = 0, j = k; i < rows && j < cols; i++, j++) {
117+
ans.push(encodedText.charAt(i * cols + j));
118+
}
119+
}
120+
return ans.join('').trimEnd();
121+
};
122+
```
123+
109124
### **C++**
110125

111126
```cpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function decodeCiphertext(encodedText: string, rows: number): string {
2+
const cols = Math.ceil(encodedText.length / rows);
3+
let ans = [];
4+
for (let k = 0; k <= cols; k++) {
5+
for (let i = 0, j = k; i < rows && j < cols; i++, j++) {
6+
ans.push(encodedText.charAt(i * cols + j));
7+
}
8+
}
9+
return ans.join('').trimEnd();
10+
};

0 commit comments

Comments
 (0)