Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Implement Look-and-Say
00:00
5 left

Implement Look-and-Say

MediumPython

Problem

See-and-say (look-and-say) problem.

Asked in the onsite round 1 stage. Implement a function that returns the nth term of the look-and-say sequence, starting with "1". Each next term describes consecutive digit runs in the previous term.

Contract

n is an integer. Return the nth term as a string.

Constraints

  • 1 <= n <= 30
  • The sequence starts with the term "1"
  • Return the result as a string containing only decimal digits

Function Signature

def count_and_say(n):
Interviewer

Your question is Implement Look-and-Say. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.