Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

1s vs 0s Ratio Check

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is 1s vs 0s Ratio Check. Start with the requirements on the right.

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.

Problem

An NVIDIA Jetson device records a binary telemetry sequence, where 0 and 1 represent two event types. Determine whether the sequence contains exactly ten times as many 1s as 0s.

Return True if count(1) == 10 * count(0), and return False otherwise.

Formal Specification

Implement a function that receives bits, a list of integers containing only 0 and 1. Return a Boolean value. The input is nonempty, and the order of elements does not affect the result.

Constraints

  • 1 <= len(bits) <= 100,000
  • Every element is either 0 or 1
  • The input sequence is nonempty

Function Signature

def has_ten_to_one_ratio(bits):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output