← 返回博客列表
Snowflake

Snowflake SDE OA Real Questions

2025-10-01

Snowflake OA emphasizes data processing and algorithm optimization. This article shares the latest OA questions. oavoservice helps you prepare efficiently.

📋 Question 1: Data Stream Median

Implement a data structure that supports:

  1. Adding a number
  2. Finding the median
import heapq

class MedianFinder:
    def __init__(self):
        self.small = []  # Max heap (stores smaller half)
        self.large = []  # Min heap (stores larger half)
    
    def addNum(self, num):
        heapq.heappush(self.small, -num)
        heapq.heappush(self.large, -heapq.heappop(self.small))
        
        if len(self.large) > len(self.small):
            heapq.heappush(self.small, -heapq.heappop(self.large))
    
    def findMedian(self):
        if len(self.small) > len(self.large):
            return -self.small[0]
        return (-self.small[0] + self.large[0]) / 2.0

📋 Question 2: Data Compression

Implement a simple data compression algorithm.

def compress(s):
    if not s:
        return ""
    
    result = []
    count = 1
    
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            count += 1
        else:
            result.append(s[i-1] + str(count))
            count = 1
    
    result.append(s[-1] + str(count))
    compressed = ''.join(result)
    
    return compressed if len(compressed) < len(s) else s

💼 How oavoservice Helps

OA Real Questions - Latest questions and solutions Time Management - Efficient answering strategy Code Quality - Clear implementation Test Cases - Comprehensive boundary testing

Contact oavoservice for professional OA assistance services!


Tags: #Snowflake #OA #DataStream #DataCompression #OAHelp #InterviewPrep #1point3acres


Need real interview questions? Contact WeChat Coding0201 immediately to get real questions.