HackerRank 30 Days of Code Solution Day 4: Class vs. Instance

Featured image

In this tutorial, we will guide you through the process of solving the Day 4: Class Vs. Instance programming problem from HackerRank’s “30 Days of Code” challenge.

We will provide comprehensive code solutions in C++, Python, and JavaScript programming languages. With our help, you will gain a better understanding of the problem and learn how to approach and solve similar coding challenges.

Disclaimer: We encourage you to solve this challenge yourself before reading our tutorial. We have provided a detailed explanation of the problem and our solutions to help you check your work.

Hackerrank 30 days of code - Day 4: Class vs. Instance

It’s part of hackerrank’s 30 days of code. A series of 30-day programming challenges. Where you can learn new programming languages by solving the coding challenges.

Problem Statement and Explanation

In this problem, we will learn the difference between class and instance using object-oriented programming. we will return the following string based on the following conditions:

The Person class is provided in the editor. We have to write the following methods inside the class:

Operators Hackerrank solution in Python

Operators Hackerrank solution in JavaScript

Test Case of Class vs. Instance Hackerrank Solution

Tested on the Hackerrank platform for the following test case and passed all the test cases. Enclosed below is the screenshot of the test case.

Class vs Instance Hackerrank Solution