
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

263 Views
Suppose we have a list of intervals in the form [start, end], this is representing the start and end time of a course. We have to find the maximum number of courses we can take, assuming we can only take one course at a time and the start of a course needs to be later than the end of the last course.So, if the input is like times = [[3, 6], [6, 9], [7, 8], [9, 11]], then the output will be 3, as we can take courses [[3, 6], [7, 8], [9, 11]]To solve this, we will follow these ... Read More

226 Views
Suppose we have a list of boxes, here each entry has two values [start, end] (start < end). We can join two boxes if the end of one is equal to the start of another. We have to find the length of the longest chain of boxes.So, if the input is like blocks = [ [4, 5], [5, 6], [4, 8], [1, 2], [2, 4] ], then the output will be 4, as we can form the chain: [1, 2], [2, 4], [4, 5], [5, 6]To solve this, we will follow these steps:if boxes are empty, thenreturn 0sort the list ... Read More

198 Views
Suppose we have a list of numbers called candies and someone is playing a game against his/her friend. In each round, a player can remove any two consecutive candies with the same value. And whoever can not pick up a candy loses and that player1 start first, we have to check whether player1 will win or not.So, if the input is like nums = [2, 2, 5], then the output will be True, as if player1 picks the 2s then the other player cannot pick any candies.To solve this, we will follow these steps:stack := a new stackturns := 0for ... Read More

908 Views
Suppose we have a string s containing a boolean expression with operators "and" and "or", evaluate it and return the result. Here the expressions may have parentheses, which should be evaluated first.So, if the input is like s = "T and (F or T)", then the output will be TrueTo solve this, we will follow these steps:stack := a new listt = list of elements of s split by blank spacesfor each v in t, doif v[0] is same as "(", thenpush true when v[from index of "(" to end] is same as "T", into stackotherwise when ")" is found, ... Read More

964 Views
Suppose we have a list of sorted numbers called days, where we must take the bus for on each day. We have to find the lowest cost it takes to travel for all the days. There are 3 types of bus tickets. 1-day pass for 2 bucks 7-day pass for 7 bucks 30-day pass for 25 bucksSo, if the input is like days = [1, 3, 5, 6, 28], then the output will be 9, as the lowest cost can be achieved by purchasing a 7-day pass in the beginning and then a 1-day pass on the 29th day.To solve ... Read More

418 Views
Suppose we have two lists of numbers L1 and L2, the length of each list is n and each value is unique to its list, and values are in range 1 to n, we have to find the minimum number of adjacent swaps required to transform L1 to L2.So, if the input is like L1 = [0, 1, 2, 3] L2 = [2, 0, 1, 3], then the output will be 2, as we can swap 1 and 2, L1 will be [0, 2, 1, 3], and then 0 and 2, L1 will be [2, 0, 1, 3], this is ... Read More

189 Views
Suppose we have a list of stock prices of a company in chronological sequence, and also have the transaction fee for one sell transaction. We have to find the maximum profit we could have made from buying and selling that stock any number of times. We must buy before we can sell it.So, if the input is like prices = [2, 10, 4, 8] fee = 3, then the output will be 6, as we can buy at 2 and sell at 10 and incur a fee of 3, so profit is 5. Then we buy at 4 and sell ... Read More

183 Views
Suppose we have a 2d binary matrix, where 1 represents a bomb and 0 represents an empty cell. When a bomb explodes, all the spaces along on the same row and column are damaged. We have to find the number of spaces we can stand in to not get damaged.So, if the input is like110000000then the output will be 2, as there are two spaces the bottom right cell and the middle right cell are safe.To solve this, we will follow these steps:r := a list of size same as row count of matrix and fill with falsec := a ... Read More

128 Views
Suppose we have a list of numbers called nums and another value k. We have to following operation k times: Select any number on the list. In the binary representation of that number, select a bit that is 0 and make it 1. Finally, we have to return the minimum possible sum of all the numbers after performing k operations. If the answer is too high, return result mode 10^9+7.So, if the input is like nums = [4, 7, 3] k = 2, then the output will be 17, as the binary representation of 4 is 100, 3 is 011, ... Read More

91 Views
Suppose we have n children standing in a circle, and they are waiting to get a balloon. The distribution is carried out starting with the kth child (first at index 0), and giving them a balloon they left the circle. Now every kth child gets a balloon going clockwise until there is only one child left that gets a balloon. So if we have n and k, we have to find the starting index of the child that receives the last balloon.So, if the input is like n = 3 k = 2, then the output will be 1, in ... Read More