
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

779 Views
Suppose, we are given a binary tree and are asked to find the distance between two nodes in the binary tree. We find out the edges between the two nodes like in a graph and return the number of edges or the distance between them. A node of a tree has the structure as below −data : right : left : So, if the input is likeand the nodes between which we have to find the distance between are 2 and 8; then the output will be 4.The edges between the two nodes 2 and 8 are: (2, ... Read More

177 Views
Suppose we have one m x n matrix. and another value k. Here the value of coordinate (a, b) of the matrix is the XOR of all matrix[i, j] where i in range (0 to a) and j in range (0 to b). We have to find the kth largest value (1-indexed) of all the coordinates of matrix.So, if the input is like5216And k = 1, then the output will be 7 because the value of coordinate (0, 1) is 5 XOR 2 = 7, and this is the largest oneTo solve this, we will follow these steps −m := ... Read More

183 Views
Suppose we have two strings s and t with only lowercase letters. In one operation, we can change any character in s or t to any lowercase letter. We have to satisfy one of the following three conditions −Every letter in s is strictly smaller than every letter in t in the alphabet.Every letter in t is strictly smaller than every letter in s in the alphabet.Both s and t consist of only one distinct letter.We have to find the minimum number of operations required to get the result.So, if the input is like s = "sts", t = "uss", ... Read More

225 Views
Suppose we have an array enc. There is an array perm that is a permutation of the first n(odd) positive integers. This list will be encoded into array enc of length n-1, such that enc[i] = perm[i] XOR perm[i+1]. We have to find the original array perm.So, if the input is like enc = [2, 5, 6, 3], then the output will be [7, 5, 0, 6, 5], here [7 XOR 5 XOR 0 XOR 6 XOR 5] = [2, 5, 6, 3]To solve this, we will follow these steps −n := size of encresult := an array of size ... Read More

194 Views
Suppose we have a number n, an array called 'languages', and an array called 'friendships', so there are n languages numbered from 1 through n, languages[i] represents a set of languages the ith user knows, and friendships[i] holds a pair [ui, vi] denotes a friendship between the users ui and vi. We can select one language and teach it to some users so that all friends can communicate with each other. We have to find the minimum number of users required to teach. (One thing we have to keep in mind that friendships are not transitive, so if x is ... Read More

342 Views
Suppose we have an array called quality for each different worker, and have another array called wages and a value K. The i-th worker has a quality[i] and a minimum wage expectation wage[i]. We want to hire K workers to form a paid group. When we are hiring a group of K workers, we must pay them according to the following rules:Each worker in the paid group should be paid in the ratio of their quality by comparing with others in the paid group.Every worker in the paid group must be paid at least their minimum wage expectation.We have to ... Read More

586 Views
Suppose we have a string s. We have to check whether we can split s into three palindromic substring or not.So, if the input is like s = "levelpopracecar", then the output will be True because we can split it like "level", "pop", "racecar", all are palindromes.To solve this, we will follow these steps −n := size of sdp := a matrix of order n x n and fill with falsefor i in range n-1 to 0, decrease by 1, dofor j in range 0 to n - 1, doif i >= j, thendp[i, j] := Trueotherwise when s[i] is ... Read More

282 Views
Suppose we have N piles of stones arranged in a row. Here the i-th pile has stones[i] number of stones. A move consists of merging K consecutive piles into one pile, now the cost of this move is equal to the total number of stones in these K number of piles. We have to find the minimum cost to merge all piles of stones into one pile. If there is no such solution then, return -1.So, if the input is like nums = [3, 2, 4, 1], K = 2, then the output will be 20, because, initially have [3, ... Read More

140 Views
Suppose we want to make a target string of lowercase letters. At first, we have the sequence as n '?' marks (n is the length of target string). We also have a stamp of lowercase letters. On each turn, we can place the stamp over the sequence, and replace every letter in the with the corresponding letter from that stamp. You can make up to 10 * n turns.As an example consider the initial sequence is "?????", and the stamp is "abc", then we may make strings like "abc??", "?abc?", "??abc" in the first turn. If the sequence is possible ... Read More

4K+ Views
Suppose we have two matrices mat1 and mat2. We shall have to add these two matrices and form the third matrix. We shall have to do this by overloading the addition operator.So, if the input is like589679834763then the output will be131113131312To solve this, we will follow these steps −Overload the addition operator, this will take another matrix mat as second argumentdefine one blank 2d array vvDefine one 2D array vv and load current matrix elements into itfor initialize i := 0, when i < size of vv, update (increase i by 1), do:for initialize j := 0, when j < ... Read More