
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

1K+ Views
Suppose we have two arrays arr1 and arr2. The XOR sum of a list is the bitwise XOR of all of its elements. If the list has only one element, then its XOR sum will be the element itself. Now, consider the list has the result of arr1[i] AND arr2[j] (bitwise AND) for every index pair (i, j) where 0

203 Views
Suppose we have an array nums with positive values. We have to find the number of different GCDs among all non-empty subsequences of nums. As we know the GCD of a sequence of numbers is the greatest value that divides all the numbers in the sequence evenly.So, if the input is like nums = [4, 6, 18], then the output will be 4 because gcd([4]) = 4, gcd([6]) = 6, gcd([18]) = 18 gcd([4, 6]) = 2, gcd([4, 18]) = 2, gcd([6, 18]) = 6, gcd([4, 6, 18]) = 2 so all numbers are [4, 6, 18, 2], there are ... Read More

155 Views
Suppose we have a value batchSize and an array group where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. So there is a donuts shop that bakes donuts in batches of given batchSize. But they have one rule, they must serve all of the donuts of a batch before serving any donuts of the next batch. And each customer will get exactly one donut. When a group enters the shop, all customers of that group must be served before addressing any next groups. One group may happy if they all get fresh donuts. ... Read More

185 Views
Suppose we have a number pf represents number of prime factors. We have to make a positive number n that satisfies the following conditions −The number of prime factors of n (may or may not be distinct) is at most pf.The number of nice divisors of n is maximized. As we know a divisor of n is nice when it is divisible by every prime factor of n.We have to find the number of nice divisors of n. If the answer is too large then return result modulo 10^9 + 7.So, if the input is like pf = 5, then ... Read More

491 Views
Suppose we have an array nums and have two values l and r, we have to find the number of nice pairs. Here a nice pair is a pair (i, j) where 0 >= 1 return res // 2 return test(nums, r + 1) - test(nums, l) nums = [4,1,7,2] l = 2 r = 6 print(solve(nums, l, r))Input[4,1,7,2], 2, 6 Output6

491 Views
Suppose we have an array called nums, whose size is 2*n. We have to perform n operations on this array. In the ith operation (1-indexed), we will do the following:Select two elements, x and y.Get a score of i*gcd(x, y).Remove x and y from the array nums.We have to find the maximum score we can get after performing n operations.So, if the input is like nums = [6, 2, 1, 5, 4, 3], then the output will be 14 because the optimal choices are (1 * gcd(1, 5)) + (2 * gcd(2, 4)) + (3 * gcd(3, 6)) = 1 ... Read More

239 Views
Suppose, we have an array of n integers 'nums'. Each value in 'nums' represent its 'power'. The array will be evaluated 'valid' if the length of the array is greater than two and the first and last value of the array is equal. We have to make the array valid by deleting elements from the array so that the rest can satisfy the condition. As output, we return the maximum possible power value of the array by adding all the power values of the array.So, if the input is like nums = [3, 4, 5, 3, 4], then the output ... Read More

495 Views
Suppose we have an array called nums and a value k. Consider the score of a subarray (i, j) is defined as minimum of subarray nums[i..j] * (j-i+1). Now, a good subarray is a subarray where i -1 and nums[i] >= minNum, doi := i - 1while j < size of nums and nums[j] >= minNum, doj := j + 1ans := maximum of ans and ((j - i - 1) * minNum)minNum := maximum of (nums[i] if i > -1 otherwise -1) and (nums[j] if j < size of nums otherwise -1)return ansExampleLet us see the following implementation ... Read More

329 Views
Suppose we have an array called nums and another value k. The XOR of a segment [left, right] (left 0, thenfor each index j and value prev in dp, donew_dp[i XOR j] := maximum of new_dp[i XOR j] and prev+cntdp := new_dpreturn size of nums - new_dp[0]ExampleLet us see the following implementation to get better understandingdef solve(nums, k): LIMIT = 2**10 temp = [[0 for _ in range(LIMIT)] for _ in range(k)] for i, x in enumerate(nums): temp[i%k][x] += 1 dp = [-2000 for _ in range(LIMIT)] ... Read More