26 Apr 2020

Cpp
CompetitiveProgramming
CodinGame
Mathematics
A gang of R foolish robbers decides to heist a bank. In the bank there are V vaults (indexed from 0 to V1). The robbers have managed to extract some information from the bank’s director. All the robbers work at the same time. A robber can work on one vault at a time, and a vault can be worked on by only one robber. Robbers deal with the different vaults in increasing order. A robber tries the combinations at the speed of combination per second. He tries all the possible combinations, i.e. he continues to try the untried combinations even after he has found the correct combination. Once he finishes one vault, he moves on to the next available vault, that is the vault with the smallest index among all the vaults that have not been worked on yet. The heist is finished when the robbers have worked on all the vaults.
Read more
25 Apr 2020

Cpp
Algorithm
CompetitiveProgramming
Hackerrank
DataStructure
A left rotation operation on an array of size n shifts each of the array’s elements 1 unit to the left. For example, if 2 left rotations are performed on array [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 1, 2]. Given an array of n integers and a number, d, perform d left rotations on the array. Then print the updated array as a single line of spaceseparated integers.
Read more
24 Apr 2020

Cpp
Algorithm
CompetitiveProgramming
Hackerrank
DataStructure
Lilah has a string, s, of lowercase English letters that she repeated infinitely many times. Given an integer, n, find and print the number of letter a’s in the first n letters of Lilah’s infinite string.For example, if the string s = ‘abcac’ and n = 10, the substring we consider is , abcacabcac the first 10 characters of her infinite string. There are 4 occurrences of a in the substring.
Read more
16 Apr 2020

Cpp
Project
Here we are going to implement the Single Elevator Simulation in C++. Initially the elevator is at ground floor. It is represented by 0. Floors below ground floor are represented by negative integers.The elevator has maximum capacity it can carry, maximum and minimum floor it can carry to.The elevator accepts the request of floor the passengers want to go. If the elevator is empty then the first request sets the direction of the elevator. After that it checks whether requests are valid. For eg. if the direction of elevator is UP, current floor is 3 and if the passenger enters request for floor 1 then the request is discarded and the passenger does not enter in the elevator.
Read more
28 Mar 2020

Cpp
Algorithm
CompetitiveProgramming
Hackerrank
DataStructure
Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less than or equal to 1. For example, if your array is a = [1, 1, 2, 2, 4, 4, 5, 5, 5], you can create two subarrays meeting the criterion: [1, 1, 2, 2] and [4, 4, 5, 5, 5]. The maximum length subarray has 5 elements.
Read more