
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

851 Views
Suppose we have an array called jobs, where jobs[i] indicates the amount of time needed to complete the ith job. We also have another value k, to them we can assign jobs. Each job should be assigned to exactly one worker. And the working time of a worker is the total time it takes to complete all jobs assigned to them. We have to find the minimum possible maximum working time of any assignment.So, if the input is like jobs = [2, 1, 3, 8, 5], k = 2, then the output will be 10 because, we can assign jobs ... Read More

828 Views
Suppose we have a string s, we have to count the number of distinct subsequences of the string s. If the answer is too large then return result modulo 10^9 + 7.So, if the input is like s = "bab", then the output will be 6 because there are 6 different sequences, these are "a", "b, "ba", "ab", "bb", "abb".To solve this, we will follow these steps −dp := an array whose size is same of s and filled with 0m := 10^9 + 7for each index i and item char in s, doind := index of i-th char in ... Read More

273 Views
Suppose we have two strings s and t. These two strings are K-similar when we can swap the positions of two letters in s exactly K times so that the resulting string is t. We have two anagrams s and t, and we have to find the smallest K for which s and t are K-similar.So, if the input is like s = "abc", t = "bac", then the output will be 1.To solve this, we will follow these steps −Define a function swapp(), this will take string s, i, j, x := s[i], y := s[j]s[i] := y, s[j] ... Read More

324 Views
Suppose we have an array called nums with non-negative values. We also have another array called queries where queries[i] has a pair (xi, mi). The answer of ith query is the maximum bitwise XOR value of xi and any element of nums that less than or equal to mi. If all elements in nums are larger than mi, then the answer is -1. So we have to find an array answer where size of answer is same as size of query and answer[i] is the answer to the ith query.So, if the input is like nums = [0, 1, 2, ... Read More

392 Views
Suppose we have one binary array nums, and a value k. In one move, we can select two adjacent indices and swap their values. We have to find the minimum number of moves required so that nums has k consecutive 1's.So, if the input is like nums = [1, 0, 0, 1, 0, 1, 0, 1], k = 3, then the output will be 2 because in one swap we can make array from [1, 0, 0, 1, 0, 1, 0, 1] to [1, 0, 0, 0, 1, 1, 0, 1], then [1, 0, 0, 0, 1, 1, 1, 0].To ... Read More

161 Views
Suppose we have one undirected weighted graph with n nodes using one edgeList, where edgeList[i] has three parameters (u, v, w) denotes there is a path from u to v whose distance is w. We also have another query array where query[i] has (p, q, lim). This query is trying to ask whether there is a path (direct or via some other node) from p to q whose distance is less than lim. We have to return an array holding True/False results for each query.So, if the input is likethen the output will be [True, False, True]. Because to go ... Read More

506 Views
Suppose we have an array nums. We can perform two types of operations on any element of the array any number of timesFor even elements, divide it by 2For odd elements, multiply it by 2.Now the deviation of the array is the maximum difference between any two elements in the array. We have to find the minimum deviation the array can have after performing some number of operations. So, if the input is like nums = [6, 3, 7, 22, 5], then the output will be 5 because we can make our array in one operation [6, 6, 7, 22, ... Read More

189 Views
Suppose we have an array nums, there are at most 50 unique values. We also have another array called quantity, where quantity[i] denotes the amount of values the ith customer ordered.We have to check whether it is possible to distribute nums such thatThe ith customer gets exactly quantity[i] items, The value that the ith customer gets are all equal, andAll customers are satisfied.So, if the input is like nums = [5, 1, 2, 2, 3, 4, 4, 3, 3] quantity = [2, 2, 3], then the output will be True because two customer wants two elements each, so they can ... Read More

748 Views
Suppose we have a list of string called words, where all elements are of same length. We also have a string called target. We have to generate target using the given words under the following rules −We should generate target from left to right.To get the ith character (0-indexed) of target, we can select the kth character of the jth string in words when target[i] is same as words[j][k].Once we use the kth character of the jth string of words, we cannot use the xth character of any string in words where x at index 0 ("qppq"), at index ... Read More

316 Views
Suppose we have a number n, we have to transform it into 0 using the following operations any number of times −Select the rightmost bit in the binary representation of n.Change the ith bit in the binary representation of n when the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.So finally we have to find the minimum number of operations required to transform n into 0.So, if the input is like n = 6, then the output will be 4 because initially 6 = "110", then convert it to "010" by second ... Read More