• How to find the first non-repeating character in a stream efficiently?

    Here’s a clean version you can use: Short Question:How do you design a data structure to efficiently track and retrieve the first non-repeating character in a stream? Description:In many data stream problems, characters arrive one by one, and we need to continuously determine the first non-repeating character at any given point. The challenge is to(Read More)

    Here’s a clean version you can use:

    Short Question:
    How do you design a data structure to efficiently track and retrieve the first non-repeating character in a stream?

    Description:
    In many data stream problems, characters arrive one by one, and we need to continuously determine the first non-repeating character at any given point.

    The challenge is to design a data structure that:

    • Supports real-time updates as new characters arrive

    • Efficiently tracks frequencies of characters

    • Quickly returns the first character that has appeared only once so far

    A brute-force approach would re-scan the entire stream after each insertion, which is inefficient. Instead, we need an optimized approach using a combination of data structures to maintain order and frequency.

    Approach:
    Use:

    • A hash map to store frequency of each character

    • A queue to maintain insertion order

    Python Code:

    from collections import deque
    
    class FirstNonRepeating:
        def __init__(self):
            self.freq = {}
            self.queue = deque()
    
        def add(self, char):
            # Update frequency
            self.freq[char] = self.freq.get(char, 0) + 1
            
            # Add to queue
            self.queue.append(char)
            
            # Remove repeating characters from front
            while self.queue and self.freq[self.queue[0]] > 1:
                self.queue.popleft()
    
        def get_first_non_repeating(self):
            return self.queue[0] if self.queue else None
    
    
    # Example usage
    stream = FirstNonRepeating()
    
    for ch in "aabcbd":
        stream.add(ch)
        print(stream.get_first_non_repeating())
    
  • What are the latest trends in data interviews, and what do candidates fear the most today?

    Data interviews seem to be evolving fast. It’s no longer just SQL or case studies, now it’s system thinking, real-world problem solving, and even communication. At the same time, a lot of candidates still feel uncertain going in. From what you’ve seen: What’s actually being tested today? And what do candidates tend to worry about(Read More)

    Data interviews seem to be evolving fast. It’s no longer just SQL or case studies, now it’s system thinking, real-world problem solving, and even communication.

    At the same time, a lot of candidates still feel uncertain going in.

    From what you’ve seen:

    • What’s actually being tested today?
    • And what do candidates tend to worry about the most?

    Would be interesting to hear both interviewer and candidate perspectives

  • Are data interviews testing real skills or just memorization?

    Many candidates spend months preparing for SQL, case studies, and system design, but struggle in real-world roles. Are interviews truly reflecting on-the-job challenges, or just rewarding preparation patterns?

    Many candidates spend months preparing for SQL, case studies, and system design, but struggle in real-world roles. Are interviews truly reflecting on-the-job challenges, or just rewarding preparation patterns?

  • How are data interviews evolving with the rise of AI tools?

    With tools like ChatGPT, Copilot, and automated coding assistants becoming common in the workplace, the traditional data interview process is starting to change. Some companies are shifting away from pure SQL or coding challenges toward problem-solving, system thinking, and real business case discussions. From your experience, how are data interviews evolving, and what skills are(Read More)

    With tools like ChatGPT, Copilot, and automated coding assistants becoming common in the workplace, the traditional data interview process is starting to change. Some companies are shifting away from pure SQL or coding challenges toward problem-solving, system thinking, and real business case discussions. From your experience, how are data interviews evolving, and what skills are becoming more important for candidates today?

     
     
  • Best way to convert API JSON response to Excel in Python?

    I’m working with an API that returns data in JSON format, and I need to convert this response into an Excel file using Python. Some of the fields in the JSON are nested (lists and dictionaries). What is the most efficient way to handle this transformation so the data can be flattened and exported properly(Read More)

    I’m working with an API that returns data in JSON format, and I need to convert this response into an Excel file using Python. Some of the fields in the JSON are nested (lists and dictionaries).

    What is the most efficient way to handle this transformation so the data can be flattened and exported properly to Excel?

    Are there recommended libraries or approaches (for example using pandas) that work best for this type of task?

Loading more threads