First Problem Solve
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```javascript []
var flat = function (arr, n) {
    if (n === 0) return arr; // Agar depth 0 hai, toh original array return karein

    return arr.reduce((acc, val) => {
        if (Array.isArray(val) && n > 0) {
            acc.push(...flat(val, n - 1)); // Recursive call with reduced depth
        } else {
            acc.push(val); // Non-array values ko directly add karein
        }
        return acc;
    }, []);
};

// Test
console.log(flat([1, [2, 3], [4, [5, 6]]], 1)); // [1, 2, 3, 4, [5, 6]]
console.log(flat([1, [2, 3], [4, [5, 6]]], 2)); // [1, 2, 3, 4, 5, 6]

```
['JavaScript']