-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy path1324.java
More file actions
23 lines (21 loc) · 709 Bytes
/
1324.java
File metadata and controls
23 lines (21 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Solution {
public List<String> printVertically(String s) {
String[] strs = s.split(" ");
int max_len = 0;
for (String st : strs) max_len = Math.max(max_len, st.length());
List<String> res = new ArrayList();
for (int j = 0; j < max_len; j++) {
StringBuilder t = new StringBuilder();
int t_len = 0;
for (String st : strs) {
if (st.length() > j) {
t.append(st.charAt(j));
t_len = t.length();
} else t.append(" ");
}
t.setLength(t_len);
res.add(t.toString());
}
return res;
}
}