
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

178 Views
Suppose we have a list of numbers called nums and we can reverse any sublist in the list at most once. After performing this operation, we have to find the maximum possible value of$\displaystyle\sum\limits_{i=0}^{n-2}| nums[i+1]-[nums[i]|$So, if the input is like nums = [2, 4, 6], then the output will be 6, as when we reverse [4, 6] we will get the list as [2, 6, 4] and the value |2 − 6| + |6 − 4| = 6To solve this, we will follow these steps −if size of nums

191 Views
Suppose we have a binary matrix where 1 represents land and 0 represents water. And an island is a group of 1s that are surrounded by water. We have to find the size of the largest island. We are allowed to change at most one water cell to land cell.So, if the input is like101000110111then the output will be 7, as we can turn one water cells to land to connect the two islands. So final matrix is like −101000110111To solve this, we will follow these steps −R := row count of mat, C := column count of matmass := ... Read More

309 Views
Suppose we have a list of numbers called nums and another value k, we have to find the largest average value of any sublist of the list whose length is at least k.So, if the input is like nums = [2, 10, -50, 4, 6, 6] k = 3, then the output will be 5.33333333, as sublist [4, 6, 6] has the largest average valueTo solve this, we will follow these steps −left := minimum of nums, right := maximum of numss := sum of all numbers in nums from index 0 to k − 1largest_avg := s / kwhile left

206 Views
Suppose we have two values n and k. Now consider a list of numbers in range 1 through n [1, 2, ..., n] and generating every permutation of this list in lexicographic sequence. For example, if n = 4 we have [1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321]. We have to find the kth value of this permutation sequence as a string.So, if the input is like n = 4 k = 5, then the output will be "1432"To solve this, we will ... Read More

170 Views
Suppose we want to construct one stack called FrequencyStack, Our FrequencyStack has two functions −append(x), This will append or push a value x onto the stack.pop(), This will remove and returns the most frequent element in the stack. If there are more than one elements with the same frequency, then the element closest to the top of the stack is removed and returned.So, if the input is like append some elements like 7, 9, 7, 9, 6, 7, then perform the pop operations four times, then the output will be 7, 9, 7, 6 respectively.To solve this, we will follow ... Read More

221 Views
Suppose we have two lists of numbers of same length called performance and costs. And we also have another number k. These indicates that each worker i performs at performance[i] level and it takes costs at least costs[i]. We have to find the minimum cost to hire k employees given also that the workers will be paid proportionate to their performance compared to other employees in the group.So, if the input is like performance = [5, 3, 2] costs = [100, 5, 4] k = 2, then the output will be 10, as we can select emp1 and emp2. They ... Read More

660 Views
Suppose we have a string s, we have to find the number of non-empty unique subsequences of s. If the answer is very large then mod the result by 10^9 + 7.So, if the input is like s = "xxy", then the output will be 5, as there are five subsequences: "x", "xx", "xy", "y" and "xxy".To solve this, we will follow these steps −m := 10^9 + 7n := size of sDefine an array table of size 26res := 0for initialize i := 1, when i

309 Views
Suppose we have a 2d binary matrix, we have to find the number of distinct islands in the given matrix. Here 1 represents land and 0 represents water, so an island is a set of 1s that are close and whose perimeter is surrounded by water. Here two islands are unique if their shapes are different.So, if the input is like100001010101101001001000011011then the output will be 4 (distinct islands are in different color).To solve this, we will follow these steps −Define a function dfs() . This will take i, j, k, lmat[i, j] := 0insert pair (i − k, j − ... Read More

112 Views
Suppose we have a strings s. The s is containing digits from 0 - 9 and we also have another number k. We have to find the number of different ways that s can be represented as a list of numbers from [1, k]. If the answer is very large then return result mod 10^9 + 7.So, if the input is like s = "3456" k = 500, then the output will be 7, as we can represent s like [3, 4, 5, 6], [34, 5, 6], [3, 4, 56], [3, 45, 6], [34, 56], [345, 6], [3, 456]To solve ... Read More

168 Views
Suppose we have a 2D matrix with 3 possible values −0 for an empty cell.1 for a coin.−1 for a wall.We have to find the maximum number of coins we can take by starting from the top−left cell and reaching the bottom−right cell by moving only right or down direction. Then come back to the top−left cell by only moving up or left direction. When we pick up a coin, the cell value becomes 0. If we cannot reach the bottom−right cell, then return 0.So, if the input is like011111−111011then the output will be 8.To solve this, we will follow ... Read More