Arnab Chakraborty has Published 4293 Articles

Friends Of Appropriate Ages in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:12:39

252 Views

Suppose some people will make friend requests. We know their ages, these are stored in ages[i]. So this indicates that the age of the ith person. Now a A will NOT friend request person B (B != A) if any of the following conditions are true −age[B] age[A]age[B] > ... Read More

Binary Trees With Factors in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:37:58

208 Views

Suppose we have a list of positive integers; whose value is greater than 1. We will make a binary tree, using these integers, and each number may be used as many times as we want. Each non-leaf node should be the product of its children. So we have to find ... Read More

Card Flipping Game in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:35:32

662 Views

Suppose on a table are N cards, with a positive integer printed on both side of each card (possibly different). We have to flip any number of cards, and after we choose one card. If the number X on the back side of the chosen card is not on the ... Read More

Short Encoding of Words in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:32:33

238 Views

Suppose we have a list of words, we may encode it by writing a reference string S and a list of indexes A. So for example, let us consider if the list of words is ["time", "me", "bell"], then we can write it as S = "time#bell#" and indexes = ... Read More

Linked List Components in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:28:44

412 Views

Suppose we have given a head; this is the head node of a linked list containing unique integer values. Now we are also given the list G, a subset of the values in the linked list. We have to find the number of connected components in G, where two values ... Read More

Largest Sum of Averages in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:17:52

155 Views

Suppose we partition a row of numbers A into at most K adjacent groups, then we will set score as the sum of the average of each group. We have to find that what is the largest score that we can achieve. Suppose A = [9, 1, 2, 3, 9] ... Read More

Escape The Ghosts in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:15:52

324 Views

Suppose we are playing a simplified Pacman game. Now we start at the point (0, 0), and our destination is (target[0], target[1]). There are several ghosts on the map, Here the i-th ghost starts at (ghosts[i][0], ghosts[i][1]). In each turn, we and all ghosts simultaneously (may) move in one of ... Read More

Rabbits in Forest in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:13:37

479 Views

Suppose In a forest, each rabbit has some color. Now some subset of rabbits (possibly all of them) will tell us how many other rabbits have the same color as them. Those answers are placed in an array. We have to find the minimum number of rabbits that could be ... Read More

K-th Symbol in Grammar in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:10:46

1K+ Views

Suppose on the first row, we have a 0. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 by 01, and each occurrence of 1 by 10. Suppose we have N rows and index K, we have to find the K-th indexed ... Read More

Global and Local Inversions in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 14:08:15

375 Views

Suppose we have some permutation A of [0, 1, ..., N - 1], where N is the length of A. Now the number of (global) inversions is the number of i < j with 0 A[j]. And the number of local inversions is the number of i with 0 ... Read More

Advertisements