## Print Pretty – HackerRank Solution

Problem : Your manager gave you a text file with many lines of numbers to format and print. For each row of 3 space-separated doubles, format and print the numbers using the specifications in the Output Format section below. Input Format : The first line

## Maps-STL – HackerRank Solution

Problem : Maps are a part of the C++ STL.Maps are associative containers that store elements formed by a combination of a key value and a mapped value, following a specific order.The mainly used member functions of maps are: Map Template : Declaration : Size : Insert :

## Sets-STL – HackerRank Solution

Problem : Sets are a part of the C++ STL. Sets are containers that store unique elements following a specific order. Here are some of the frequently used member functions of sets: Declaration : Size : Insert : Erasing an element : Finding an element : To know more about

## Lower Bound-STL – HackerRank

You are given N integers in sorted order. Also, you are given Q queries. In each query, you will be given an integer and you have to tell whether that integer is present in the array. If so, you have to tell at which index it is present and if it is not

## Vector-Erase – HackerRank Solution

You are provided with a vector of N integers. Then, you are given 2 queries. For the first query, you are provided with 1 integer, which denotes a position in the vector. The value at this position in the vector needs to be erased. The next

## Vector-Sort – HackerRank Solution

Problem : You are given N integers.Sort the N integers and print the sorted order.Store the N integers in a vector.Vectors are sequence containers representing arrays that can change in size. Declaration : Size : Pushing an integer into a vector

## Virtual Functions – HackerRank Solution

This problem is to get you familiar with virtual functions. Create three classes Person, Professor and Student. The class Person should have data members name and age. The classes Professor and Student should inherit from the

## Classes and Objects – HackerRank Solution

Problem : A class defines a blueprint for an object. We use the same syntax to declare objects of a class as we use to declare variables of other basic types. For example: Kristen is a contender for valedictorian of her high school. She wants to know how many

## Class – HackerRank Solution

Problem : Classes in C++ are user defined types declared with keyword class that has data and functions . Although classes and structures have the same type of functionality, there are some basic differences. The data members of a class are private by default and the members

## Structs – HackerRank Solution

Problem : struct is a way to combine multiple fields to represent a composite data structure, which further lays the foundation for Object Oriented Programming. For example, we can store details related to a student in a struct consisting of his age (int),

## Strings – HackerRank Solution

Problem : C++ provides a nice alternative data type to manipulate strings, and the data type is conveniently called string. Some of its widely used features are the following: Declaration : Size : Concatenate two strings : Accessing i^th element :

## StringStream – HackerRank Solution

Problem : stringstream is a stream class to operate on strings. It basically implements input/output operations on memory (string) based streams. stringstream can be helpful in different type of parsing. The following operators/functions are commonly used here

## Attribute Parser – HackerRank Solution

Problem : We have defined our own markup language HRML. In HRML, each element consists of a starting and ending tag, and there are attributes associated with each tag. Only starting tags can have attributes. We can call an attribute by referencing the tag, followed by a

## Variable Sized Arrays – HackerRank Solution

Problem : Consider an n-element array, a, where each index i in the array contains a reference to an array of ki integers (where the value of ki varies from array to array). See the Explanation section below for a diagram.

## Arrays Introduction – HackerRank Solution

An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier. Declaration : Accessing elements of an array : You’ll be given an array of N integers and

## Pointer – HackerRank Solution

Problem : A pointer in C is a way to share a memory address among different contexts (primarily functions). They are primarily used whenever a function needs to modify the content of a variable, of which it doesn’t have ownership. In order to access the

## Functions – HackerRank Solution

Problem : Functions are a bunch of statements glued together. A function is provided with zero or more arguments, and it executes the statements on it. Based on the return type, it either returns nothing (void) or something. A sample syntax for a function is For example, a

## For Loop – HackerRank Solution

Problem : A for loop is a programming language statement which allows code to be repeatedly executed. The syntax for this is expression_1 is used for initializing variables which are generally used for controlling terminating flag for the loop.