
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 10476 Articles for Python

301 Views
Suppose we have an array of strings called A. One move onto S consists of swapping any two even indexed characters of S, or any two odd indexed characters of S.Now, two strings S and T are special-equivalent if after any number of moves onto S, S is same as T. So, if S = "zzxy" and T = "xyzz" are special-equivalent because we may make the moves like "zzxy" to "xzzy" to "xyzz" that swap S[0] and S[2], then S[1] and S[3].Now, a group of special-equivalent strings from A is a non-empty subset of A such that −In every ... Read More

507 Views
Suppose there is a N x N grid, we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z. Here each value v = grid[i][j] is showing a tower of v cubes placed on top of grid cell (i, j). We view the projection of these cubes onto the xy, yz, and zx planes. Here, we are viewing the projection when looking at the cubes from the top, the front, and the side view. We have to find the total area of all three projections.So, if the input is like [[1, 2], [3, ... Read More

1K+ Views
Suppose there is a robot on an infinite grid that starts at point (0, 0). It is facing towards north direction. Now the robot can receive one of three possible types of commands −-2 to turn left 90 degrees-1 to turn right 90 degreesany value from 1 to 9 to move forward x unitsThere are some grid squares that are obstacles.We also have another array called obstacle, this indicates the i-th obstacle is at grid point (obstacles[i][0], obstacles[i][1]), If the robot wants to move onto them, the robot stays on the previous grid square instead.We have to find the square ... Read More

2K+ Views
Suppose we have a positive integer N, we have to find the longest distance between two consecutive 1's in the binary representation of N. If there are no two-consecutive 1's, then return 0.So, if the input is like 22, then the output will be 2, as 22 in binary is 10110. There are three ones In the binary representation of 22, and two consecutive pairs of 1's. The first consecutive pair of 1's have distance 2, then the second consecutive pair of 1's have distance 1. Answer will be the largest of these two distances, which is 2.To solve this, ... Read More

772 Views
Suppose there is a lemonade stand, each lemonade costs $5. Now customers are standing in a queue to buy from the store, and order one at a time.Each customer can buy only one lemonade and pay with either a $5, $10, or $20 bill. We have to must provide the correct change to each customer, so that the net transaction is that the customer pays $5. And at first, we have no change in hand.We have to check whether we can provide every customer with correct change.So, if the input is like [5, 5, 5, 10, 20], then the output ... Read More

678 Views
Suppose we have two strings A and B of lowercase letters; we have to check whether we can swap two letters in A so that the result equals to B or not.So, if the input is like A = "ba", B = "ab", then the output will be True.To solve this, we will follow these steps −if size of A is not same as size of B, thenreturn Falseotherwise when A and B has any element that are not common, thenreturn Falseotherwise when A is same as B and all characters are distinct in A, thenreturn Falseotherwise, count:= 0for i ... Read More

5K+ Views
Suppose there is a rectangle that is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinates of its bottom-left corner, and (x2, y2) is the coordinates of its top-right corner. Now two rectangles overlap if the area of their intersection is positive. So, we can understand that two rectangles that only touch at the corner or edges do not overlap.If we have two (axis-aligned) rectangles, we have to check whether they overlap or not.So, if the input is like R1 = [0, 0, 2, 2], R2 = [1, 1, 3, 3], then the output will ... Read More

577 Views
Suppose we have a binary matrix A, this is the representation of an image, we want to flip the image horizontally, after that invert it, and finally return the resulting image. To flip the image horizontally each row of the image will be reversed. And to invert the image each 0 will be replaced by 1, and each 1 will be replaced by 0.So, if the input is like110101000then the output will be100010111To solve this, we will follow these steps −result:= a new listfor each row i in A, doReverse:= reverse row ifor j in range 0 to size of ... Read More

230 Views
Suppose there is a string S of lowercase letters, these letters form consecutive groups of the same character. So, when a string like S is like "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z" and "yy". A group will be a large group when it has 3 or more characters. We would like the starting and ending positions of every large group.So, if the input is like "abcdddeeeeaabbbcd", then the output will be [[3, 5], [6, 9], [12, 14]]To solve this, we will follow these steps −ans := a new listcsum := 0for each a, b in make group of ... Read More

686 Views
Suppose we have a list of points on a plane. We have to find the area of the largest triangle that can be formed by any 3 of the points.So, if the input is like [[0, 0], [0, 1], [1, 0], [0, 2], [2, 0]], then the output will be 2To solve this, we will follow these steps −res := 0N := size of points listfor i in range 0 to N - 2, dofor j in range i + 1 to N - 1, dofor k in range i + 2 to N, do(x1, y1) := points[i], (x2, y2) ... Read More