
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

163 Views
Suppose we have two arrays A with n elements and B with m elements. Select some element a form A and some element b from B, such that a + b does not belong to A or B.So, if the input is like A = [3, 2, 2]; B = [1, 5, 7, 7, 9], then the output will be [3, 1], because 3 + 1 = 4 is not present in any array. (Other answers are also available)StepsTo solve this, we will follow these steps −sort the array A sort the array B return last element of A and ... Read More

312 Views
Suppose we have a matrix containing H rows and W columns. The cells either holds '.' or '#'. The dot '.' indicates passable space, and '#' indicates block. Amal will go from his house to a market. His house is in the cell at the top-left corner, and the market is at the bottom-right corner. Amal can move one cell up, down, left, or right to a passable cell. He cannot leave the town. He cannot enter a blocked cell, either. However, his physical strength allows him to destroy all blocks in a square region with 2×2 cells of his ... Read More

220 Views
Suppose we have two numbers a and b. We have to find the smallest possible value of (a XOR x) + (b XOR x) for some value of x.So, if the input is like a = 6; b = 12, then the output will be 10, because if x = 4, then (6 XOR 4) + (12 XOR 4) = 2 + 8 = 10.StepsTo solve this, we will follow these steps −return a XOR bExampleLet us see the following implementation to get better understanding −#include using namespace std; int solve(int a, int b){ return (a^b); } int main(){ int a = 6; int b = 12; cout

161 Views
Suppose we have an array A with N elements and another value K. For an integer X in range 0 to K, let f(X) = (X xor A[1]) + (X xor A[2]) + ... + (X xor A[N]). We have to find the maximum possible value of f.So, if the input is like K = 7; A = [1, 6, 3], then the output will be 14, because f(4) = (4 XOR 1) + (4 XOR 6) + (4 XOR 3) = 5 + 2 + 7 = 14.StepsTo solve this, we will follow these steps −n := size of ... Read More

761 Views
Suppose we have a coordinate (x, y). On a 2D grid, a robot is at (0, 0) position and want to reach (x, y). It can move up, down, left or right or stay at current cell. It wants to reach destination with as minimum as possible commands. We have to count the number of steps needed.So, if the input is like x = 3; y = 4, then the output will be 7StepsTo solve this, we will follow these steps −return x + y + minimum of |x - y|, |x - y + 1|, and |x - y ... Read More

212 Views
Suppose we have an array A with N elements. In each operation, we pick an element and increase or decrease it by 1. We have to find at least how many operations are needed to satisfy following conditions −For every i in range 1 to n, the sum of the terms from 1st through ith term is not 0For every i in range 1 to n - 1, the sign of the terms from the 1st through ith term is different from sign of the sum of the terms from the 1st through (i+1)th term.So, if the input is like ... Read More

154 Views
To generate a pseudo Vandermonde matrix of the Hermite polynomial, use the hermite.hermvander2d() in Python Numpy. The method returns the pseudo-Vandermonde matrix. The parameter, x, y are an array of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. The parameter, deg is the list of maximum degrees of the form [x_deg, y_deg].StepsAt first, import the required library −import numpy as np from numpy.polynomial import hermite as HCreate arrays of point coordinates, all of the same shape ... Read More

203 Views
Suppose we have an array A with K number of elements. Consider, in a game there are N players and a game master is there. This game has K rounds. In ith round game master announces to form groups with A[i] number of children. Then the remaining children form as many groups of A[i] children as possible. One child cannot take part into multiple groups. Those who are left without a group leave the game. The others proceed to the next round. A round may have with no player loss. In the end, after the K-th round, there are exactly ... Read More

224 Views
Suppose we have an array A with n elements. A function F(p) is a sorted array of sums of adjacent elements in p. So F(p) = sort([p1 + p2, p2 + p3, ... pn-1 + pn]). We have a permutation represented in A. We have to find the different permutation of A where F(A) is same.So, if the input is like A = [2, 1, 6, 5, 4, 3], then the output will be [1, 2, 5, 6, 3, 4], because F(A)=sort([2+1, 1+6, 6+5, 5+4, 4+3]) = sort([3, 7, 11, 9, 7]) = [3, 7, 7, 9, 11]. And sort([1+2, ... Read More

135 Views
To generate a Hermite series with given roots, use the hermite.hermfromroots() method in Python Numpy. The method returns a 1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real. The parameter roots are the sequence containing the roots.StepsAt first, import the required library −import numpy as np from numpy.polynomial import hermite as HTo generate a Hermite series with given roots, use the hermite.hermfromroots() method in Python Numpy −print("Result...", H.hermfromroots((-1, 0, 1)))Get the datatype −print("Type...", ... Read More