반응형
문자열안에 문자열
class Solution {
public int solution(String str1, String str2) {
if(str1.contains(str2)){
return 1;
}
return 2;
}
}
제곱수 판별하기
import java.util.*;
class Solution {
public int solution(int n) {
int sq = (int)Math.sqrt(n);
int pow = (int) Math.pow((double)sq,2.0);
if(n == pow){
return 1;
}
return 2;
}
}
세균 증식
class Solution {
public int solution(int n, int t) {
for(int i =1; i<= t; i++){
n *= 2;
}
return n;
}
}
문자열 정렬하기 (2)
import java.util.*;
class Solution {
public String solution(String my_string) {
char []carr = my_string.toLowerCase().toCharArray();
Arrays.sort(carr);
return new String(carr);
}
}
728x90
반응형
'CodingTest' 카테고리의 다른 글
코딩테스트 입문 - Day 20 (1) | 2025.05.05 |
---|---|
코딩테스트 입문 - Day 19 (0) | 2025.05.05 |
코딩테스트 입문 - Day 17 (0) | 2025.04.27 |
코딩테스트 입문 - Day 16 (0) | 2025.04.27 |
코딩테스트 입문 - Day 15 (0) | 2025.04.27 |