
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

410 Views
Suppose we have a list of unique and sorted numbers that represent breakpoints in a string. We want to create a tree out of these rules −There are nodes that have a value (a, b) where a and b are breakpoints. This means the node spans from indices [a, b] in the string.The root node spans over every breakpoint. (the whole string).The spans of a node's left and right child are ordered, contiguous, and contains the parent node's span.Leaf nodes' index of 'a' in breakpoints is 1 before the index of 'b' in breakpoints.The cost of a tree is determined ... Read More

282 Views
Suppose we have a 2D matrix and another value k. Our goal is to return a matrix that contains the lowest values of all k x k sub-matrices.So, if the input is like3568654312and k =2, then the output will be [[3, 5], [3, 3]] .From the input, we can see that the top left submatrix has the lowest value of 33 5 8 6The top right submatrix has the lowest value of 55 6 6 5The bottom left submatrix has the lowest value of 38 6 4 3The bottom right submatrix has the lowest value of 36 5 3 12To ... Read More

153 Views
Suppose we have a list of numbers called nums, The width of a sequence of numbers as the difference between the maximum and minimum number in the sequence. We have to find the sum of widths of all subsequences of nums. If the answer is very large then mod the result by 10^9+7.So, if the input is like nums = [7, 4, 9], then the output will be 15, as we have the subsequences like: [7], [4], [9], [7, 4], [7, 9], [4, 9], [7, 4, 9] and So the widths are 0, 0, 0, 3, 2, 5, 5, so ... Read More

224 Views
Suppose we have a list of numbers called nums and we can delete at most one element in the list. We have to find the maximum number of sublists that contain both the maximum and minimum values of the resulting list.So, if the input is like nums = [3, 2, 6, 2, 4, 10], then the output will be 8, as if we remove 10 we will get [3, 2, 6, 2, 4] and there are eight sublists where it contains both the max and the min −[2, 6][6, 2][2, 6, 2][3, 2, 6][6, 2, 4][2, 6, 2, 4][3, 2, ... Read More

154 Views
Suppose we have a list of numbers called nums and another value pos. We have to find a sublist A of nums that includes the index pos such that (minimum of A) * (size of A) is maximized then return the value.So, if the input is like nums = [-2, 2, 5, 4] pos = 3, then the output will be 8, as the best sublist is [5, 4], because (5, 4) = 4 and its size is 2 we have 4 * 2 = 8.To solve this, we will follow these steps −ans := A[pos], m := A[pos]i := ... Read More

369 Views
Suppose we have a string s, this is encoding a longer string. s is represented as the concatenation of n(t), n(t) represents the concatenation of t, n times, and t is either a regular string or it is another encoded string recursively. We have to find the decoded version of s.So, if the input is like s = "3(pi)2(3(am))0(f)1(u)", then the output will be "pipipiamamamamamamu"To solve this, we will follow these steps −i := 0Define a function parse() . This will takeans := a new listwhile i < size of s and s[i] is not same as ")", doif s[i] ... Read More

178 Views
Suppose we have a 2d matrix, we have to find the largest k × k submatrix where all of its elements are containing the same value, then find the value of k.So, if the input is like1183155525554555then the output will be 3, as there is a 3 × 3 square matrix of value 5.To solve this, we will follow these steps −n := row count of matrixm := column count of matrixDefine one 2D array dp of size (n x m) and fill with 1ret := 1for initialize i := n - 1, when i >= 0, update (decrease i ... Read More

148 Views
Suppose we have a lowercase string s, we have to split it into as few strings as possible such that each string is a palindrome and then find the number of strings.So, if the input is like s = "levelracecar", then the output will be 2, as there are two palindromes "level" and "racecar".To solve this, we will follow these steps −n := size of ADefine an array result of size (n + 1)result[n] := -1for initialize i := n - 1, when i >= 0, update (decrease i by 1), do −result[i] := n - i - 1for initialize ... Read More

183 Views
Suppose we have a list of numbers called nums and another value k. We can split the list into k non-empty sublists. We have to find the minimum largest sum of the k sublists.So, if the input is like nums = [2, 4, 3, 5, 12] k = 2, then the output will be 14, as we can split the list like: [2, 4, 3, 5] and [12].To solve this, we will follow these steps −Define a function ok(), this will take array v, k, x,cnt := 0, sum := 0for each element i in v −if sum + i > x, then −sum := i(increase cnt by 1)Otherwisesum := sum + ireturn true when cnt

246 Views
Suppose we have a list of numbers called heights that represents the height of plants and we have another list of values called costs that represents the price needed to increase height of a plant by one. We have to find the smallest cost to make each height in the heights list different from adjacent heights.So, if the input is like heights = [3, 2, 2] costs = [2, 5, 3], then the output will be 3, as we can increase the last height by 1, which costs 3.To solve this, we will follow these steps −Define a function dp() ... Read More