백준 1769
·
Algorithm/백준
https://www.acmicpc.net/problem/1769 package baekjoon; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class _1769 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); // 변환 수 int count = 0; while (true) { // 합계 int num = 0; // 탈출 조건 i..
Stack - Fish
·
Algorithm/Codility
package codility.num5; import java.util.Stack; public class Solution { public int solution(int[] A, int[] B) { // write your code in Java SE 8 Stack aliveFish = new Stack(); // 시작 인덱스 추가 aliveFish.push(0); int i = 1; while (i A[aliveFish.peek()]){ // 살아남은 물고기 스택에서 현재 물고기를 pop aliveFi..
Sybase Random함수
·
Database
SELECT top N * FROM ~~ OREDER BY newid() 지정한 수의 랜덤한 레코드를 추출해준다.
Lesson7 - Brackets
·
Algorithm/Codility
https://app.codility.com/programmers/lessons/7-stacks_and_queues/brackets/ Brackets coding task - Learn to Code - Codility Determine whether a given string of parentheses (multiple types) is properly nested. app.codility.com A string S consisting of N characters is considered to be properly nested if any of the following conditions is true: S is empty; S has the form "(U)" or "[U]" or "{U}" wher..
기능개발
·
Algorithm/프로그래머스
https://programmers.co.kr/learn/courses/30/lessons/42586?language=java 코딩테스트 연습 - 기능개발 프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 programmers.co.kr package programmers.stackandqueue; import java.util.Arrays; public class Solution { public int[] solution(int[] progresses, int[] speeds) { int[] answer = new int[100]; int day = 0; for..
스택/큐 - 프린터
·
Algorithm/프로그래머스
https://programmers.co.kr/learn/courses/30/lessons/42587 코딩테스트 연습 - 프린터 일반적인 프린터는 인쇄 요청이 들어온 순서대로 인쇄합니다. 그렇기 때문에 중요한 문서가 나중에 인쇄될 수 있습니다. 이런 문제를 보완하기 위해 중요도가 높은 문서를 먼저 인쇄하는 프린 programmers.co.kr public class Printer { public int solution(int[] priorities, int location) { int answer = 0; // 1. 우선 순위 큐 (큰 수가 우선순위 가짐) PriorityQueue queue = new PriorityQueue(Collections.reverseOrder()); // 2. 우선순위 큐에 ..
검색 알고리즘
·
Algorithm/자료 구조 및 개념 정리
- 검색 알고리즘 : 데이터 집합에서 원하는 값을 가진 요소를 찾아내는 알고리즘 선형검색 - 요소가 직선 모양으로 늘어선 배열에서 원하는 키 값 요소를 만날때까지 맨앞부터 순서대로 요소를 검색하는 것. package basic; import java.util.Scanner; public class SeqSearch { static int seqSearch(int[] a, int n, int key) { // int i = 0; /* while (true) { if (i == n) return -1; if (a[i] == key) return i; i++; } */ for(int i=0; i
정렬 - K번째 수
·
Algorithm/프로그래머스
package programmers.sort; import java.util.Arrays; public class Main { public int[] solution(int[] array, int[][] commands) { int[] answer = new int[commands.length]; // Arrays.copyOfRange(원본배열, 복사할 시작 인덱스, 복사할 끝 인덱스 for (int i = 0; i < commands.length; i++) { int[] arr = Arrays.copyOfRange(array, commands[i][0] - 1, commands[i][1]); Arrays.sort(arr); answer[i] = arr[commands[i][2] -1]; } return..
Lesson2. OddCurrencesInArray
·
Algorithm/Codility
A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. For example, in array A such that: A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9 the elements at indexes 0 and 2 have value 9, the elements at i..
takoyummy
'분류 전체보기' 카테고리의 글 목록 (12 Page)