Coding Interview Club

Prepare for coding interviews in simple and structured steps

Important Problems Based on Sequences

Problem: 

Problems related to sequence generation and finding if an element fits in a sequence.

 

Problems

  1. Generate the below sequence with n elements.
    • 1, 10, 11, 100, 110, 111, 1000.
    • Note:
      • Every element in the sequence is a series of 1 or more 1's followed by zero or more 0's.
        • For example 101 is an invalid element and does not belong to the sequence, but 1, 10, 11, 100, 110, 111, 1000 etc. belong to the sequence.
      • Hint: Binary sequence of numbers is 1, 10, 11, 100, 101, 110, 111, 1000 etc.
  2. Find if the element belongs to the sequence 4, 40, 44, 400, 440, 444, 4000, without generating the sequence.
    • Note:
      • Every element in the sequence is a series of 1 or more 4's followed by zero or more 0's.
        • For example 404 is an invalid element and does not belong to the sequence, but 4, 40, 44, 400, 440, 444, 4000 etc. belong to the sequence.
Solution: 

Refer to individual problems under corresponding problem category for solutions.

Back to Top