Codepath

Check if Transmission is Complete

Unit 2 Session 1 (Click for link to problem statements)

U-nderstand

Understand what the interviewer is asking for by using test cases and questions about the problem.

  • Q: What is the problem asking for?

    • A: The problem asks to determine if a given string transmission contains every letter of the English alphabet at least once.
  • Q: What are the inputs?

    • A: A string transmission containing only lowercase English letters.
  • Q: What are the outputs?

    • A: A boolean value, True if the transmission contains all letters of the English alphabet, and False otherwise.
  • Q: Are there any constraints on the values in the string?

    • A: The string contains only lowercase English letters.

P-lan

Plan the solution with appropriate visualizations and pseudocode.

General Idea: Use a dictionary to count the frequency of each letter in the transmission and check if all letters of the alphabet are present.

1. Initialize a dictionary `letter_count` to store the frequency of each letter.
2. Iterate through the `transmission` string and update the dictionary with the frequency of each letter.
3. Define a string `alphabet` containing all 26 letters of the English alphabet.
4. Iterate through the `alphabet` string.
   - If any letter from `alphabet` is not found in `letter_count`, return `False`.
5. If all letters are found, return `True`.

I-mplement

def check_if_complete_transmission(transmission):
    # Step 1: Initialize a dictionary to store the frequency of each letter
    letter_count = {}

    # Step 2: Iterate through the transmission and update the dictionary
    for char in transmission:
        if char in letter_count:
            letter_count[char] += 1
        else:
            letter_count[char] = 1

    # Step 3: Check if the dictionary contains all 26 letters
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    for letter in alphabet:
        if letter not in letter_count:
            return False

    return True
Fork me on GitHub