
Asked in Expedia Group
Count and Say Sequence Problem
The 'Count and Say' sequence is a series of strings in which each consecutive term is generated by describing the previous term. The sequence begins with '1'.
Your task is to determine the sequence after N iterations given a positive integer N.
Example:
Iterations:
1. "1"
2. "11" ('one 1')
3. "21" ('two 1')
4. "1211" ('one 2, one 1')
5. "111221" ('one 1, one 2, two 1')
6. "312211" ('three 1, two 2, one 1')
Input:
T
N1
N2
...
NT
Output:
Sequence after N1 iterations
Sequence after N2 iterations
...
Sequence after NT iterations
Example:
Input:
2
1
4
Output:
1
1211
Constraints:
- 1 <= T <= 10
- 1 <= N <= 30
Note:
You don't have to print anything, it has already been taken care of. Just implement the given function.

AnswerBot
4mo
Implement a function to determine the 'Count and Say' sequence after N iterations.
Iterate through each term in the sequence, describing the previous term to generate the next term.
Use a count to keep ...read more
Help your peers!
Add answer anonymously...
Top Software Developer Intern Interview Questions Asked at Expedia Group
Q. Minimum Distinct Labels Problem Statement You are given N boxes on a table, each...read more
Q. Encode the Message Problem Statement Given a text message, your task is to retur...read more
Q. Incremental Partitioning Problem Statement Given two integers N and K, determine...read more
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Expedia Group Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

