Day 27: Testing Objective This challenge is very different from the others we've completed because it requires you to generate a valid test case for a problem instead of solving the problem. There is no input to read, you simply have to generate and print test values for the problem that satisfy both the problem's Input Format and the criteria laid out in the Tasksection. Check out the Tutorial tab for an instr.. 더보기 Day 26: Nested Logic Task Your local library needs your help! Given the expected and actual return dates for a library book, create a program that calculates the fine (if any). The fee structure is as follows:If the book is returned on or before the expected return date, no fine will be charged (i.e.: .If the book is returned after the expected return day but still within the same calendar month and year as the expe.. 더보기 Day 25: Running Time and Complexity Task A prime is a natural number greater than that has no positive divisors other than and itself. Given a number, , determine and print whether it's or .Note: If possible, try to come up with a primality algorithm, or see what sort of optimizations you come up with for an algorithm. Be sure to check out the Editorial after submitting your code!Input FormatThe first line contains an integer, , t.. 더보기 Day 24: More Linked Lists Task 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 removeDuplicates function is declared in your editor, which takes a pointer to the node of a linked list as a parameter. Complete removeDuplicates so that it deletes any duplicate nodes from the list and returns .. 더보기 Level 4 - 숫자의 표현 수학을 공부하던 민지는 재미있는 사실을 발견하였습니다. 그 사실은 바로 연속된 자연수의 합으로 어떤 숫자를 표현하는 방법이 여러 가지라는 것입니다. 예를 들어, 15를 표현하는 방법은 (1+2+3+4+5) (4+5+6) (7+8) (15) 로 총 4가지가 존재합니다. 숫자를 입력받아 연속된 수로 표현하는 방법을 반환하는 expressions 함수를 만들어 민지를 도와주세요. 예를 들어 15가 입력된다면 4를 반환해 주면 됩니다. 풀이 public class Expressions { public int expressions(int num) { int answer = 0; int size = num / 2; for (int i = 1; i 더보기 Level 3 - N개의 최소공배수 두 수의 최소공배수(Least Common Multiple)란 입력된 두 수의 배수 중 공통이 되는 가장 작은 숫자를 의미합니다. 예를 들어 2와 7의 최소공배수는 14가 됩니다. 정의를 확장해서, n개의 수의 최소공배수는 n 개의 수들의 배수 중 공통이 되는 가장 작은 숫자가 됩니다. nlcm 함수를 통해 n개의 숫자가 입력되었을 때, 최소공배수를 반환해 주세요. 예를들어 [2,6,8,14] 가 입력된다면 168을 반환해 주면 됩니다. 풀이 import java.util.Arrays; class NLCM { public long nlcm(int[] num) { long answer = 0; long[] longNum = Arrays.stream(num).mapToLong(i -> (long)i).toA.. 더보기 Day 23: BST Level-Order Traversal Task A level-order traversal, also known as a breadth-first search, visits each level of a tree's nodes from left to right, top to bottom. You are given a pointer, , pointing to the root of a binary search tree. Complete the levelOrderfunction provided in your editor so that it prints the level-order traversal of the binary search tree.Hint: You'll find a queue helpful in completing this challen.. 더보기 Day 21: Generics Task Write a single generic function named printArray; this function must take an array of generic elements as a parameter (the exception to this is C++, which takes a vector). The locked Solution class in your editor tests your function.Note: You must use generics to solve this challenge. Do not write overloaded functions.Input FormatThe locked Solution class in your editor will pass different .. 더보기 Day 20: Sorting Consider the following version of Bubble Sort:for (int i = 0; i array[j + 1]) { int temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; numberOfSwaps++; } } // If no elements were swapped during a traversal, array is sorted if (numberOfSwaps == 0) { break; } } return numberOfSwaps; } Integer getFirstElement() { return array[0]; } Integer getLastElement() { return array[array.length - 1]; .. 더보기 Level 3 - 다음 큰 숫자 어떤 수 N(1≤N≤1,000,000) 이 주어졌을 때, N의 다음 큰 숫자는 다음과 같습니다.N의 다음 큰 숫자는 N을 2진수로 바꾸었을 때의 1의 개수와 같은 개수로 이루어진 수입니다.1번째 조건을 만족하는 숫자들 중 N보다 큰 수 중에서 가장 작은 숫자를 찾아야 합니다.예를 들어, 78을 2진수로 바꾸면 1001110 이며, 78의 다음 큰 숫자는 83으로 2진수는 1010011 입니다. N이 주어질 때, N의 다음 큰 숫자를 찾는 nextBigNumber 함수를 완성하세요. 풀이이진법으로 바꿔주는 자체 메소드를 이용하면 쉽게 해결그냥 이런거 이용없이 한다고 했을 때 먼저 이진법으로 바꿔야 하니n % 2 값을 stack에 쌓아두고 pop해서 이진수를 만들고 1의 count를 센다이 process를 .. 더보기 이전 1 ··· 4 5 6 7 8 9 10 ··· 13 다음