Instruction
stringlengths
261
35k
Response
stringclasses
1 value
For this Question: Given an array of N elements, your task is to update every element with multiplication of previous and next elements with following exceptions:- a) First element is replaced by multiplication of first and second. b) Last element is replaced by multiplication of last and second last. See example ...
Compilable
For this Question: Given an array of N elements, your task is to update every element with multiplication of previous and next elements with following exceptions:- a) First element is replaced by multiplication of first and second. b) Last element is replaced by multiplication of last and second last. See example ...
Compilable
For this Question: Given an array of N integers containing only 0 or 1. You can do the following operations on the array: <ul><li>swap elements at two indices</li><li>choose one index and change its value from 0 to 1 or vice-versa.</li></ul> You have to do the minimum number of the above operations such that the fina...
Compilable
For this Question: Given an array of N integers containing only 0 or 1. You can do the following operations on the array: <ul><li>swap elements at two indices</li><li>choose one index and change its value from 0 to 1 or vice-versa.</li></ul> You have to do the minimum number of the above operations such that the fina...
Compilable
For this Question: Given an array of N integers containing only 0 or 1. You can do the following operations on the array: <ul><li>swap elements at two indices</li><li>choose one index and change its value from 0 to 1 or vice-versa.</li></ul> You have to do the minimum number of the above operations such that the fina...
Compilable
For this Question: Given an array A and an integer K. Find the maximum for each and every contiguous subarray of size K. Problem asked in Amazon, Flipkart.The first line of each test case contains a single integer N denoting the size of array and the size of subarray K. The second line contains N space-separated i...
Compilable
For this Question: Given an array A and an integer K. Find the maximum for each and every contiguous subarray of size K. Problem asked in Amazon, Flipkart.The first line of each test case contains a single integer N denoting the size of array and the size of subarray K. The second line contains N space-separated i...
Compilable
For this Question: Given an array A and an integer K. Find the maximum for each and every contiguous subarray of size K. Problem asked in Amazon, Flipkart.The first line of each test case contains a single integer N denoting the size of array and the size of subarray K. The second line contains N space-separated i...
Compilable
For this Question: Given a number N, you need to check whether the given number is <b>Palindrome</b> or not. A number is said to be Palindrome when it reads the same from backward as forward.User task: Since this is a functional problem you don't have to worry about the input. You just have to complete the function <b...
Compilable
For this Question: Given a number N, you need to check whether the given number is <b>Palindrome</b> or not. A number is said to be Palindrome when it reads the same from backward as forward.User task: Since this is a functional problem you don't have to worry about the input. You just have to complete the function <b...
Compilable
For this Question: You will be given an array of N numbers. Your task is to first reverse the array (the first number becomes last, 2nd number becomes 2nd from the last, and so on) and then print the sum of the numbers at even indices and print the product of the numbers at odd indices. <b>Note :</b> 1 based indexin...
Compilable
For this Question: You will be given an array of N numbers. Your task is to first reverse the array (the first number becomes last, 2nd number becomes 2nd from the last, and so on) and then print the sum of the numbers at even indices and print the product of the numbers at odd indices. <b>Note :</b> 1 based indexin...
Compilable
For this Question: You will be given an array of N numbers. Your task is to first reverse the array (the first number becomes last, 2nd number becomes 2nd from the last, and so on) and then print the sum of the numbers at even indices and print the product of the numbers at odd indices. <b>Note :</b> 1 based indexin...
Compilable
For this Question: Given an integer N, your task is to return the sum of all of its divisors.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>SumOfDivisors()</b> that takes the integer N as parameter. Constraints:- 1<=N<=10^9Return t...
Compilable
For this Question: Given an integer N, your task is to return the sum of all of its divisors.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>SumOfDivisors()</b> that takes the integer N as parameter. Constraints:- 1<=N<=10^9Return t...
Compilable
For this Question: Given an integer N, your task is to return the sum of all of its divisors.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>SumOfDivisors()</b> that takes the integer N as parameter. Constraints:- 1<=N<=10^9Return t...
Compilable
For this Question: Given an integer N, your task is to return the sum of all of its divisors.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>SumOfDivisors()</b> that takes the integer N as parameter. Constraints:- 1<=N<=10^9Return t...
Compilable
For this Question: Bodega is trying to go from point (0, 0) to (X, Y). In one move, Bodega can perform one of the following operations: 1. Go from (x, y) &rarr; (x', y), if x | x' = x' and x ≠ x'. 2. Go from (x, y) &rarr; (x, y'), if y | y' = y' and y ≠ y'. where "|" denotes the bitwise OR operator. However, a to...
Compilable
For this Question: Given a circular linked list consisting of N nodes and an integer K, your task is to add the integer K at the end of the list. <b>Note: Sample Input and Output just show how a linked list will look depending on the questions. Do not copy-paste as it is in custom input</b><b>User Task:</b> Sinc...
Compilable
For this Question: Ram has a military dog who has the special ability of hearing, He can hear frequencies starting from 70Hz to 44000Hz (both inclusive). Now Ram wants to detect some unusual sounds across him. Tell "Yes" or "No" whether his dog can detect the sound or not.First line of the input contains the value of T...
Compilable
For this Question: Ram has a military dog who has the special ability of hearing, He can hear frequencies starting from 70Hz to 44000Hz (both inclusive). Now Ram wants to detect some unusual sounds across him. Tell "Yes" or "No" whether his dog can detect the sound or not.First line of the input contains the value of T...
Compilable
For this Question: Ram has a military dog who has the special ability of hearing, He can hear frequencies starting from 70Hz to 44000Hz (both inclusive). Now Ram wants to detect some unusual sounds across him. Tell "Yes" or "No" whether his dog can detect the sound or not.First line of the input contains the value of T...
Compilable
For this Question: Saurabh has a paper of size N*M and some horizontal and vertical lines in the form of arrays. Saurabh wants to know the maximum area which is trapped inside the lines. Note:- Consider the boundary of the paper to be vertical and horizontal lines. Also consider 0 indexingThe first line of input con...
Compilable
For this Question: Saurabh has a paper of size N*M and some horizontal and vertical lines in the form of arrays. Saurabh wants to know the maximum area which is trapped inside the lines. Note:- Consider the boundary of the paper to be vertical and horizontal lines. Also consider 0 indexingThe first line of input con...
Compilable
For this Question: Given a sorted array arr[] of N integers and a number K is given. The task is to check if the element K is present in the array or not. <b>Note:</b> Use binary search to solve the problemThe first line of input contains a number of test cases T. For each test case, the first line of input contains a...
Compilable
For this Question: Given a sorted array arr[] of N integers and a number K is given. The task is to check if the element K is present in the array or not. <b>Note:</b> Use binary search to solve the problemThe first line of input contains a number of test cases T. For each test case, the first line of input contains a...
Compilable
For this Question: Given a sorted array arr[] of N integers and a number K is given. The task is to check if the element K is present in the array or not. <b>Note:</b> Use binary search to solve the problemThe first line of input contains a number of test cases T. For each test case, the first line of input contains a...
Compilable
For this Question: Given a sorted array arr[] of N integers and a number K is given. The task is to check if the element K is present in the array or not. <b>Note:</b> Use binary search to solve the problemThe first line of input contains a number of test cases T. For each test case, the first line of input contains a...
Compilable
For this Question: Gian and Suneo want their heights to be equal so they asked Doraemon's help. Doraemon gave a big light to both of them but the both big lights have different speed of magnifying. Let's assume the big light given to Gian can increase height of a person by v1 m/s and that of Suneo's big light is v2 m/s...
Compilable
For this Question: Gian and Suneo want their heights to be equal so they asked Doraemon's help. Doraemon gave a big light to both of them but the both big lights have different speed of magnifying. Let's assume the big light given to Gian can increase height of a person by v1 m/s and that of Suneo's big light is v2 m/s...
Compilable
For this Question: Gian and Suneo want their heights to be equal so they asked Doraemon's help. Doraemon gave a big light to both of them but the both big lights have different speed of magnifying. Let's assume the big light given to Gian can increase height of a person by v1 m/s and that of Suneo's big light is v2 m/s...
Compilable
For this Question: You are given a cubic dice with 6 faces. All the individual faces have numbers printed on them. The numbers are in the range of 1 to 6, like any <b>ordinary dice</b>. You will be provided with a face of this cube, your task is to find the number on the opposite face of the cube. <b>Note</b>:- The ...
Compilable
For this Question: You are given a cubic dice with 6 faces. All the individual faces have numbers printed on them. The numbers are in the range of 1 to 6, like any <b>ordinary dice</b>. You will be provided with a face of this cube, your task is to find the number on the opposite face of the cube. <b>Note</b>:- The ...
Compilable
For this Question: You are given a cubic dice with 6 faces. All the individual faces have numbers printed on them. The numbers are in the range of 1 to 6, like any <b>ordinary dice</b>. You will be provided with a face of this cube, your task is to find the number on the opposite face of the cube. <b>Note</b>:- The ...
Compilable
For this Question: You are given a cubic dice with 6 faces. All the individual faces have numbers printed on them. The numbers are in the range of 1 to 6, like any <b>ordinary dice</b>. You will be provided with a face of this cube, your task is to find the number on the opposite face of the cube. <b>Note</b>:- The ...
Compilable
For this Question: Olivia likes triangles. Hence, John decided to give her three integers and ask whether a triangle with edge length as given three integers is possible. Help Olivia in answering it.The input consists of a single line containing three space-separated integers A, B, and C. <b>Constraints </b> 1 <= ...
Compilable
For this Question: A binary heap is a Binary Tree with following properties: 1) It’s a complete tree (All levels are completely filled except possibly the last level and the last level has all keys as left as possible). This property of Binary Heap makes them suitable to be stored in an array. 2) A Binary Heap is e...
Compilable
For this Question: Remove duplicates of an array and return an array of only unique elements.An array containing numbers.Space separated unique elements from the array.Sample Input:- 1 2 3 5 1 5 9 1 2 8 Sample Output:- 1 2 3 5 9 8 <b>Explanation:-</b> Extra 1, 2, and 5 were removed since they were occurring mu...
Compilable
For this Question: Remove duplicates of an array and return an array of only unique elements.An array containing numbers.Space separated unique elements from the array.Sample Input:- 1 2 3 5 1 5 9 1 2 8 Sample Output:- 1 2 3 5 9 8 <b>Explanation:-</b> Extra 1, 2, and 5 were removed since they were occurring mu...
Compilable
For this Question: Given the length, breadth, and height of a cuboid. Your task is to calculate its Perimeter. Note:- Formula for the perimeter of the cuboid is 4(Length + Breadth + height)<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function...
Compilable
For this Question: Given the length, breadth, and height of a cuboid. Your task is to calculate its Perimeter. Note:- Formula for the perimeter of the cuboid is 4(Length + Breadth + height)<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function...
Compilable
For this Question: There are N balloons numbered from 1 to N. Every balloon has an another integer value Arr[i] assigned to it where i varies from 1 to N, and i represents the number of balloon. A balloon at an odd position (i = 1, 3, 5. ) is happy if Arr[i] is odd. A balloon at an even position (i = 2, 4, 6. ) is ...
Compilable
For this Question: There are N balloons numbered from 1 to N. Every balloon has an another integer value Arr[i] assigned to it where i varies from 1 to N, and i represents the number of balloon. A balloon at an odd position (i = 1, 3, 5. ) is happy if Arr[i] is odd. A balloon at an even position (i = 2, 4, 6. ) is ...
Compilable
For this Question: There are N balloons numbered from 1 to N. Every balloon has an another integer value Arr[i] assigned to it where i varies from 1 to N, and i represents the number of balloon. A balloon at an odd position (i = 1, 3, 5. ) is happy if Arr[i] is odd. A balloon at an even position (i = 2, 4, 6. ) is ...
Compilable
For this Question: An array of numbers is given. It has all unique elements except one. Find the only duplicate element in that array having all other unique elements.The first line contains an integer N, the number of elements in the array. The second line contains N integers. Constraints: 1 <= N <= 10^5 1 <= El...
Compilable
For this Question: An array of numbers is given. It has all unique elements except one. Find the only duplicate element in that array having all other unique elements.The first line contains an integer N, the number of elements in the array. The second line contains N integers. Constraints: 1 <= N <= 10^5 1 <= El...
Compilable
For this Question: Find number of ways an integer N can be represented as a sum of unique natural numbers.First line contain an integer T denoting number of test cases. Each test case contains a single integer N. Constraint:- 1 <= T <= 100 0 <= N <= 120Print a single integer containing number of ways.Sample input ...
Compilable
For this Question: Find number of ways an integer N can be represented as a sum of unique natural numbers.First line contain an integer T denoting number of test cases. Each test case contains a single integer N. Constraint:- 1 <= T <= 100 0 <= N <= 120Print a single integer containing number of ways.Sample input ...
Compilable
For this Question: Find number of ways an integer N can be represented as a sum of unique natural numbers.First line contain an integer T denoting number of test cases. Each test case contains a single integer N. Constraint:- 1 <= T <= 100 0 <= N <= 120Print a single integer containing number of ways.Sample input ...
Compilable
For this Question: Find number of ways an integer N can be represented as a sum of unique natural numbers.First line contain an integer T denoting number of test cases. Each test case contains a single integer N. Constraint:- 1 <= T <= 100 0 <= N <= 120Print a single integer containing number of ways.Sample input ...
Compilable
For this Question: Given n and m and a matrix of size n x m. print sum of XOR of all SEPERATED ELEMENT. A element a is said to be SEPERATED element from an element B if a will not share any side with b or vice versa.first line contain two element n and m. next n line contains m space separated integer i. e. element o...
Compilable
For this Question: Given a number N, you need to check whether the given number is <b>Palindrome</b> or not. A number is said to be Palindrome when it reads the same from backward as forward.User task: Since this is a functional problem you don't have to worry about the input. You just have to complete the function <b...
Compilable
For this Question: Given a number N, you need to check whether the given number is <b>Palindrome</b> or not. A number is said to be Palindrome when it reads the same from backward as forward.User task: Since this is a functional problem you don't have to worry about the input. You just have to complete the function <b...
Compilable
For this Question: Given a linked list consisting of N nodes, your task is to delete every kth Node from the circular linked list until only one node is left. Also, print the intermediate lists <b>Note: Sample Input and Output just show how a linked list will look depending on the questions. Do not copy-paste as i...
Compilable
For this Question: There is a rope of length L which you have to cut at 11 positions to divide it into 12 ropes. Here, each of the 12 resulting ropes must have a positive integer length. Find the number of ways to do this division. Note: Two ways to do the division are considered different if and only if there is a p...
Compilable
For this Question: There is a rope of length L which you have to cut at 11 positions to divide it into 12 ropes. Here, each of the 12 resulting ropes must have a positive integer length. Find the number of ways to do this division. Note: Two ways to do the division are considered different if and only if there is a p...
Compilable
For this Question: There is a rope of length L which you have to cut at 11 positions to divide it into 12 ropes. Here, each of the 12 resulting ropes must have a positive integer length. Find the number of ways to do this division. Note: Two ways to do the division are considered different if and only if there is a p...
Compilable
For this Question: Sara selects two different numbers from the range 1 to 50 and noted their sum as N. However later she Forgets which numbers she selected and now wants to know the total number of possible combinations she can have.<b>User Task:</b> Since this will be a functional problem, you don't have to take inpu...
Compilable
For this Question: Sara selects two different numbers from the range 1 to 50 and noted their sum as N. However later she Forgets which numbers she selected and now wants to know the total number of possible combinations she can have.<b>User Task:</b> Since this will be a functional problem, you don't have to take inpu...
Compilable
For this Question: Sara selects two different numbers from the range 1 to 50 and noted their sum as N. However later she Forgets which numbers she selected and now wants to know the total number of possible combinations she can have.<b>User Task:</b> Since this will be a functional problem, you don't have to take inpu...
Compilable
For this Question: Sara selects two different numbers from the range 1 to 50 and noted their sum as N. However later she Forgets which numbers she selected and now wants to know the total number of possible combinations she can have.<b>User Task:</b> Since this will be a functional problem, you don't have to take inpu...
Compilable
For this Question: Given an array arr[] and a number K where K is not greater than the size of array, the task is to find the Kth smallest element in the given array. It is given that all array elements are distinct. <b>Note:</b> Do Not Use sort() STL function, Use heap data structure.The input line contains T, de...
Compilable
For this Question: Given an array arr[] and a number K where K is not greater than the size of array, the task is to find the Kth smallest element in the given array. It is given that all array elements are distinct. <b>Note:</b> Do Not Use sort() STL function, Use heap data structure.The input line contains T, de...
Compilable
For this Question: Given an array arr[] and a number K where K is not greater than the size of array, the task is to find the Kth smallest element in the given array. It is given that all array elements are distinct. <b>Note:</b> Do Not Use sort() STL function, Use heap data structure.The input line contains T, de...
Compilable
For this Question: Given an array of n numbers, sorted in non-decreasing order, and k queries. For each query, print the minimum index of an array element not less than the given one. Note: if the query value is greater than all the elements in the array return n+1.The first line of the input contains n and k. The ...
Compilable
For this Question: Given a linked list consisting of N nodes, your task is to traverse the list and print its elements.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>printList()</b> that takes head node of the linked list as parameter....
Compilable
For this Question: Akash is hosting a farewell party and wants to serve the most delicious pizzas to his K friends. There are N restaurants in the city, numbered from 1 to N, and each restaurant has a rating between 1 and 100. Akash wants to select K different restaurants such that the minimum rating of any selected re...
Compilable
For this Question: You are given an integer A and a floating point number B, upto exactly two decimal places. Compute their product, truncate its fractional part, and print the result as an integer.Since this will be a functional problem, you don't have to take input. You just have to complete the function solve() that...
Compilable
For this Question: There is a rope of length L which you have to cut at 11 positions to divide it into 12 ropes. Here, each of the 12 resulting ropes must have a positive integer length. Find the number of ways to do this division. Note: Two ways to do the division are considered different if and only if there is a p...
Compilable
For this Question: There is a rope of length L which you have to cut at 11 positions to divide it into 12 ropes. Here, each of the 12 resulting ropes must have a positive integer length. Find the number of ways to do this division. Note: Two ways to do the division are considered different if and only if there is a p...
Compilable
For this Question: There is a rope of length L which you have to cut at 11 positions to divide it into 12 ropes. Here, each of the 12 resulting ropes must have a positive integer length. Find the number of ways to do this division. Note: Two ways to do the division are considered different if and only if there is a p...
Compilable
For this Question: Take input from standard input while you do not get 0 as an input. Print all the inputs separated by space. It is guaranteed that the number of integers are less than 100000.The input will contain a series of integers in one line each. Input should be taken while you have not get a 0 as an input. ...
Compilable
For this Question: Take input from standard input while you do not get 0 as an input. Print all the inputs separated by space. It is guaranteed that the number of integers are less than 100000.The input will contain a series of integers in one line each. Input should be taken while you have not get a 0 as an input. ...
Compilable
For this Question: Take input from standard input while you do not get 0 as an input. Print all the inputs separated by space. It is guaranteed that the number of integers are less than 100000.The input will contain a series of integers in one line each. Input should be taken while you have not get a 0 as an input. ...
Compilable
For this Question: Given an sorted array <b>Arr[]</b> of size <b>N</b>, containing both <b>negative</b> and <b>positive</b> integers, you need to print the squared sorted output. <b>Note</b> Try using two pointer approachThe first line of input contains T, denoting the number of test cases. Each testcase contains 2 ...
Compilable
For this Question: Given an sorted array <b>Arr[]</b> of size <b>N</b>, containing both <b>negative</b> and <b>positive</b> integers, you need to print the squared sorted output. <b>Note</b> Try using two pointer approachThe first line of input contains T, denoting the number of test cases. Each testcase contains 2 ...
Compilable
For this Question: <b> The only difference between the easy and the tricky version is the constraint on the number of queries Q. Solving the tricky version automatically solves the easy version.</b> You are given an array A of N integers. You will be given Q queries with two integers L and R. For each query, you ne...
Compilable
For this Question: <b> The only difference between the easy and the tricky version is the constraint on the number of queries Q. Solving the tricky version automatically solves the easy version.</b> You are given an array A of N integers. You will be given Q queries with two integers L and R. For each query, you ne...
Compilable
For this Question: <b> The only difference between the easy and the tricky version is the constraint on the number of queries Q. Solving the tricky version automatically solves the easy version.</b> You are given an array A of N integers. You will be given Q queries with two integers L and R. For each query, you ne...
Compilable
For this Question: Check if given two number are in golden ratio. Two numbers are said to be in the golden ratio if their ratio is the same as the ratio of the sum of the two numbers to the larger number . If A>B>0 then A and B are in golden ratio if <b> A+B / A = A/B = 1.618 </b> <b>Note</b> : precision is impo...
Compilable
For this Question: Check if given two number are in golden ratio. Two numbers are said to be in the golden ratio if their ratio is the same as the ratio of the sum of the two numbers to the larger number . If A>B>0 then A and B are in golden ratio if <b> A+B / A = A/B = 1.618 </b> <b>Note</b> : precision is impo...
Compilable
For this Question: Given a number N. Write a program to the find number of diagonals possible in N sided convex polygon.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>numberOfDiagonal()</b> that takes the integer N parameter. Constr...
Compilable
For this Question: Given a number N. Write a program to the find number of diagonals possible in N sided convex polygon.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>numberOfDiagonal()</b> that takes the integer N parameter. Constr...
Compilable
For this Question: Given a number N. Write a program to the find number of diagonals possible in N sided convex polygon.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>numberOfDiagonal()</b> that takes the integer N parameter. Constr...
Compilable
For this Question: Given a number N. Write a program to the find number of diagonals possible in N sided convex polygon.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>numberOfDiagonal()</b> that takes the integer N parameter. Constr...
Compilable
For this Question: You are given a number N. You need to Fix the middle bit of N in binary form and print the result in decimal form. If number of bits in binary form of N are odd then Fix the middle bit (Like 111 to 101). If number of bits in binary form of N are even then Fix both the middle bits (Like 1111 to 10...
Compilable
For this Question: You are given a number N. You need to Fix the middle bit of N in binary form and print the result in decimal form. If number of bits in binary form of N are odd then Fix the middle bit (Like 111 to 101). If number of bits in binary form of N are even then Fix both the middle bits (Like 1111 to 10...
Compilable
For this Question: You are given a number N. You need to Fix the middle bit of N in binary form and print the result in decimal form. If number of bits in binary form of N are odd then Fix the middle bit (Like 111 to 101). If number of bits in binary form of N are even then Fix both the middle bits (Like 1111 to 10...
Compilable
For this Question: You are given a chessboard of size N x N, where the top left square is black. Each square contains a value. Find the sum of the values of all black squares and all white squares. Remember that in a chessboard black and white squares are alternate.The first line of input will be the N size of the m...
Compilable
For this Question: You are given a chessboard of size N x N, where the top left square is black. Each square contains a value. Find the sum of the values of all black squares and all white squares. Remember that in a chessboard black and white squares are alternate.The first line of input will be the N size of the m...
Compilable
For this Question: Given a double linked list consisting of N nodes, your task is to reverse the linked list and return the head of the modified list.<b>User Task:</b> Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>Reverse()</b> that takes head node of ...
Compilable
For this Question: Given an array Arr[] of size N. Your task is to check whether you can divide the array into two subsets of equal sum.The first line of input contains a single integer N. The next line of input contains N space separated integers depicting the values of the Arr. Constraints:- 1 <= N <= 100 1 <= A...
Compilable
For this Question: Given an array Arr[] of size N. Your task is to check whether you can divide the array into two subsets of equal sum.The first line of input contains a single integer N. The next line of input contains N space separated integers depicting the values of the Arr. Constraints:- 1 <= N <= 100 1 <= A...
Compilable
For this Question: Given an array Arr[] of size N. Your task is to check whether you can divide the array into two subsets of equal sum.The first line of input contains a single integer N. The next line of input contains N space separated integers depicting the values of the Arr. Constraints:- 1 <= N <= 100 1 <= A...
Compilable
For this Question: Given a stack of integers and N queries. Your task is to perform these operations:- <b>push:-</b>this operation will add an element to your current stack. <b>pop:-</b>remove the element that is on top <b>top:-</b>print the element which is currently on top of stack <b>Note:-</b>if the stack is ...
Compilable
For this Question: Given an ArrayList of N lowercase characters. The task is to insert given elements in the list and count frequency of elements present in the list. You can use some inbuilt functions as:- add() to append element in the list contains() to check an element is present or not in the list collecti...
Compilable
For this Question: You are given an array A of N integers. You can perform the following operation as many times as you like:- Choose two indices i and j (1 <= i < j <= N), replace A[i] by A[i] OR A[j] and replace A[j] by A[i] AND A[j]. (where OR and AND are logical operators). All you need to do is find the maximu...
Compilable
For this Question: You are given an array A of N integers. You can perform the following operation as many times as you like:- Choose two indices i and j (1 <= i < j <= N), replace A[i] by A[i] OR A[j] and replace A[j] by A[i] AND A[j]. (where OR and AND are logical operators). All you need to do is find the maximu...
Compilable
For this Question: There is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves. You have given a string of moves that represents the move sequence of the robot where moves[i] represent its ith move. Valid...
Compilable
For this Question: There is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves. You have given a string of moves that represents the move sequence of the robot where moves[i] represent its ith move. Valid...
Compilable