Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is a number that is the square of an integer. Your goal is to determine the minimum number of perfect squares that sum up to the given integer n.
You are given a tree with ’n’ nodes labeled from 0 to n-1, represented by ’n-1’ edges. Your task is to find all roots that minimize the height of the tree. The height of a tree is defined as the number of edges in the longest downward path from the root to any leaf.
You are given a set of coins with different denominations and a target amount. Your task is to determine the fewest number of coins required to make the target amount. If it’s not possible, return -1.
You are given two jugs with capacities x and y liters, and an infinite supply of water. You need to determine whether you can measure exactly target liters of water using the following operations: fill, empty, and pour water between the jugs.