
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

285 Views
Suppose we have a circular list called nums. So the first and the last elements are neighbors. So starting from any index say i, we can move nums[i] number of steps forward if nums[i] is a positive value, otherwise backwards if it's a negative value. We have to check whether there is a cycle whose length is greater than one such that the path only goes forwards or only goes backwards.So, if the input is like nums = [-1, 2, -1, 1, 2], then the output will be True, because there is a forward path [1 -> 3 -> 4 ... Read More

545 Views
Suppose we have a string s which consists of only three characters "X", "(", and ")". The string has balanced brackets and in between some "X"s are there along with possibly nested brackets may also there recursively. We have to find the number of "X"s at each depth of brackets in s, starting from the shallowest depth to the deepest depth.So, if the input is like s = "(XXX(X(XX))XX)", then the output will be [5, 1, 2]To solve this, we will follow these steps −depth := -1out := a new listfor each c in s, doif c is same as ... Read More

669 Views
Suppose we have a lowercase string s and another list of integers called shifts whose length is same as the length of s. Here each element in shifts[i] indicates it to shift the first i + 1 letters of s by shifts[i] positions. If shifting crosses 'z' it will be wrap up to 'a'. We have to find the resulting string after applying shifts to s.So, if the input is like s = "tomato" shifts = [2, 5, 2, 3, 7, 4], then the output will be "qjcoes" so, after shifting first character 2 places, it will be 't' to ... Read More

267 Views
Suppose we have a list of numbers called bricks and two other values width and height. Each element in bricks[i] represents a brick whose length is bricks[i] units and width is 1 unit. We have to find the number of ways to lay the bricks such that we get full layout of bricks with the given width and height. We can reuse the bricks but can only be laid horizontally.So, if the input is like bricks = [2, 1] width = 3 height = 2, then the output will be 9 because −To solve this, we will follow these steps ... Read More

216 Views
Suppose we have two list of numbers nums1 and nums2. And also have two numbers lower and upper. We have to find the number of pairs (i, j) such that lower ≤ nums1[i]^2 + nums2[j]^2 ≤ upper.So, if the input is like nums1 = [5, 3, 2] nums2 = [8, 12, 6] lower = 10 upper = 50, then the output will be 2 because the pairs are like (1, 2) and (2, 2)10

290 Views
Suppose we have a string s, that represents the moves of a robot. Robot is currently at (0, 0) position and it is facing north. The move string s may have these characters"F" to move forward direction, one unit"L" to rotate 90 degrees’ left"R" to rotate 90 degrees’ rightSo if the robot repeatedly makes the moves in s in order, we have to check whether there is some box in the plane in which the robot never leaves or not.So, if the input is like s = "FFRFRFFRF", then the output will be True, because robot moves 2 units towards ... Read More

290 Views
Suppose we have two values start and end, we have to find the bitwise AND of all numbers in the range [start, end] (both inclusive).So, if the input is like start = 8 end = 12, then the output will be 8 is 1000 in binary and 12 is 1100 in binary, so 1000 AND 1001 AND 1010 AND 1011 AND 1100 is 1000 which is 8.To solve this, we will follow these steps −n := end - start + 1x := 0for b in range 31 to 0, decrease by 1, doif 2^b < n, thencome out from loopif ... Read More

209 Views
Suppose we have a binary list with 0s or 1s. We also have another input called k, we have to find the number of sublists whose sum is same as k.So, if the input is like nums = [1, 0, 0, 1, 1, 1, 0, 1] k = 3, then the output will be 8 because the sublists are [1, 0, 0, 1, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 0], [0, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1], [1, 1, 1, 0] [1, 1, 0, 1].To solve this, we will follow ... Read More
Program to find list showing total distance required to move all balls to current position in Python

130 Views
Suppose we have a binary list called nums containing only 0s and 1s where a 0 indicates empty cell and 1 indicates the cell is filled by a ball. We have to find a new list of say L, whose size is also same like nums size, where L[i] is set to the total distance required to move all the balls to L[i]. Here the distance to move a ball from index j to index i is |j - i|.So, if the input is like nums = [1, 1, 0, 1], then the output will be [4, 3, 4, 5], ... Read More

452 Views
Suppose we have a string s with four directions "N", "S", "W" and "E" for North, South, West and East respectively. We have to find the size of the shortest substring we can update such that each of the four directions occur n/4 times each, where n is the size of string s.So, if the input is like s = "NNSWWESN", then the output will be 1, here n is 8, so 8/4 is 2, so if we change last N to E, all directions will be there twice.To solve this, we will follow these steps −n := size of ... Read More