Look and Say Pattern
Easy Accuracy: 76.32% Submissions: 4753 Points: 2

Given an integer n. Return the nth row of the following look-and-say pattern.
1
11
21
1211
111221

Example 1:

Input:
n = 5
Output: 111221
Explanation: The 5th row of the given pattern
will be 111221.

Example 2:

Input:
n = 3
Output: 21
Explanation: The 3rd row of the given pattern
will be 21.

You dont need to read input or print anything. Complete the function lookandsay() which takes integer n as input parameter and returns a string denoting the contents of the nth row of given pattern.

Expected Time Complexity: O(2n)
Expected Auxiliary Space: O(2n-1)

Constraints:
1 ≤ n ≤ 30

We are replacing the old Disqus forum with the new Discussions section given below.