import java.util.ArrayList; import java.util.Arrays; class Solution { public int[] solution(int[] arr, int divisor) { ArrayList list = new ArrayList(); for (int i = 0; i < arr.length; i++) { if (arr[i] % divisor == 0) { list.add(arr[i]); } } if (list.size() == 0) { list.add(-1); } int[] answer = new int[list.size()]; for (int i = 0; i < list.size(); i++) { answer[i] = list.get(i); } Arrays.sort(..
import java.util.ArrayList; class Solution { public int[] solution(int []arr) { ArrayList list = new ArrayList(); for (int i = 0; i = 0 && arr[i-1] == arr[i])) { list.add(arr[i]); } } int[] answer = new int[list.size()]; for (int i = 0; i < list.size(); i++) { answer[i] = list.get(i); } return answer; } } - 다른 코드랑 비교해도 깔끔하고 나쁘지 않은듯 - 앞에 똑같은 숫자가 있으면 리스트에 추가하지않고 나왔던..
class Solution { public static String solution(String s) { String answer = ""; if (s.length()%2 != 0) { answer += s.charAt(s.length()/2); } else { answer += s.charAt(s.length()/2 - 1); answer += s.charAt(s.length()/2); } return answer; } } - charAt으로 그 부분을 빼서 더해줬다. return s.substring((s.length()-1) / 2, s.length()/2 + 1); - 다른 풀이 코드 - 훨씬 간편하게 했는데 나는 이렇게 생각 못할거같다 ,,, - 내가 떠올릴 수 있는 방법으로 해보자
class Solution { public static String solution(int a, int b) { int[] days = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; String[] day_week = { "THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED" }; int totalDays = 0; if (a == 1) { totalDays = b; } else { for (int i = 0; i < a-1; i++) { totalDays += days[i]; } totalDays += b; } return day_week[totalDays%7]; } } - 적다보니까 규칙이 보여서 월마다의 일수배열, 요일배열 ..
import java.util.ArrayList; import java.util.Arrays; class Solution { public int[] solution(int[] array, int[][] commands) { int[] answer = new int[commands.length]; ArrayList list = new ArrayList(); for (int c = 0; c < commands.length; c++) { int i = commands[c][0]; int j = commands[c][1]; int k = commands[c][2]; int[] arr = Arrays.copyOfRange(array, i - 1, j); Arrays.sort(arr); answer[c] = arr..
import java.util.ArrayList; import java.util.Arrays; class Solution { public static int[] solution(int[] answers) { int[] student1 = {1, 2, 3, 4, 5}; int[] student2 = {2, 1, 2, 3, 2, 4, 2, 5}; int[] student3 = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; int[] cnt = new int[3]; for (int i = 0; i < answers.length; i++) { if (answers[i] == student1[i%5]) { cnt[0]++; } if (answers[i] == student2[i%8]) { cnt[1]+..
트리 (tree) 자료구조의 일종 사이클이 없는 연결 그래프 정점의 개수 : V 간선의 개수 : V-1 정점 V, 간선 V 개 라면 사이클이 1개 있다. 정점 V, 간선 V-1 개라면 트리라 할 수 있을까 ? 아니다. 왜냐면 연결이 되어있지 않다. 정점 V, 간선 V-1 개 라는것은 트리의 성질이다. 트리가 맞을려면 연결되어있다는 조건이 추가되어야 한다. 트리를 구성하는 요소 - node - edge root - 트리의 가장 윗부분에 위치하는 노드 - 하나의 트리에는 하나의 루트가 존재 reaf (terminal node, external node) - 트리의 가장 아랫부분에 위치하는 노드 - 더 이상 뻗어나갈 수 없는 마지막 노드 Parent - Parent가 없는 V를 Root라고 할 수 있다. Ch..
- Total
- Today
- Yesterday
- JPA 연관관계 매핑
- HTTP 완벽가이드
- 드림코딩
- 프로그래머스
- 김영한 JPA
- 모던자바스크립트
- 김영한 http
- 프로그래머스 SQL
- 백준
- REST API
- 이펙티브자바 아이템59
- Spring Security
- BOJ
- java
- JS 딥다이브
- js promise
- 이펙티브자바 아이템60
- 킹수빈닷컴
- GCP
- js array
- HTTP 완벽 가이드
- 이펙티브자바
- 패스트캠퍼스 컴퓨터공학 완주반
- 이펙티브자바 스터디
- 백기선 스터디
- http
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- dreamcoding
- ㅇㄷㅇㅈ
- js api
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |