Skip to content

Commit

Permalink
Merge pull request #54 from AlgoLeadMe/16-mong3125
Browse files Browse the repository at this point in the history
16-mong3125
  • Loading branch information
tgyuuAn authored Jun 27, 2024
2 parents 74b643a + 9a3eb2f commit 5e62857
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mong3125/문자열/PS스킬체크테스트1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package 문자열;

public class PS스킬체크테스트1 {
class Solution {
public boolean solution(String s) {
boolean answer = false;

int len_s = s.length();
if (len_s != 4 && len_s != 6) return false;

for (int i = 0; i < len_s; i++) {
char c = s.charAt(i);
if (c >= '0' && c <= '9') {
answer = true;
} else {
answer = false;
break;
}
}

return answer;
}
}
}
26 changes: 26 additions & 0 deletions mong3125/문자열/PS스킬체크테스트2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package 문자열;

import java.util.*;

public class PS스킬체크테스트2 {
class Solution {
public int[] solution(String s) {
int[] answer = new int[s.length()];

HashMap<Character, Integer> alphabet = new HashMap<>();

for (int i = 0; i < s.length(); i++) {
char now = s.charAt(i);
if (alphabet.containsKey(now)) {
answer[i] = i - alphabet.get(now);
} else {
answer[i] = -1;
}

alphabet.put(now, i);
}

return answer;
}
}
}

0 comments on commit 5e62857

Please sign in to comment.