전체 글 (92) 썸네일형 리스트형 [Algorithm 기초 연습] 이진 탐색을 이용한 숫자 찾기 //이진탐색 - 숫자 찾기 import java.util.*; class Solution { public int solution(int[] nums, int target){ int answer = 0; int left = 0; int right = nums.length - 1; // 배열의 길이 while(left [Data Structure 기초 연습] 우선순위 큐 - 오름차순 정렬 02 // 비선형 자료구조 - 우선순위 큐 // Practice 2 // 나이 오름차순 (인터페이스 상속 구현 없는 버전) import java.util.PriorityQueue; class Person3 { String name; int age; public Person3(String name, int age) { this.name = name; this.age = age; } } public class priorityQueuePractice03 { public static void solution(String[] name, int[] age) { PriorityQueue pq = new PriorityQueue(); } public static void main(String[] args) { String[.. [Data Structure 기초 연습] 우선순위 큐 - 오름차순 정렬 01 // 비선형 자료구조 - 우선순위 큐 // Practice 1 // 나이 순으로 오름차순 또는 내림차순 출력 // 자바 기본 PriorityQueue import java.util.PriorityQueue; class Person2 implements Comparable { String name; int age; public Person2(String name, int age) { this.name = name; this.age = age; } @Override public int compareTo(Person2 o){ // 1 : 변경 안함. 우선순위가 높지 않음 // -1 : 변경 //새롭게 추가하는 데이터가 더 적을 때 변경 (적은 값이 위로 올라감) return this.age >= o.age ?.. 이전 1 2 3 4 5 6 7 8 ··· 31 다음