
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 26504 Articles for Server Side Programming

301 Views
Suppose we have to find all non-negative integers of length N such that the absolute difference between every two consecutive digits is K. We have to keep in mind that every number in the answer must not have leading zeros except for the number 0 itself. We may return the answer in any order. So if N = 3 and K = 7, then output will be [181, 292, 707, 818, 929], Here we can see 070 is not a valid number, because it has one leading zero.To solve this, we will follow these steps −Create one matrix called dp, ... Read More

470 Views
Suppose there are 8 prison cells in a row, and in each cell there is a prisoner or that is empty. In each day, whether the cell is occupied or vacant changes according to the following rules −If one cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.Otherwise, it becomes empty.We will describe the current state of the prison in the following way: cells[i] will be 1 if the i-th cell is occupied, else cells[i] will be 0.So we have the initial state of the prison, then return the state of the ... Read More

302 Views
Suppose we have an array of integers A with even length, now we have to say true if and only if it is possible to reorder it in such a way that A[2 * i + 1] = 2 * A[2 * i] for every 0 0, thenif m[key of kv] is not 0 and m[2* key of kv] > 0x := min of m[key of kv] and m[2* key of kv]cnt := cnt – (x * 2)decrease m[2 * key of kv] by xdecrease m[key of kv] by xotherwise when key of kv = 0, thencnt := cnt ... Read More

449 Views
Suppose we have a deck of cards; every card has a one unique number. We can order the deck in any order that we want. So Initially, all the cards start face down (unrevealed) in one deck. Now, we do the following steps multiple times, until all cards are revealed −Suppose we have a deck of cards; every card has a one unique number. We can order the deck in any order that we want. So Initially, all the cards start face down (unrevealed) in one deck. Now, we do the following steps multiple times, until all cards are revealed ... Read More

422 Views
Suppose we have an initial power P, an initial score of 0 points, and one bag of tokens. Now each token can be used at most once, there is a value token[i], and has potentially two ways to use it, these are as follows −If we have at least token[i] power, then we may play the token face up, losing token[i] power, and gaining 1 point.Otherwise when we have at least 1 point, we may play the token face down, gaining token[i] power, and losing 1 point.We have to find the largest number of points that we can have after ... Read More

361 Views
Suppose we have an array of integers A, here a move consists of choosing any A[i], and incrementing it by 1. We have to find the least number of moves to make every value in A unique. So if the input is like [3, 2, 1, 2, 1, 7], then the output will be 6, as after 6 moves, the array could be [3, 4, 1, 2, 5, 7], it can be shown with 5 or less moves that it is impossible for the array to have all distinct values.To solve this, we will follow these steps −ret:= 0sort array ... Read More

532 Views
Suppose an array A of 0s and 1s is given, we have to find how many non-empty subarrays have sum S? So if the input is like [1, 0, 1, 0, 1], and S = 2, then the result will be 4, as the subarrays are [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1].To solve this, we will follow these steps −Define a method called atMost(), this will take array A and integer xif x < 0, then return 0, set j := 0 and set ret := ... Read More

363 Views
Suppose a string of '0's and '1's is given. That string will be monotonic increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.). We have a string S of '0's and '1's, and we may flip any '0' to a '1' or a '1' to a '0'. Find the minimum number of flips to make S monotone increasing. So if the input is like “010110”, then the output will be 2. By flipping we can get “011111” or “000111”.To solve this, we will follow these steps −n := size ... Read More

443 Views
Suppose we have an array A, we have to partition it into two subarrays left and right such that −Every element in left subarray is less than or equal to every element in right subarray.left and right subarrays are non-empty.left subarray has the smallest possible size.We have to find the length of left after such a partitioning. It is guaranteed that such a partitioning exists.So if the input is like [5, 0, 3, 8, 6], then the output will be 3, as left array will be [5, 0, 3] and right subarray will be [8, 6].To solve this, we will ... Read More