Weird Numbers

Given an integer as input, can you check the following: If   N is odd then print "Weird" If N is even and, in between range 2 and 5(inclusive), print "Not Weird" If   N is even and, in between range 6 and 20(inclusive), print "Weird" If is even and ,N>20  print "Not Weird" Java … Continue reading Weird Numbers


Set .add()

Task Apply your knowledge of the .add() operation to help your friend Rupal. Rupal has a huge collection of country stamps. She decided to count the total number of distinct country stamps in her collection. She asked for your help. You pick the stamps one by one from a stack of N country stamps. Find … Continue reading Set .add()

Find the Second Largest Number

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.     if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) print(sorted(list(set(arr)))[-2])

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 N. 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 . Here, 0<=i<=X;0<=j<=Y;0<=k<=Z Input … Continue reading List Comprehensions

Game of Stones

Two players (numbered 1 and 2 ) are playing a game with n stones. Player 1 always plays first, and the two players move in alternating turns. The game's rules are as follows: In a single move, a player can remove either 2 ,3 , or 5 stones from the game board. If a player … Continue reading Game of Stones

Mini-Max Sum

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. import*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static … Continue reading Mini-Max Sum

Matching Specific String

Task You have a test string S. Your task is to match the string hackerrank. This is case sensitive. Note This is a regex only challenge. You are not required to write code. You only have to fill in the regex pattern in the blank (_________). import*; import java.util.*; import java.text.*; import java.math.*; import … Continue reading Matching Specific String


Alice wrote a sequence of words in CamelCase as a string of letters,s , having the following properties: 1. It is a concatenation of one or more words consisting of English letters. 2. All letters in the first word are lowercase. 3. For each of the subsequent words, the first letter is uppercase and rest … Continue reading CamelCase