
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

471 Views
Suppose we have a list of cards, and we want to order the cards in a way so that they are revealed in ascending order. As we know, the cards are revealed in this manner: 1. The top most card is removed and revealed and then next card is gone to the back. 2. Step 1 is repeated until there's no more cards. We have to find an ordering of the cards such that they are revealed in ascending order.So, if the input is like cards = [1, 2, 3, 4, 5, 6, 7, 8], then the output will be ... Read More

530 Views
Suppose we have two non-empty strings s and t that are of the same length. We have to partition them into substrings such that each pair of s and t substring is the same size and they are the anagrams of each other. Now find the cut indexes such that it results in the maximum number of cuts of s and t. If no result is found, then return empty list.So, if the input is like s = "bowcattiger" t = "owbactietgr", then the output will be [0, 3, 5, 6, 10], as we can partition the string into 5 ... Read More

418 Views
Suppose we have a list of numbers called nums, now consider every contiguous subarray. Sum each of these subarray and return the sum of all these values. Finally, mod the result by 10 ** 9 + 7.So, if the input is like nums = [3, 4, 6], then the output will be 43, as We have the following subarrays − [3] [4] [6] [3, 4] [4, 6] [3, 4, 6] The sum of all of these is 43.To solve this, we will follow these steps −N:= size of numsans:= 0for i in range 0 to size of nums, don:= nums[i]ans ... Read More

372 Views
Suppose we have a list of numbers called nums and another number k. If we start at index k and at any index i, we can go either left or right by exactly nums[i] number of steps. We have to check whether we can reach the end of the list or not.So, if the input is like nums = [0, 0, 2, 1, 3, 3, 1, 1] k = 2, then the output will be True, as if we start at index 2, then jump to index 4 and then jump to the last index 7.To solve this, we will ... Read More

249 Views
Suppose we have a staircase with n steps and we also have another number k, initially we are at stair 0, and we can climb up either 1, 2 or 3 steps at a time. but we can only climb 3 stairs at most k times. Now we have to find the number of ways we can climb the staircase.So, if the input is like n = 5, k = 2, then the output will be 13, as there are different ways we can climb the stairs −[1, 1, 1, 1, 1][2, 1, 1, 1][1, 2, 1, 1][1, 1, 2, ... Read More

333 Views
Suppose we have a staircase with n steps, and we can climb up either 1 or 2 steps at a time. We have to define a function that returns the number of unique ways we can climb the staircase.The order of the steps should not be changed, so each different order of steps counts as a way. If the answer is very large then mod the result by 10^9 + 7So, if the input is like n = 5, then the output will be 8, as there are 8 unique ways −1, 1, 1, 1, 12, 1, 1, 11, 2, ... Read More

2K+ Views
Suppose we have a list of numbers called nums and that is showing the bus stops on a line where nums[i] shows the time a bus must arrive at station i. Now that buses can only move forward, we have to find the minimum number of buses that are needed to pass through all the stops.So, if the input is like nums = [1, 2, 7, 9, 3, 4], then the output will be 2, as one bus can take stops [1, 2, 3, 4] and another can do [7, 9].To solve this, we will follow these steps−ans := 0seen ... Read More

1K+ Views
Suppose we have two binary strings a and b, we have to add these binary numbers and find their sum, also as a string.So, if the input is like a = "10110", b = "10010", then the output will be "101000".To solve this, we will follow these steps −ret := empty stringna := size of a, nb := size of bi := na - 1, j := nb - 1carry := 0while (i >= 0 or j >= 0), do:addA := (if i >= 0, then a[i] - ASCII of '0', otherwise 0)addB := (if j >= 0, then b[j] ... Read More

577 Views
Suppose we have two lists called weights and values which are of same length and another number called capacity k. Here weights[i] and values[i] shows the weight and value of the ith item. Now, we can take at most k capacity weights, and that we can only take at most one copy of each item, we have to find the maximum amount of value we can get.So, if the input is like weights = [2, 3, 4], values = [2, 6, 4], capacity = 6, then the output will be 8To solve this, we will follow these steps −n:= size ... Read More

452 Views
Suppose we have one n x n matrix M, we have to find the sum of all elements that form a Z shape in the matrix.So, if the input is like432918256then the output will be 23, as elements are [4+3+2+1+2+5+6] = 23.To solve this, we will follow these steps −n := row count of matrixif n