-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from AlgoLeadMe/16-mong3125
16-mong3125
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |