Skip to content

Commit 5969544

Browse files
committed
이진희-3838
1 parent dccacca commit 5969544

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
3+
1. 아이디어 : 문자열의 배열마다 각 배열 가중치를 센 후 모듈러 연산으로 나눠서 나온값을 알파벳 변환한다
4+
5+
이때, z=0, a=25 처럼 반대로 계산해야 한다.
6+
7+
2. 시간복잡도 : O(100*10)
8+
9+
3. 자료구조/알고리즘 : 완전탐색
10+
11+
*/
12+
13+
class Solution {
14+
public String mapWordWeights(String[] words, int[] weights) {
15+
StringBuilder sb = new StringBuilder();
16+
for(String s : words) {
17+
int cnt = 0;
18+
for(int i=0; i<s.length(); i++) {
19+
cnt+=weights[s.charAt(i)-'a'];
20+
}
21+
22+
char c = (char)('z'-cnt%26);
23+
sb.append(c);
24+
}
25+
26+
return sb.toString();
27+
}
28+
}

0 commit comments

Comments
 (0)