Objective: You are given n numbers. Store them in a list and find the second largest number. Input Format The first line contains n. The second line contains an array A[] of n integers each separated by a space. Constraints 2 <= n<=10 -100<= A[i] <=100 Output Format Print the value of the second largest number. Sample Input 0 5 2... Continue Reading →
Day 9: Recursion
Objective Today, we're learning and practicing an algorithmic concept called Recursion. Recursive Method for Calculating Factorial factorial(N) = 1 N=1 factorial(N)=factorial(N-1)*N N>1 Task... Continue Reading →
List Comprehensions
Let's learn about list comprehensions! You are given three integers X, Y and Z representing the dimensions of a cuboid along with an integer . You have to print a list of all possible coordinates given by (i, j, k) on a 3D grid where the sum of i+j+k is not equal to N .... Continue Reading →
Day 8: Dictionaries and Maps
A dictionary is used to map or associate things you want to store with a key and a key is required to get values associated with that particular key. A dictionary in Python is just like a dictionary in the real world. Python Dictionary is defined by two elements Keys and Values. Keys will be... Continue Reading →
Day 7: Arrays
Objective Today, we're learning about the Array data structure. Check out the Tutorial tab for learning materials and an instructional video! Task Given an array, A, of N integers, print A's elements in reverse order as a single line of space-separated numbers. Input Format The first line contains an integer, N (the size of our array). The second line contains N space-separated integers describing array 's elements. Constraints 1<=... Continue Reading →
Day 6: Let’s Review. HackerRank 30 Days of Code Challenge
Objective Today we're expanding our knowledge of Strings and combining it with what we've already learned about loops. Check out the Tutorial tab for learning materials and an instructional video! Task Given a string, S, of length that is indexed from 0 to N-1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line (see the Sample below for more detail). Note: 0 is... Continue Reading →
Day 5: Loops. HackerRank 30 Days of Code Challenge.
In most of the programming language, the program is executed sequentially i.e. the first statement is executed first, the second statement next and so on. But in some cases, we need to execute the same sequence of code time and again. For this purpose programming language provide certain control structures that allow more complicated code... Continue Reading →
Day 4: Class vs. Instance. HackerRank 30 Days of Code Challenge
Python is an object-oriented programming language, which means that it provides features that support object-oriented programming (OOP). The object is simply a collection of data (variables) and methods (functions) that act on those data. And, the class is a blueprint for the object. We can think of a class as a sketch (prototype) of a car.... Continue Reading →
Day 3: Intro to Conditional Statements
If, else and elif are used to create conditional statement. As the name suggest the conditional statement are used to evaluate a condition. If a condition is evaluated to true a set of code runs else other set of code runs. Objective In this challenge, we're getting started with conditional statements. Check out the Tutorial tab for... Continue Reading →
Day 2: Operators. HackerRank 30 Days of Code Challenge.
Arithmetic Operators There are 5 types of arithmetic operator used for binary operation: +: Additive -: Subtraction *: Multiplication /: Division %: Remainder (modulo) +: Additive operator add two numbers - : Subtraction operator subtract one number from another. *: Multiplication operator multiply two numbers. /: Division operator divides one number from another. %: Remainder... Continue Reading →