VS Code / Cursor Integration & Screen OCR
Technical Coding Co-Pilot
Real-time algorithmic solutions, Big-O trade-offs, and step-by-step talking points for HackerRank, CodeSignal, CoderPad, and live IDE screenings.
Problem Statement
OCR SyncedCaptured via Screen OCR (Alt+S) from CoderPad.
Top K Frequent Elements (LeetCode 347)
Given an integer array nums and an integer k, return the k most frequent elements in any order.
Example 1: nums = [1,1,1,2,2,3], k = 2 → [1,2]
Complexity & Big-O Analysis
Time Complexity:O(N log K)
Space Complexity:O(N + K)
Optimal Alternative:Bucket Sort O(N)
from collections import Counter
import heapq
def topKFrequent(nums: list[int], k: int) -> list[int]:
# 1. Frequency counting O(N)
count = Counter(nums)
# 2. Min-heap of size K: O(N log K)
return heapq.nlargest(k, count.keys(), key=count.get)Verbal Walkthrough (Say this to the interviewer while coding):
“First, I'll count frequencies in linear O(N) time with a hash map. Instead of sorting all elements which would cost O(N log N), I'll maintain a min-heap of size K. That bounds our heap push/pop operations to O(log K), resulting in O(N log K) overall time and O(N) space.”
Hotkeys: Ctrl+Alt+L in VS CodeLaunch Live In-Call HUD