본문 바로가기

Day 3: Intro to Conditional Statements Task Given an integer, , perform the following conditional actions:If is odd, print WeirdIf is even and in the inclusive range of to , print Not WeirdIf is even and in the inclusive range of to , print WeirdIf is even and greater than , print Not WeirdComplete the stub code provided in your editor to print whether or not is weird.Input FormatA single line containing a positive integer, .Constrai.. 더보기
Day 2: Operators Task Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost.Note: Be sure to use precise values for your calculations, or you may end up with an incorrectly rounded result!Input FormatThere are lines of numeric input: The f.. 더보기
Hash Tables: Ransom Note A kidnapper wrote a ransom note but is worried it will be traced back to him. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he must use whole words available in the magazine, meaning he cannotuse substrings or concatenation to create the words he needs.Give.. 더보기
Strings: Making Anagrams Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency For example, bacdc and dcbac are anagrams, but bacdc and dcbad are not.Alice decides on an encryptio.. 더보기
Level 1 - 행렬의 덧셈 행렬의 덧셈은 행과 열의 크기가 같은 두 행렬의 같은 행, 같은 열의 값을 서로 더한 결과가 됩니다. 2개의 행렬을 입력받는 sumMatrix 함수를 완성하여 행렬 덧셈의 결과를 반환해 주세요.예를 들어 2x2 행렬인 A = ((1, 2), (2, 3)), B = ((3, 4), (5, 6)) 가 주어지면, 같은 2x2 행렬인 ((4, 6), (7, 9))를 반환하면 됩니다.(어떠한 행렬에도 대응하는 함수를 완성해주세요.) 풀이class SumMatrix {int[][] sumMatrix(int[][] A, int[][] B) {int[][] answer = new int[A.length][A[0].length]; for (int i = 0; i < A.length; i++) { for (int j = .. 더보기
Day 1: Data Types Objective Today, we're discussing data types. Check out the Tutorial tab for learning materials and an instructional video!Task Complete the code in the editor below. The variables , , and are already declared and initialized for you. You must:Declare variables: one of type int, one of type double, and one of type String.Read lines of input from stdin (according to the sequence given in the Inpu.. 더보기
Level 1 - 약수의 합 어떤 수를 입력받아 그 수의 약수를 모두 더한 수 sumDivisor 함수를 완성해 보세요. 예를 들어 12가 입력된다면 12의 약수는 [1, 2, 3, 4, 6, 12]가 되고, 총 합은 28이 되므로 28을 반환해 주면 됩니다. 풀이 class SumDivisor {public int sumDivisor(int num) {int answer = 0; for (int i = 1; i 더보기
Common Elements in Two Sorted Arrays (Java) Common Elements in Two Sorted Arrays (Java)Write a function that returns the common elements (as an array) between two sorted arrays of integers (ascending order).Example: The common elements between [1, 3, 4, 6, 7, 9] and [1, 2, 4, 5, 9, 10] are [1, 4, 9]. 풀이ascending order임으로 중복된 숫자는 안들어감map 에 담아서 중복되는 게 있으면 list에 담아두고 이걸 나중에 array 변환 (list는 resizable하니까) import java.util.ArrayList;import java.. 더보기
Arrays: Left Rotation A left rotation operation on an array of size shifts each of the array's elements unit to the left. For example, if left rotations are performed on array , then the array would become .Given an array of integers and a number, , perform left rotations on the array. Then print the updated array as a single line of space-separated integers.Input FormatThe first line contains two space-separated int.. 더보기
Day 0: Hello, World. Objective In this challenge, we review some basic concepts that will get you started with this series. You will need to use the same (or similar) syntax to read input and write output in challenges throughout HackerRank. Check out the Tutorial tab for learning materials and an instructional video!Task To complete this challenge, you must save a line of input from stdin to a variable, print Hello.. 더보기