Consider a game where a player can score 3 or 5 or 10 points in a move. Given a total score n, find number of ways to reach the given score.
Examples:
Input: n = 20
Output: 4
Examples:
Input: n = 20
Output: 4
struct node {
int data;
struct node *left;
struct node *right;
};
need to find out common ancestor of two nodes. [1]
/ \
[2] [3]
/ \ / \
[4] [5] [6] [7]
/
[8]
Here Output should be 1, and 2 for K=2 as both are at 2 distance from leaf nodes.Example: Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3 Output: 3->2->1->6->5->4->8->7->NULL.