hackerrank

learn kro favicon img

Day 20: Sorting | HackerRank Solution

Hello coders, today we are going to solve Day 20: Sorting HackerRank Solution in C++, Java and Python. Objective Today, we’re discussing a simple sorting algorithm called Bubble Sort. Consider the following version of Bubble Sort: Task Given an array, a, of size n distinct elements, sort the array in ascending order using the Bubble Sort algorithm above. Once sorted, print the following 3 lines: Hint: To complete this challenge, you will …

Day 20: Sorting | HackerRank Solution Read More »

learn kro favicon img

Day 19: Interfaces | HackerRank Solution

Hello coders, today we are going to solve Day 19: Interfaces HackerRank Solution in C++, Java and Python. Objective Today, we’re learning about Interfaces. Task The AdvancedArithmetic interface and the method declaration for the abstract divisorSum(n) method are provided for you in the editor below. Complete the implementation of Calculator class, which implements the AdvancedArithmetic interface. The implementation for the divisorSum(n) method must return the sum of all divisors of n. Examplen = …

Day 19: Interfaces | HackerRank Solution Read More »

learn kro favicon img

Day 18: Queues and Stacks | HackerRank Solution

Hello coders, today we are going to solve Day 18: Queues and Stacks HackerRank Solution in C++, Java and Python. Task Welcome to Day 18! Today we’re learning about Stacks and Queues 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, s, is a palindrome? To solve …

Day 18: Queues and Stacks | HackerRank Solution Read More »

learn kro favicon img

Day 17: More Exceptions | HackerRank Solution

Hello coders, today we are going to solve Day 17: More Exceptions HackerRank Solution in C++, Java and Python. Objective Yesterday’s challenge taught you to manage exceptional situations by using try and catch blocks. In today’s challenge, you will practice throwing and propagating an exception. Task Write a Calculator class with a single method: int power(int,int). The power method takes two integers, n and p, as parameters and returns the integer result of np. …

Day 17: More Exceptions | HackerRank Solution Read More »

learn kro favicon img

Day 16: Exceptions – String to Integer | HackerRank Solution

Hello coders, today we are going to solve Day 16: Exceptions – String to Integer HackerRank Solution in C++, Java and Python. Objective Today, we’re getting started with Exceptions by learning how to parse an integer from a string and print a custom error message.  Task Read a string, S, and print its integer value; if S cannot be converted to an integer, print Bad …

Day 16: Exceptions – String to Integer | HackerRank Solution Read More »

learn kro favicon img

Day 15: Linked List | HackerRank Solution

Hello coders, today we are going to solve Day 15:Linked List HackerRank Solution in C++, Java and Python. Objective Today we will work with a Linked List.  A Node class is provided for you in the editor. A Node object has an integer data field, data, and a Node instance pointer, next, pointing to another node (i.e.: the next node in the list). A Node insert function is also declared in your …

Day 15: Linked List | HackerRank Solution Read More »

learn kro favicon img

Day 14: Scope | HackerRank Solution

Hello coders, today we are going to solve Day 14: Scope HackerRank Solution in C++, Java and Python. Objective Today we’re discussing scope. The absolute difference between two integers, a and b, is written as |a – b|. The maximum absolute difference between two integers in a set of positive integers, elements, is the largest absolute difference between any two integers in elements. The Difference class is started for you in the editor. It …

Day 14: Scope | HackerRank Solution Read More »

learn kro favicon img

Day 13: Abstract Classes | HackerRank Solution

Hello coders, today we are going to solve Day 13: Abstract Classes HackerRank Solution in C++, Java and Python. Objective Today, we will extend what we learned yesterday about Inheritance to Abstract Classes. Because this is a very specific object oriented concept, submissions are limited to the few languages that use this construct. Task Given a Book class and a Solution class, write a MyBook class that does the following: …

Day 13: Abstract Classes | HackerRank Solution Read More »

learn kro favicon img

Day 12: Inheritance | HackerRank Solution

Hello coders, today we are going to solve Day 12: Inheritance HackerRank Solution in C++, Java and Python. Objective Today, we’re delving into Inheritance.  Task You are given two classes, Person and Student, where Person is the base class and Student is the derived class. Completed code for Person and a declaration for Student are provided for you in the editor. Observe that Student inherits all the properties of Person. Complete the Student class by writing the …

Day 12: Inheritance | HackerRank Solution Read More »

learn kro favicon img

Day 11: 2D Arrays | HackerRank Solution

Hello coders, today we are going to solve Day 11: 2D Arrays HackerRank Solution in C++, Java and Python. Objective Today, we are building on our knowledge of arrays by adding another dimension. ContextGiven a 6 x 6 2D Array, A: We define an hourglass in A to be a subset of values with indices falling in this pattern in A‘s graphical representation: There are 16 hourglasses in A, and an hourglass sum is …

Day 11: 2D Arrays | HackerRank Solution Read More »