We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1c68634 commit 45442bbCopy full SHA for 45442bb
Easy/Decode the Message.java
@@ -0,0 +1,16 @@
1
+class Solution {
2
+ public String decodeMessage(String key, String message) {
3
+ int counter = 0;
4
+ Map<Character, Character> map = new HashMap<>();
5
+ for (char c : key.toCharArray()) {
6
+ if (!map.containsKey(c) && c != ' ') {
7
+ map.put(c, (char) ('a' + counter++));
8
+ }
9
10
+ StringBuilder sb = new StringBuilder();
11
+ for (char c : message.toCharArray()) {
12
+ sb.append(c == ' ' ? ' ' : map.get(c));
13
14
+ return sb.toString();
15
16
+}
0 commit comments