# Category Archives: GeeksQuiz

## Difference between sum of even and odd valued nodes in a Binary Tree

Given a binary tree, the task is to find the absolute difference between the even valued and the odd valued nodes in a binary tree.… Read More »

## Count of all subsequences having adjacent elements with different parity

Given an array arr[] of size N, the task is to find the number of non-empty subsequences from the given array such that no two… Read More »

## Find the node at the centre of an N-ary tree

Prerequisites: Diameter of a N-ary tree Path between two nodes in a graph Given a N-ary tree with N nodes numbered from 0 to N-1… Read More »

## Count of submatrix with sum X in a given Matrix

Given a matrix of size N x M and an integer X, the task is to find the number of sub-squares in the matrix with… Read More »

## Count of N-digit numbers with absolute difference of adjacent digits not exceeding K

Given two integers N and K, the task is to find the count of N-digit numbers such that the absolute difference of adjacent digits in… Read More »

## Calculate weight of parenthesis based on the given conditions

Given a valid parenthesis string S, the task is to find the weight of parenthesis based on the following conditions: Weight of “( )” is… Read More »

## Check if two nodes are on same path in a tree | Set 2

Given two nodes of a binary tree v1 and v2, the task is to check if two nodes are on the same path in a… Read More »

## Minimum count of numbers required with unit digit X that sums up to N

Given two integers N and X, the task is to find the minimum count of integers with sum N and having unit digit X. If… Read More »

## Print the longest path from root to leaf in a Binary tree

Given a binary tree, the task is to print the longest path from the root node to the leaf node. If there are multiple answers… Read More »

## Largest number M less than N such that XOR of M and N is even

Given a positive integer N, the task is to find the largest integer M such that 0 <= M < N and XOR(M, N) is… Read More »

## Count of 0s to be flipped to make any two adjacent 1s at least K 0s apart

Given a binary string s and a number K, the task is to find the maximum number of 0s that can be replaced by 1s… Read More »

## Shortest path in a complement graph

Given an undirected non-weighted graph G. For a given node start return the shortest path that is the number of edges from start to all… Read More »

## Maximum size subset with given sum using Backtracking

Given an array arr[] consisting of N integers and an integer K, the task is to find the length of longest subsequence with sum equal… Read More »

## Maximize Profit by trading stocks based on given rate per day

Given an array arr[] of N positive integers which denotes the cost of selling and buying a stock on each of the N days. The… Read More »

## First element of every K sets having consecutive elements with exactly K prime factors less than N

Given two integers N and K, the task is to find the first element for every set of K consecutive elements which have exactly K… Read More »