
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

127 Views
Suppose we have a list of intervals where each interval is like [start, end) and we also have a list of strings called types. Now for a given i, the intervals[i] shows the times someone worked on the job types[i] from [start, end). Two intervals of the same type never overlap or touch. So we have to find a sorted merged list where each item has [start, end, num_types], indicates from start to end, num_types number of tasks were being worked on.So, if the input is like intervals = [ [0, 3], [5, 7], [0, 7] ] types = ["problem ... Read More

365 Views
Suppose we have a linked list. We have to rotate the list to the right by k places. The value of k will be positive. So if the list is like [1 −> 2 −> 3 −> 4 −> 5 −> NULL], and k = 2, then the output will be [4 −> 5 −> 1 −> 2 −> 3 −> NULL]Let us see the steps −If the list is empty, then return nulllen := 1create one node called tail := headwhile next of tail is not nullincrease len by 1tail := next of tailnext of tail := headk := ... Read More

2K+ Views
Suppose we have a square matrix, we have to rotate it 90 degrees counter-clockwise.147258369then the output will be789456123To solve this, we will follow these steps −if matrix is empty, thenreturn a blank listn := row count of matrixfor each row in matrix, doreverse the rowfor i in range 0 to n−1, dofor j in range 0 to i−1, doswap matrix[i, j] and matrix[j, i]return matrixLet us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, matrix): if not matrix or not matrix[0]: return [] n ... Read More

260 Views
Suppose we have a robot, that is currently sitting in at position (0, 0) (Cartesian plane). If we have list of its moves that it can make, containing N(North), S(South), W(West), and E(East). However, if the robot reaches a spot it has been in before, it will continue moving in the same direction until it reaches a new unvisited spot. We have to check whether after its moves it will end at (x, y) coordinate or not.So, if the input is likemoves = ['N', 'N', 'E', 'N', 'W', 'S'], coord = [0, -1], then the output will be True, as ... Read More

757 Views
Suppose we have a rod is given of length n. We also have a list, that contains different size and price for each size. We have to find the maximum price by cutting the rod and selling them in the market. To get the best price by making a cut at different positions and comparing the prices after cutting the rod.So, if the input is like prices = [1, 5, 8, 9, 10, 17, 17, 20], n = 8, then the output will be 22, as by cutting the rod in length 2 and 6. The profit is 5 + ... Read More

174 Views
Suppose we have a list of numbers called weights this is representing peoples' weights and a value limit determines the weight limit of one rocket ship. Now each rocketship can take at most two people. We have to find the minimum number of rocket ships it would take to rescue everyone to Planet.So, if the input is like weights = [300, 400, 300], limit = 600, then the output will be 2, as it will take one rocket ship to take the two people whose weights are 300 each, and another to take the person whose weight is 400.To solve ... Read More

413 Views
Suppose we have a singly linked list, and another value k, we have to reverse every k contiguous group of nodes.So, if the input is like List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k = 3, then the output will be [3, 2, 1, 6, 5, 4, 9, 8, 7, 10, ]To solve this, we will follow these steps −tmp := a new node with value 0next of tmp := nodeprev := null, curr := nulllp := temp, lc := currcnt := kwhile curr is not null, doprev := nullwhile cnt > 0 and curr ... Read More

1K+ Views
Suppose we have a directed graph, we have to find its reverse so if an edge goes from u to v, it now goes from v to u. Here input will be an adjacency list, and if there are n nodes, the nodes will be (0, 1, ..., n-1).So, if the input is likethen the output will beTo solve this, we will follow these steps −ans := a list of n different lists, where n is number of verticesfor each index i, and adjacent list l in graph, dofor each x in l, doinsert i at the end of ans[x]return ... Read More

543 Views
Suppose we have a linked list, we have to reverse it. So if the list is like 2 -> 4 -> 6 -> 8, then the new reversed list will be 8 -> 6 -> 4 -> 2.To solve this, we will follow this approach −Define one procedure to perform list reversal in recursive way as solve(head, back)if head is not present, then return headtemp := head.nexthead.next := backback := headif temp is empty, then return headhead := tempreturn solve(head, back)Let us see the following implementation to get better understanding −Exampleclass ListNode: def __init__(self, data, next = None): ... Read More

423 Views
Suppose we have a string s, we repeatedly delete the first consecutive duplicate characters. We have to find the final string.So, if the input is like s = "xyyyxxz", then the output will be "z", as "yyy" are the first consecutive duplicate characters which will be deleted. So we have "xxxz". Then "xxx" will be deleted to end up with "z".To solve this, we will follow these steps −stack := a new stacki := 0while i < size of s, doif stack is not empty and top of stack is same as s[i], thenx := delete last element from stackwhile ... Read More