본문 바로가기

HackerRank

[Hackerrank] Loops Objective In this challenge, we will use loops to do some math. Check out the Tutorial tab to learn more. Task Given an integer, , print its first multiples. Each multiple (where ) should be printed on a new line in the form: n x i = result. Example The printout should look like this: 3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30 Inpu.. 더보기
[Hackerrank] Class vs. Instance Objective In this challenge, we're going to learn about the difference between a class and an instance; because this is an Object Oriented concept, it's only enabled in certain languages. Check out the Tutorial tab for learning materials and an instructional video! Task Write a Person class with an instance variable, age, and a contructor that takes an integer, initialAge, as a parameter. The co.. 더보기
[Hackerrank] Intro to Conditional Statements Objective In the challenge, we learn about conditional statements. Check out the Turorial tab for learning materials and an instructional video. Task Given an integer, n, perform the following confitional actions: if n is odd, print Weird if n is even and in the inclusive range of 2 to 5, print Not Weird if n is even and in the inclusive range of 6 to 20, print Weird if n is even and greater tha.. 더보기
[Hackerrank] 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 i, d, and s are already declared and initalized for you. You must: 1. Declare 3 variables: one of type int, one of type double, and one of type String. 2. Read 3 lines of input from stdin (according to the sequence g.. 더보기
[Hackerrank] Picking Numbers Given an array of integers, find the longest subarray where the absolute difference between any two elements is less than or equal to 1. Example a = [1,1,2,2,4,4,5,5,5] There are two subarrays meeting the criterion: [1,1,2,2] and [4,4,5,5,5]. The maximum length subarray has 5 elements. Function Description Complete the pickingNumbers function in the editor below. pickingNumbers has the following.. 더보기
[Hackerrank] Forming a Magic Square We define a magic square to be an n x n matrix of distinct positive integers from 1 to n2 where the sum of any row, column, or diagonal of length n is always equal to the same number: the magic constant. You will be gicen a 3 x 3 matrix s of integers in the inclusive range [1,9]. We can convert any digit a to any other digit b in the range [1,9] at cost of |a-b|. Given s, convert it into a magic.. 더보기
[Hackerrank] Java Loops 1 Objective In this challenge, we're going to use loops to help us do some simple math. Task Given an integer, N, rint its first 10 multiples. Each mutiple N x i(where 1 더보기
[Hackerrank] Java Output Formatting java's System.out.printf function can be used to print formatted output. The purpose of this exercise is to test your understanding of formatting output using printf. To get you started, a portion of the solusion is provided for you in the editor; you must format and print the input to complete the solution. Input Format Every line of input will contain a String followed by an integer. Each Stri.. 더보기