
import java.util.*; class Solution { public int solution(String dirs) { int answer = 0; Set set = new HashSet(); String from = "0 0"; for(int i=0; i 5 || y > 5 || x < -5 || y < -5) continue; String to = Integer.toString(x) + " " +Integer.toString(y); set.add(from+" "+to); set.add(to+" "+from); from = to; } answer = set.size()/2; return answer; } } HashSet을 사용하여 중복을 제거하는 방식으로 진행하였다. 현재 위치를 from 변..

처음 int index = 0; int target = queue.poll(); list.add(1); while(queue.size() >= 1){ int next = queue.peek(); if(target >= next){ list.set(index, list.get(index)+1); queue.remove(); } else{ index += 1; list.add(index, 1); target = next; queue.remove(); } } 처음 코드를 짤 때 큐에 모든 작업을 추가한 뒤 위와 같이 poll()과 peek()를 사용하여 처음과 다음을 비교하면서 진행했었는데 이렇게 하면 같이 배포 될 수 있는 작업을 구하기 위해 불필요한 변수와 연산이 생겨났다. 자바 코드 import java..
- Total
- Today
- Yesterday
- 알고리즘
- 완전탐색
- 정규식
- Enter키
- 비밀번호 일치
- 할인행사
- 모음 사전
- 스킬트리
- 자동 하이푼
- level2
- 연속 부분 수열 합의 개수
- 스타일
- 브루트포스
- 방문 길이
- 이메일
- 커스텀훅
- 프로그래머스
- input
- 회원가입
- 배열 자르기
- 슬라이드
- Java
- 기능개발
- react
- swiper
- 자바
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |