본문 바로가기

Level 3 - 야근지수 야근 지수 회사원인 수민이는 많은 일이 쌓여 있습니다. 수민이는 야근을 최소화하기 위해 남은 일의 작업량을 숫자로 메기고, 일에 대한 야근 지수를 줄이기로 결정했습니다. 야근 지수는 남은 일의 작업량을 제곱하여 더한 값을 의미합니다. 수민이는 1시간 동안 남은 일 중 하나를 골라 작업량 1만큼 처리할 수 있습니다. 수민이의 퇴근까지 남은 N 시간과 각 일에 대한 작업량이 있을 때, noOvertime 함수를 제작하여 수민이의 야근 지수를 최소화 한 결과를 출력해 주세요. 예를 들어, N=4 일 때, 남은 일의 작업량이 [4, 3, 3] 이라면 야근 지수를 최소화하기 위해 일을 한 결과는 [2, 2, 2]가 되고 야근 지수는 22 + 22 + 22 = 12가 되어 12를 반환해 줍니다. 풀이 각 작업량의 .. 더보기
Level 3 - 멀리 뛰기 효진이는 멀리 뛰기를 연습하고 있습니다. 효진이는 한번에 1칸, 또는 2칸을 뛸 수 있습니다. 칸이 총 4개 있을 때, 효진이는 (1칸, 1칸, 1칸, 1칸) (1칸, 2칸, 1칸) (1칸, 1칸, 2칸) (2칸, 1칸, 1칸) (2칸, 2칸) 의 5가지 방법으로 맨 끝 칸에 도달할 수 있습니다. 멀리뛰기에 사용될 칸의 수 n이 주어질 때, 효진이가 끝에 도달하는 방법이 몇 가지인지 출력하는 jumpCase 함수를 완성하세요. 예를 들어 4가 입력된다면, 5를 반환해 주면 됩니다. 풀이 노트에 써보면 피보나치 수열을 이용할 수 있음을 알 수 있다.재귀로 해결 class JumpCase { public int jumpCase(int num) { if(num 더보기
Level 2 - 2016년 2016년 1월 1일은 금요일입니다. 2016년 A월 B일은 무슨 요일일까요? 두 수 A,B를 입력받아 A월 B일이 무슨 요일인지 출력하는 getDayName 함수를 완성하세요. 요일의 이름은 일요일부터 토요일까지 각각SUN,MON,TUE,WED,THU,FRI,SAT를 출력해주면 됩니다. 예를 들어 A=5, B=24가 입력된다면 5월 24일은 화요일이므로 TUE를 반환하면 됩니다.풀이class TryHelloWorld { public String getDayName(int a, int b) { String[] days = {"FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU"}; int[] months = {31, 29, 31, 30, 31, 30, 31, 31, 30,3.. 더보기
Day 19: Interfaces Task The AdvancedArithmetic interface and the method declaration for the abstract int divisorSum(int n) method are provided for you in the editor below. Write the Calculator class, which implements the AdvancedArithmeticinterface. The implementation for the divisorSum method must be public and take an integer parameter, , and return the sum of all its divisors.Note: Because we are writing multip.. 더보기
Day 18: Queues and Stacks Welcome to Day 18! Today we're learning about Stacks and Queues. Check out the Tutorial tab for learning materials and an instructional video!A palindrome is a word, phrase, number, or other sequence of characters which reads the same backwards and forwards. Can you determine if a given string, , is a palindrome?To solve this challenge, we must first take each character in , enqueue it in a queu.. 더보기
Day 17: More Exceptions Task Write a Calculator class with a single method: int power(int,int). The power method takes two integers, and , as parameters and returns the integer result of . If either or is negative, then the method must throw an exception with the message: n and p should be non-negative.Note: Do not use an access modifier (e.g.: public) in the declaration for your Calculator class.Input FormatInput from.. 더보기
Day 16: Exceptions - String to Integer Task Read a string, , and print its integer value; if cannot be converted to an integer, print Bad String.Note: You must use the String-to-Integer and exception handling constructs built into your submission language. If you attempt to use loops/conditional statements, you will get a score.Input FormatA single string, .Constraints, where is the length of string . is composed of either lowercase .. 더보기
Day 15: Linked List A Node class is provided for you in the editor. A Node object has an integer data field, , and a Node instance pointer, , pointing to another node (i.e.: the next node in a list).A Node insert function is also declared in your editor. It has two parameters: a pointer, , pointing to the first node of a linked list, and an integer value that must be added to the end of the list as a new Node objec.. 더보기
Day 14: Scope The absolute difference between two integers, and , is written as . The maximum absolute differencebetween two integers in a set of positive integers, , is the largest absolute difference between any two integers in .The Difference class is started for you in the editor. It has a private integer array () for storing non-negative integers, and a public integer () for storing the maximum absolute .. 더보기
Day 13: Abstract Classes Task Given a Book class and a Solution class, write a MyBook class that does the following:Inherits from BookHas a parameterized constructor taking these parameters:string string int Implements the Book class' abstract display() method so it prints these lines:, a space, and then the current instance's ., a space, and then the current instance's ., a space, and then the current instance's .Note:.. 더보기