
‘986’ is a strobogrammatic number because on rotating ‘986’ by 180 degrees, ‘986’ will be obtained.

If N = 2, all the strobogrammatic numbers of length = 2 are “11”, “88”, “69”, “96”.
The first line contains an integer ‘T’, denoting the number of test cases.
The first line of each test case contains a single integer denoting ‘N’.
For each test case, print space-separated strings denoting strobogrammatic numbers of the given length.
Print the output of each test case in a separate line.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 7
Where ‘T’ is the number of test cases, and ‘N’ is the given length.
Time Limit: 1 sec
Approach: Out of all the 10 digits, 0,1,6,8,9 will give a valid digit when rotated upside down(top part turned to bottom).
After rotating upside down digits will be-
0 -> 0
1 -> 1
6 -> 9
8 -> 8
9 -> 6
So We have to form numbers using only 0,1,6,8,9.
The basic idea is that we will reduce the problem into small problems. We will recursively solve the problem for length = length - 2. And then add digits out of (0,1,6,8,9) at the starting and the corresponding digits (0,1,9,8,6) at the end.
Recursion will be stopped when len = 0 and len - 1.
If len = 0, we will return an empty string and in case len = 1, we will return three strings “1”, “0”, “8” as these are the strobogrammatic numbers with pen = 1.
Let us understand this with an example for N = 4.
Algorithm:
Maximum Island Size in a Binary Tree
Equal Subtree Sums
Sorted Doubly Linked List to Balanced BST
Longest Substring with K-Repeating Characters
Expression Add Operators