본문 바로가기

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:.. 더보기
Queues: A Tale of Two Stacks A queue is an abstract data type that maintains the order in which elements were added to it, allowing the oldest elements to be removed from the front and new elements to be added to the rear. This is called a First-In-First-Out(FIFO) data structure because the first element added to the queue (i.e., the one that has been waiting the longest) is always the first one to be removed.A basic queue .. 더보기
Level 2 - 최솟값 만들기 자연수로 이루어진 길이가 같은 수열 A,B가 있습니다. 최솟값 만들기는 A, B에서 각각 한 개의 숫자를 뽑아 두 수를 곱한 값을 누적하여 더합니다. 이러한 과정을 수열의 길이만큼 반복하여 최종적으로 누적된 값이 최소가 되도록 만드는 것이 목표입니다.예를 들어 A = [1, 2] , B = [3, 4] 라면A에서 1, B에서 4를 뽑아 곱하여 더합니다.A에서 2, B에서 3을 뽑아 곱하여 더합니다.수열의 길이만큼 반복하여 최솟값 10을 얻을 수 있으며, 이 10이 최솟값이 됩니다. 수열 A,B가 주어질 때, 최솟값을 반환해주는 getMinSum 함수를 완성하세요. 풀이 import java.util.*; class TryHelloWorld { public int getMinSum(int []A, int .. 더보기