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
Server Side Programming Articles - Page 1749 of 2650
208 Views
Suppose there are n people and 40 different types of hats those are labeled from 1 to 40. Now a 2D list is given called hats, where hats[i] is a list of all hats preferred by the i-th person. We have to find the number of ways that the n people wear different hats to each other. The answer may come very large, so return the answer modulo 10^9 + 7.So, if the input is like [[4, 6, 2], [4, 6]], then the output will be 4, as there are 4 different ways to choose, these are [4, 6], [6, ... Read More
180 Views
Suppose we have an array called nums and an integer k, we have to find the maximum sum of a non-empty subsequence of that array such that for every two consecutive numbers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i k and first element of dq is same as dp[i - k - 1], thendelete front element from dqdp[i] := maximum of dp[i] and (if dq is empty, then dp[i] + 0, otherwise first element of dp + dq[i])while (not dq is empty and last element of dq < dp[i]), do −delete ... Read More
376 Views
Suppose there is a program that is used to print the array elements of an array A, but there was a little mistake in the program. In that program there was no white space after each element, so if we have one printed string, can we regenerate the array again? We know the array elements are in range 1 to k.Given the string s and the integer k. We have to find how many number of ways we can restore the array. The answer may be very large so return it modulo 10^9 + 7.So, if the input is like ... Read More
309 Views
Suppose we have grid of size n x 3 and we want to paint each cell of the grid with exactly one of the three colors. The colors are Red, Yellow or Green. Now there is a constraint that is no two adjacent cells have the same color. We have n the number of rows of the grid. We have to find the number of ways we can paint this grid. The answer may be very large so return it modulo 10^9 + 7.So, if the input is like 1, then the output will be 12To solve this, we will ... Read More
246 Views
Suppose Amal and Bimal are playing with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is a number given in the array called stoneValue.Amal and Bimal take turns, with Amal starting first. On each player's turn, he/she can take 1, 2 or 3 stones from the first remaining stones in the row.The score of each player is the sum of values of the stones taken. Initially the score is 0. The goal of the game is to end with the highest score, and the winner is the player with ... Read More
561 Views
Suppose there is a chef. And he has collected data on the satisfaction level of his n dishes. The Chef can cook any dish in 1 unit of time. Like-time coefficient of a dish is actually the time takento cook that dish including previous dishes multiplied by its satisfaction level So time[i]*satisfaction[i].We have to find the maximum sum of Like-time coefficient that the chef can obtain after dishes preparation. Dishes can be ready in any order and the chef can discard some dishes to get this maximum value.So, if the input is like [-1, -7, 0, 6, -7], then the ... Read More
462 Views
Suppose we have two strings s1 and s2. The size of these strings is n, and we also have another string called evil. We have to find the number of good strings.A string is called good when its size is n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it has no evil as a substring. The answer may be very large, so return the answer modulo 10^9 + 7.So, if the input is like n = 2, s1 = "bb", s2 = "db", evil = "a", then the ... Read More
1K+ Views
Suppose we have a string s, we have to find the longest happy prefix of s. A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself). If there is no such happy prefix, then simply return blank string.So, if the input is like "madam", then the output will be "m", it has 4 prefixes excluding itself. These are "m", "ma", "mad", "mada" and 4 suffixes like "m", "am", "dam", "adam". The largest prefix which is also suffix is given by "m".To solve this, we will follow these steps −Define a function ... Read More
350 Views
Suppose there is a pizza with 3n slices of varying size, I and my two friends will take slices of pizza as follows −I shall pick any pizza slice.My friend Amal will pick next slice in anti clockwise direction of my pick.My friend Bimal will pick next slice in clockwise direction of my pick.Repeat these steps until there are no more slices of pizzas.Sizes of Pizza slices is represented by circular array slices in clockwise direction. We have to find the maximum possible sum of slice sizes which I can have.So, if the input is like [9, 8, 6, 1, ... Read More
268 Views
Suppose there are n engineers. They are numbered from 1 to n and we also have two arrays: speed and efficiency, here speed[i] and efficiency[i] represent the speed and efficiency for the ith engineer. We have to find the maximum performance of a team composed of at most k engineers. The answer may be very large so return it modulo 10^9 + 7.Here the performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers.So, if the input is like n = 6, speed = [1, 5, 8, 2, 10, 3], efficiency ... Read More