It is as per 'Daily Coding Problem'
The "look and say" sequence is defined as follows: beginning with the term 1, each subsequent term visually describes the digits appearing in the previous term. The first few terms are as follows:
1
11
21
1211
111221
As an example, the fourth term is 1211, since the third term consists of one 2 and one 1.
Given an integer N, print the Nth term of this sequence.
Note : I have used String below while updating, one can use StringBuilder or StringBuffer instead to avoid creation of multiple intermediate String
The "look and say" sequence is defined as follows: beginning with the term 1, each subsequent term visually describes the digits appearing in the previous term. The first few terms are as follows:
1
11
21
1211
111221
As an example, the fourth term is 1211, since the third term consists of one 2 and one 1.
Given an integer N, print the Nth term of this sequence.
Note : I have used String below while updating, one can use StringBuilder or StringBuffer instead to avoid creation of multiple intermediate String
public class Solution {