Algorithms

    [그래프 위상정렬] Topological Sort : Java

    [그래프 위상정렬] Topological Sort : Java

    그래프 위상정렬: Topological Sort BFS&DFS를 계속 공부하다가 위상정렬도 요즘 핫(?)하다길래 따로 공부하는 중이다. 위상정렬은 그래프 정렬의 일종인데 이것이 가능하기 위해선 순환성을 가져서는 안된다. 즉 순환없는 방향성을 가진 계층적 정렬이 가능해야 위상정렬이 가능하다. 조건식으로 나타내면 다음과 같다. 1. 1 -> 2 -> 3 -> 4 와 같은 관계가 성립되어야 한다. 2. A -> B | B

    [백준/17248번] 물리 공부 [2019 전북대학교 프로그래밍 경진대회]

    [백준/17248번] 물리 공부 [2019 전북대학교 프로그래밍 경진대회]

    문제 전북대학교 컴퓨터공학부 신입생인 시현이는 공대 필수 교양인 기초물리를 수강중이다. 공부를 열심히 하는 시현이는 물리 문제집를 풀다가 다음과 같은 문제를 만났다. 평소 물리를 좋아하던 시현이는 ㄱ, ㄴ번은 단숨에 알았지만, ㄷ번을 풀 수 없어 절망에 빠져 있다. 절망에 빠져있는 시현이를 도와주도록 하자. 입력 첫째 줄에 테스트케이스 T를 입력한다. (1 ≤ T ≤ 100) 다음 줄부터 각 테스트케이스마다 자동차 A와 자동차 B의 속력 X, Y, 그리고 자동차 A의 가속도 Z가 주어진다. (각각의 입력은 띄어쓰기로 구분한다.) 단, 0 ≤ X < Y ≤ 10,000이고, 0

    [Codeforce/round#611] Minutes Before the New Year [Java]

    [Codeforce/round#611] Minutes Before the New Year [Java]

    time limit per test 1 second memory limit per test 256 megabytes input: standard input output: standard output New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows ℎh hours and 𝑚m minutes, where 0≤ℎℎ

    058 - Scope and Global Variables 1

    058 - Scope and Global Variables 1

    Fix the following code so it produces the following output: one word Note: You should achieve this WITHOUT changing any print statements. Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.util.*; class Main { public static void main(String[] args) { String output =""; String text = "hello"; if (text.indexOf(" ") == -1) //if a space doesn't exist { output = "one word"; } else {..

    050 - Accumulator Method Practice 6

    050 - Accumulator Method Practice 6

    Write a method header on line two with the following specs: Returns: a String Name: keepVowels Parameters: a String called s Purpose: create a string that is composed of all the vowels in the string, in the same order that they appear. see below examples for clarity. Examples: keepVowels("hello") ==> "eo" keepVowels("how do i internets") ==> "ooiiee" Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ..

    044 - Method Header Challenge 1 (Optional)

    044 - Method Header Challenge 1 (Optional)

    Write a method header on line two with the following specs: Returns: a String Name: mixString Parameters: a String called s1 a String called s2 Then, starting on line 4, write code that will return the strings combined, one letter at a time, starting with s1. See example below for an example. You can assume that s1 and s2 are equal lengths: s1 ==> "12345" s2 ==> "abcde" mixString(s1,s2) ==> "1a2..

    040 - Method Header Practice 5

    040 - Method Header Practice 5

    Write a method header on line two with the following specs: Returns: a double Name: negate Parameters: a double called "num" Then, starting on line 4, write the code that will return the opposite value of num (if it's positive, make it negative, otherwise make it positive) Examples: 4 ==> -4 -10 ==> 10 1 ==> -1 Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 import java.util.*; class Main { public static..

    [Programmers] 서울에서 김서방 찾기 [Java]

    [Programmers] 서울에서 김서방 찾기 [Java]

    문제 설명 String형 배열 seoul의 element중 Kim의 위치 x를 찾아, 김서방은 x에 있다는 String을 반환하는 함수, solution을 완성하세요. seoul에 Kim은 오직 한 번만 나타나며 잘못된 값이 입력되는 경우는 없습니다. 제한 사항 seoul은 길이 1 이상, 1000 이하인 배열입니다. seoul의 원소는 길이 1 이상, 20 이하인 문자열입니다. Kim은 반드시 seoul 안에 포함되어 있습니다. 입출력 예 seoul return [Jane, Kim] 김서방은 1에 있다 풀이 1 2 3 4 5 6 7 8 9 10 11 class Solution { String answer = ""; public String solution(String[] seoul) { for(int ..