// Process
// 1. Input countGate, countAirplane, airplanes
// 2. Iterate airplanes while docking status true
// 2.1. 비행기입력번호 이하의 게이트 위치에 도킹이 가능한 곳을 찾아 채운다.
// 2.2. 도킹하면 개수 센다.
// 2.2.1. 없으면 종료한다.
// 3. 개수 출력한다.
import java.util.*;
class Airport {
public static void main(String[] args) {
int count = 0;
Scanner scanner = new Scanner(System.in);
int countGate = scanner.nextInt();
int countAirplanes = scanner.nextInt();
boolean[] gatesFull = new boolean[countGate];
int[] airplaneIndexes = new int[countAirplanes];
for (int i = 0; i < countAirplanes; ++i) {
airplaneIndexes[i] = scanner.nextInt()-1;
}
// 2.
boolean dockingStatus = true;
int i = 0;
while (i < airplaneIndexes.length) {
int planeIndex = airplaneIndexes[i];
boolean foundEmptyGate = false;
while (planeIndex >= 0) {
if (!gatesFull[planeIndex]) {
gatesFull[planeIndex] = true;
foundEmptyGate = true;
++count;
break;
}
--planeIndex;
}
if (!foundEmptyGate) {
break;
}
++i;
}
// 3.
System.out.println(count);
}
}
TDD, TestDrivenDevelopment, 테스트 기반 개발, unit test, 단위테스트, 설계, TFD, TestFirstDevelopment, 테스트
2021.04 우아한테크캠프 pro 프리코스 중 자바지기님의 TDD 관련 강의를 이해한대로 간략 정리 TDD -> Test code + Production code 로 이루어져 있다. 테스트 코드는 말그대로 테스트를 하기 위한 코드이고,
itdar.tistory.com
백준 1012 - 유기농배추, 너비우선, 깊이우선, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash,
// Process // 1. Input row, col, matrices // 2. Make matrix for cabbages // 3. 전체 반복한다. // 3.1. 배추이면서 아직 접근 안했으면 -> 큐 준비하고, 탐색 시작한다. // ..
itdar.tistory.com