Q1. Implement pow(x, n)
Problem:
Implement a function to compute x raised to the power n without using built-in functions.
Examples:
Input: x = 2, n = 5 → Output: 32
Input: x = 3.4, n = 3 → Output: 39.04
Typical approach:
Use fast exponentiation (binary exponentiation). Repeatedly square the base and halve the exponent. Handle negative powers by converting to reciprocal.
Q2. Find Compound Words
Problem:
Given a large list of words, identify all words that can be formed by combining two or more other words from the list.
Example:
Input: [rockstar, rock, star, rocks, tar, superhighway, super, highway, high, way]
Valid decompositions:
[rock, star]
[super, highway]
[super, high, way]
Typical approach:
Use dynamic programming similar to the Word Break problem. For each word, check if it can be segmented into smaller words from the dictionary.