
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 33676 Articles for Programming

981 Views
Suppose we have a N*M matrix A, this is the representation of 3D figure. The height of the building at point (i, j) is A[i][j]. We have to find the surface area of the figure.So, if the input is like N = 3, M = 3, A = [[1, 4, 5], [3, 3, 4], [1, 3, 5]], then the output will be 72.To solve this, we will follow these steps −res := 0for i in range 0 to N, dofor j in range 0 to M, doup_side := 0left_side := 0if i > 0, thenup_side := array[i - 1, j]if ... Read More

164 Views
Suppose we have an array of integers A; we have to find all the values for sum so that for a value sum[i] the array can be divided into sub-arrays of sum sum[i]. If we cannot divide the array into sub-arrays of equal sum then return -1.So, if the input is like A = [2, 4, 2, 2, 2, 4, 2, 6], then the output will be [6, 8, 12] as the array can be divided into sub-arrays of sum 6, 8 and 12. These are as follows: [{2, 4}, {2, 2, 2}, {4, 2}, {6}] [{2, 4, 2}, {2, ... Read More

269 Views
Suppose we have three sorted arrays A, B, and C (these can be of different sizes), we have to find compute the minimum absolute difference between the maximum and minimum number of any triplet (A[i], B[j], C[k]) such that they are under arrays A, B and C respectively, So, if the input is like A : [ 2, 5, 6, 9, 11 ], B : [ 7, 10, 16 ], C : [ 3, 4, 7, 7 ] , then the output will be 1 as by selecting A[i] = 6 B[j] = 7 and C[k] = 7, we will ... Read More

423 Views
Suppose we have an array A of n values (elements may not be distinct). We have to find the sum of maximum difference possible from all subsets of given array. Now consider max(s) denotes the maximum value in any subset, and min(s) denotes the minimum value in the set. We have to find the sum of max(s)-min(s) for all possible subsets.So, if the input is like A = [1, 3, 4], then the output will be 9.To solve this, we will follow these steps −n := size of Asort the list Asum_min := 0, sum_max := 0for i in range ... Read More

291 Views
Suppose we have a given integer N; we have to find the sum of all Truncatable primes less than N. As we know the truncatable prime is a number which is left-truncatable prime (if the leading "left" digit is successively removed, then all resulting numbers are treated as prime) as well as right-truncatable prime (if the last "right" digit is successively removed, then all the resulting numbers are treated as prime). An example of truncatable prime is 9137 as this is lefttruncatable prime because 9137, 137, 37 and 7 are primes. Hence 9137 is a truncatable prime.So, if the input ... Read More

199 Views
Suppose we have a string, s, and we have another list with few words, these words are of same length. We have to find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.So if the input is like “wordgoodgoodgoodword” and words are ["word", "good"], then the output will be [0, 12]. This is because the substring starting at index 0 and 12 are “wordgood” and “goodword”.To solve this, we will follow these steps −Define a method called ok(), this will take string s, map wordCnt and ... Read More

475 Views
Suppose we have two strings s1 and s2, we have to find the smallest substring in s1 such that all characters of s2 will be used efficiently.So, if the input is like s1 = "I am a student", s2 = "mdn", then the output will be "m a studen"To solve this, we will follow these steps −N := 26str_len := size of main_str, patt_len := size of patternif str_len < patt_len, thenreturn Nonehash_pat := an array of size N and fill with 0hash_str := an array of size N and fill with 0for i in range 0 to patt_len, dohash_pat[ASCII ... Read More

610 Views
Suppose we have a sorted array of positive numbers, this array is sorted in ascending order, er have to find the smallest positive value that cannot be represented as sum of elements of any subset of given set. We have to solve this problem in O(n) time.So, if the input is like A = [1, 4, 8, 12, 13, 17], then the output will be 2.To solve this, we will follow these steps −n := size of Aanswer := 1for i in range 0 to n, doif A[i]

469 Views
Suppose we have a given weighted undirected graph with N different nodes and M edges, some of the nodes are good nodes. We have to find the shortest distance between any pair of two different good nodes. In the given diagram the yellow in the following graph are considered to be good nodes.So, if the input is likethen the output will be 11, as the pairs of good nodes and distance between them are: (1 to 3) the distance is 11, (3 to 5) the distance is 13, (1 to 5) the distance is 24, out of which 11 is ... Read More

136 Views
Suppose we have a number N this represents the initial position of the person on the number line. We also have L which is the probability of the person of going left. We have to find the the probability of reaching all points on the number line after completing N moves from point N. Each move can be either to the left or to the right.So, if the input is like n = 2, l = 0.5, then the output will be [0.25, 0, 0.5, 0, 0.25]To solve this, we will follow these steps −high := 1 - lowDefine an ... Read More