본문 바로가기
반응형

전체 글55

[Android Studio] 라이브러리 참조 / 직접 경로 입력 Gradle Script bulid.gradle (당연하게 Module:app) dependencies { 참조할 라이브러리 주소 } dependencies { implementation 'com.github.bumptech.glide:glide:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' } 2020. 6. 18.
K번째수도움말 import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; class Solution { public int[] solution(int[] array, int[][] commands) { int[] answer = new int [commands.length]; for(int i = 0 ; i < commands.length ; i++) { answer[i] = slice(array, commands[i]); } return answer; } public int slice(int[] array, int[] command) { //command 하나를 받아 자른 후 정렬하여 리턴해준다. int answer; int.. 2020. 6. 17.
핸드폰 번호 가리기 class Solution { public String solution(String phone_number) { String answer = ""; //CharSequencesubSequence(int beginIndex, int endIndex) //Stringreplace(CharSequence target, CharSequence replacement) String Replace = ""; for(int i = 0; i < phone_number.length()-4 ; i++) { Replace += "*"; } answer = phone_number.replace(phone_number.subSequence(0, phone_number.length()-4), Replace); return answ.. 2020. 6. 10.
자연수 뒤집어 배열로 만들기 class Solution { public int[] solution(long n) { String n2s = String.valueOf(n); int[] answer = new int[n2s.length()]; int i = 0; while(n!=0) { answer[i] = (int)n%10; n/=10; i++; } return answer; } } class Solution { public int[] solution(long n) { String n2s = String.valueOf(n); char [] s2c = n2s.toCharArray(); int [] answer = new int[s2c.length]; for(int i = 0; i < answer.length ; i++) { answe.. 2020. 6. 9.
정수 내림차순으로 배치하기 import java.util.*; class Solution { public long solution(long n) { String [] rr = String.valueOf(n).split(""); Arrays.sort(rr,Comparator.reverseOrder()); //String 배열에 하나씩 저장됨 String ans = ""; for(String r : rr){ ans += r; } long answer = Long.parseLong(ans); return answer; } } 2020. 5. 25.
문자열 다루기 기본 class Solution { //Charater.isDigit 사용 public boolean solution(String s) { boolean answer = true; if(s.length() == 4 || s.length() == 6){ for(char r : s.toCharArray()){ if(Character.isDigit(r)) return true; else { return false; } } } return answer; } } class Solution { //정규 표현식 사용 public boolean solution(String s) { boolean answer = true; if(s.length() == 4 || s.length() == 6 ) { answer = s.matc.. 2020. 5. 25.
x만큼 간격이 있는 n개의 숫자 class Solution { public long[] solution(int x, int n) { long [] answer = new long[n]; int num = 0; for(int i = 0 ; i < n ; i++){ num+=x; answer[i] = num; } return answer; } } class Solution { public long[] solution(int x, int n) { long [] answer = new long[n]; answer[0] = x; for(int i = 1 ; i < n ; i++){ answer[i] = answer[i-1]+x; } return answer; } } 2020. 5. 21.
반응형