
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

643 Views
Suppose we have two binary trees original and cloned and given a reference to a node target in the original tree. The cloned tree is actually a copy of the original tree. We have to find a reference to the same node in the cloned tree.So if the tree is like below and the target is 3, then the output will be 3.To solve this, we will follow these steps −Define a method called solve(), this will take the node1m node2 and targetif node1 is null, then return nullif node1 is target and value of node 1 is the value ... Read More

455 Views
Suppose we have a company has n employees with a unique ID for each employee. These IDs are ranging from 0 to n - 1. The head of the company has is the one with headID. Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also it's guaranteed that the subordination relationships have a tree-like structure. Here the head of the company wants to inform all the employees of the company of an urgent piece of news. He can inform his direct subordinates and they ... Read More

438 Views
Suppose we have a room with n bulbs, these are numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off. At moment k (for k in range 0 to n - 1), we turn on the light[k] bulb. A bulb changes color to blue only if it is on and all the previous bulbs (to the left) are turned on too. We have to find the number of moments in which all turned on bulbs is blue. So this is an example −The output will be 3 as the moments ... Read More

915 Views
Suppose we have a binary tree root, a ZigZag path for a binary tree is defined as follow −Choose any node in the binary tree and a direction (either right or left).If the current direction is right then moving towards the right child of the current node otherwise move towards the left child.Then change the direction from right to left or vice versa.Repeat the second and third steps until we can't move in the tree.Here the Zigzag length is defined as the number of nodes visited - 1. (A single node has a length of 0). We have to find ... Read More

366 Views
Suppose we have the string s, we have to find the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times. So if the string is like “helloworld”, then the output will be 8.To solve this, we will follow these steps −ret := 0, define two maps m and cnt, set m[“00000”] := -1store vowels into vowels arrayfor i in range 0 to size of sx := s[i], and ok := falseincrease cnt[x] by 1, set temp := empty stringfor k in ... Read More

3K+ Views
Suppose we have a binary tree root and a linked list with a head as the first node. We have to return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise False. So if the tree is like −And the linked list is [1, 4, 2, 6], then the output will be true.To solve this, we will follow these steps −Define a map dpDefine a method called solve(), this will take head, root, and flagif the head is null, then return true, or if the ... Read More

409 Views
Suppose we have an integer num, we have to find the closest two integers in absolute difference whose product equals num + 1 or num + 2. We have to find the two integers in any order. So if the input is 8, then the output will be [3, 3], for num + 1, it will be 9, the closest divisors are 3 and 3, for num + 2 = 10, the closest divisors are 2 and 5, hence 3 and 3 are chosen.To solve this, we will follow these steps −Define a method called getDiv(), this will take x as inputdiff := infinity, create an array called ret of size 2for i := 1, if i^2

389 Views
Suppose we have n binary tree nodes numbered from 0 to n - 1 where node I has two children leftChild[i] and rightChild[i], we have to say true if and only if all the given nodes form exactly one valid binary tree. When node i has no left child then leftChild[i] will equal -1, similarly for the right child. We have to keep in mind that the nodes have no values and that we only use the node numbers in this problem. So if the input is like −Then the output will be true.To solve this, we will follow these ... Read More

688 Views
Suppose we have given a string s consisting only of characters a, b and c. We have to return the number of substrings containing at least one occurrence of all these characters a, b and c. So for example, if the string is “abcabc”, then the output will be 10, as the substring containing at least one occurrence of the characters a, b and c, these are “abc”, “abca”, “abcab”, “abcabc”, “bca”, “bcab”, “cab”, “cabc” and “abc” (again for the last part).To solve this, we will follow these steps −ret := 0, make a map called m, set j := ... Read More

333 Views
Suppose there is a sale in a supermarket, there will be a discount every n customer. Consider there are some products in the supermarket where the id of the i-th product is products[i] and the price per unit of this product is prices[i]. Here the system will count the number of customers and when the n-th customer arrives he/she will have a discount on the bill. Then the system will start counting customers again. The customer orders a certain amount of each product where product[i] is the id of the i-th product the customer ordered and amount[i] is the number ... Read More