## Sum of the distances from every node to all other nodes is maximum

Given a tree with N nodes and N-1 edges with root at 1 and given an array of N-1 integers. The task is to assign… Read More »

- Java Program to print distinct permutations of a string
- Number of unique pairs in an array
- Sum of all Submatrices of a Given Matrix
- Python program to get all subsets of given size of a set
- Generate all permutations of a string that follow given constraints
- Count pairs of non-overlapping palindromic sub-strings of the given string
- Iterative approach to print all permutations of an Array
- XOR of all the elements in the given range [L, R]
- Number of ways of scoring R runs in B balls with at most W wickets
- Sum of bitwise AND of all submatrices
- Count paths with distance equal to Manhattan distance
- Sum of Bitwise-OR of all Submatrices
- Count of sub-sets of size n with total element sum divisible by 3
- Sum of (maximum element - minimum element) for all the subsets of an array.
- Iterative approach to print all combinations of an Array
- Program to calculate the value of nPr
- Mobile Numeric Keypad Problem | Set 2
- Number of submatrices with OR value 1
- Number of Simple Graph with N Vertices and M Edges
- Number of submatrices with all 1s
- Number of ways to go from one point to another in a grid
- Maximum sum from three arrays such that picking elements consecutively from same is not allowed
- Print k different sorted permutations of a given array
- Find the good permutation of first N natural numbers
- Number of trailing zeroes in base 16 representation of N!
- Number of subsequences with zero sum
- Arrange first N natural numbers such that absolute difference between all adjacent elements > 1
- Deletions of "01" or "10" in binary string to make it free from "01" or "10"
- Sum of the distances from every node to all other nodes is maximum
- Number of ways to pair people

Given a tree with N nodes and N-1 edges with root at 1 and given an array of N-1 integers. The task is to assign… Read More »

Given a number N. The task is to find the number of ways you can draw N chords in a circle with 2*N points such… Read More »

Given three integers N, M, X. The task is to find the probability of distributing M items among X bags such that first bag contains… Read More »

Given two integers N and M, the task is to find the count of possible sequences a1, a2, … of length N such that the… Read More »

Given two integers N and K, the task is to find the count of quadruples of (i, j, k, l) such that 1 ≤ i… Read More »

Given four integers X, Y, M and W. The task is to find the number of ways to choose X men and Y women from… Read More »

Given the mobile numeric keypad. You can only press buttons that are up, left, right or down to the current button or can choose to… Read More »

Given an integer N, the task is to partition the first N natural numbers in two non-empty sets such that the sum of these set… Read More »

Given an array p[] of odd length N where p[i] denotes the probability of getting a head on the ith coin. As the coins are… Read More »

Given an array arr[] of size N, the task is to generate and print all permutations of the given array. Examples: Input: arr[] = {1,… Read More »

Given an array arr[] of size N, the task is to generate and print all possible combinations of R elements in array. Examples: Input: arr[]… Read More »

Given an English word of length at most 20 characters. Calculate the number of ways to arrange the word such that no vowels occur together.… Read More »

Given a tree with N nodes and a number K. Paint every node of the tree in one of the K available colors. Count and… Read More »

Given three integers N, R and P where P is prime, the task is to find whether NCR is divisible by P or not. Examples:… Read More »

Given an N * N matrix arr[][] consisting of non-negative integers, the task is to find the number of ways to reach arr[N – 1][N… Read More »