Suppose we want to make one Triangle class and another child class called Isosceles. The triangle class has a function that prints that the object is of type triangle, and Isosceles has two functions to show that it is an isosceles triangle and one description. We also need to call the parent class function through Isosceles class object. There is no such proper input, we just call functions in proper way.So, if the input is like define an object called trg, then call trg.isosceles(), trg.description(), trg.triangle()., then the output will beThis is an isosceles triangleThere are two sides are equal ... Read More
Suppose we have a map data structure for students roll and name the roll is an integer data and name is string type data. In our standard input we provide n queries. In each query (in each line) there must be two elements and for type 1 query there are three elements. First one is the operator, second one is the roll and third one is the name, for two elements query the second item is the roll number. The operations are like below−Insert. This will insert the name into the map at corresponding rollDelete. This will delete the against ... Read More
Suppose we have a set data structure for integer type data. In our standard input we provide n queries. In each query (in each line) we have two elements. First one is the operator, second one is the element. The operations are like below −Insert. This will insert the element into the setDelete. This will delete the element from the set (if exists)Search. This will search the element into the set, if present show Yes, otherwise No.So, if the input is like n = 7, queries = [[1, 5], [1, 8], [1, 3], [2, 8], [1, 9], [3, 8], [3, ... Read More
Suppose we have a set of elements present inside a vector. We shall have to perform some remove operation using erase() function of vector class type to remove using indices, and finally display rest of elements. The erase function does not take the index directly. We shall have to pass its address by passing v.begin()+index, here v is the vector and v.begin() is the address of the first element (0th element). Now by adding index with it, it will move towards the element that is present at given index.So, if the input is like v = [5, 8, 6, 3, ... Read More
Suppose we have an array called nums with non-negative values. We also have another array called queries where queries[i] has a pair (xi, mi). The answer of ith query is the maximum bitwise XOR value of xi and any element of nums that less than or equal to mi. If all elements in nums are larger than mi, then the answer is -1. So we have to find an array answer where size of answer is same as size of query and answer[i] is the answer to the ith query.So, if the input is like nums = [0, 1, 2, ... Read More
Suppose we have one binary array nums, and a value k. In one move, we can select two adjacent indices and swap their values. We have to find the minimum number of moves required so that nums has k consecutive 1's.So, if the input is like nums = [1, 0, 0, 1, 0, 1, 0, 1], k = 3, then the output will be 2 because in one swap we can make array from [1, 0, 0, 1, 0, 1, 0, 1] to [1, 0, 0, 0, 1, 1, 0, 1], then [1, 0, 0, 0, 1, 1, 1, 0].To ... Read More
Suppose we shall have to define a box class with few conditions. These are as follows −There are three attributes l, b and h for length, breadth and height respectively, (these are private variables)Define one non-parameterized constructor to set l, b, h to 0, and one parameterized constructor to set values initially.Define getter methods for each attributeDefine a function calculateVolume() get the volume of the boxOverload less than operator (
Suppose we have one undirected weighted graph with n nodes using one edgeList, where edgeList[i] has three parameters (u, v, w) denotes there is a path from u to v whose distance is w. We also have another query array where query[i] has (p, q, lim). This query is trying to ask whether there is a path (direct or via some other node) from p to q whose distance is less than lim. We have to return an array holding True/False results for each query.So, if the input is likethen the output will be [True, False, True]. Because to go ... Read More
Suppose we have an array nums. We can perform two types of operations on any element of the array any number of timesFor even elements, divide it by 2For odd elements, multiply it by 2.Now the deviation of the array is the maximum difference between any two elements in the array. We have to find the minimum deviation the array can have after performing some number of operations. So, if the input is like nums = [6, 3, 7, 22, 5], then the output will be 5 because we can make our array in one operation [6, 6, 7, 22, ... Read More
Suppose we have an array nums, there are at most 50 unique values. We also have another array called quantity, where quantity[i] denotes the amount of values the ith customer ordered.We have to check whether it is possible to distribute nums such thatThe ith customer gets exactly quantity[i] items, The value that the ith customer gets are all equal, andAll customers are satisfied.So, if the input is like nums = [5, 1, 2, 2, 3, 4, 4, 3, 3] quantity = [2, 2, 3], then the output will be True because two customer wants two elements each, so they can ... Read More
 Data Structure
 Networking
 RDBMS
 Operating System
 Java
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP