
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

107 Views
Suppose we have a list of numbers called nums and another value k, we have to check whether we can find three unique elements in the list whose sum is k.So, if the input is like nums = [11, 4, 6, 10, 5, 1] k = 20, then the output will be True, as we have numbers [4, 6, 10] whose sum is 20.To solve this, we will follow these steps −sort the list numsl := 0, r := size of nums − 1while l < r − 1, dot := k − nums[l] − nums[r]if nums[r − 1] < ... Read More

114 Views
Suppose we have a binary tree; we have to find the sum of values of its deepest leaves. So if the tree is like −Then the output will be 11.To solve this, we will follow these steps −Define a map m, and maxDepthDefine a recursive method solve(), this will take node and level, initially level is 0if node is not present, then returnmaxDepth := max of level and maxDepthincrease m[level] by value of nodesolve(left of node, level + 1)solve(right of node, level + 1)In the main method, setup maxDepth := 0, then solve(root, 0)return m[maxDepth]Let us see the following implementation ... Read More

195 Views
Suppose we have a binary tree we have to find the sum of all right leaves in a given binary tree.So, if the input is likethen the output will be 17, as there are two right leaves in the binary tree, with values 7 and 10 respectively.To solve this, we will follow these steps −Define a function dfs(), this will take node, add, if node is null, then −returnif left of node is null and right of node is null and add is non-zero, then −ret := ret + val of nodedfs(left of node, false)dfs(right of node, true)From the main ... Read More

128 Views
Suppose we have a list of numbers called nums and a value k, we have to check whether there are four unique elements in the list that add up to k.So, if the input is like nums = [11, 4, 6, 10, 5, 1] k = 25, then the output will be True, as we have [4, 6, 10, 5] whose sum is 25.To solve this, we will follow these steps −sort the list numsn := size of numsfor i in range 0 to n − 4, dofor j in range i + 1 to n − 3, dol := ... Read More

323 Views
Suppose we have a partially filled Sudoku grid and we have to solve this. We know that Sudoku is a 9 × 9 number grid, and the whole grid are also divided into 3 × 3 boxes There are some rules to solve the Sudoku.We have to use digits 1 to 9 for solving this problem.One digit cannot be repeated in one row, one column or in one 3 × 3 box.Using backtracking algorithm, we will try to solve Sudoku problem. When some cell is filled with a digit, it checks whether it is valid or not. When it is ... Read More

376 Views
Suppose we have two binary trees. We have to check whether second tree is a subtree of first one or not.So, if the input is likethen the output will be True.To solve this, we will follow these steps −Define a function solve() . This will take root, targetif root is null and target is also null, thenreturn Trueif root is null or target is null, thenreturn Falseif value of root is same as value of target, thenreturn solve(left of root, left of target) and solve(right of root, right of target)otherwise, return solve(left of root, target) or solve(right of root, target)Let ... Read More

197 Views
Suppose we have a list of numbers called nums, we select a subsequence of strictly increasing values, where the differences of each two numbers is the same as the differences of their two indices. So we have to find the maximum sum of such a subsequence.So, if the input is like nums = [6, 7, 9, 9, 8, 5], then the output will be 22, as we select the subsequence [6, 7, 9] whose indices are [0, 1, 3]. The differences between each consecutive numbers is [1, 2] which is same as the differences of their indices.To solve this, we ... Read More

2K+ Views
Suppose we have two strings S and T. We have to check whether S is subsequence of T or not.So, if the input is like S = "abc", T = "adbrcyxd", then the output will be TrueTo solve this, we will follow these steps −if s is same as t, then −return truen := size of s, m := size of tj := 0for initialize i := 0, when i < n, update (increase i by 1), do −if t[j] is same as s[i], then −(increase j by 1)if j is same as size of t, then −return truereturn falseLet ... Read More

292 Views
Suppose we have a list of numbers called nums, we have to check whether there is a sublist such that its sum is strictly greater than the total sum of the list.So, if the input is like nums = [1, −2, 3, 4], then the output will be True, as the sum of the list is 6 and the sum of the sublist [3, 5] is 8 which is strictly larger.To solve this, we will follow these steps −total := sum of elements numss := 0for each i in nums, dos := s + iif s < 0, thenreturn Trues ... Read More

1K+ Views
Suppose we have two numbers as string. We have to multiply them and return the result also in string. So if the numbers are “28” and “25”, then the result will be “700”To solve this, we will follow these steps −Taking two arguments x and y it indicates x divides yif x < −Infinity and y = 1, then return infinitya := |x|, b := |y| and ans := 0while a − b >= 0p := 0while a − (left shifted b (left shifted 1 p times)) >= 0p := p + 1a := a − (left shift b, p ... Read More