Numerical Coding And Algorithmic Data Processing
Asked of: Data Scientist
Last updated
What's being tested
These problems test algorithmic data-processing patterns a Data Scientist must use in production analytics: building n-gram frequency maps, one-pass streaming scans, efficient frequency counting, and string/sequence normalization. Interviewers probe correctness, algorithmic complexity (time/space), and pragmatic choices for edge cases and large inputs.
Patterns & templates
- Sliding window / two-pointer scans for contiguous segments — single
O(n)pass, maintain counts/lengths withdequeor indices; watch inclusive/exclusive bounds. - Hash-map frequency: use
collections.Counterordefaultdict(int)to build context→counts for n-grams and anagram multiset checks,O(n+m)time. - Stable deduplication: keep a
setof seen keys and append unseen items to output list for order-preserving removal,O(n)time,O(n)extra memory. - Unicode normalization: apply
unicodedata.normalize('NFKC', s)and.casefold()before comparing or counting characters to avoid locale surprises. - Large-index Fibonacci: use fast doubling or matrix exponentiation (
O(log n)), apply modular arithmetic early for bounded results to avoid big-integer blowup. - N-gram predictor template: nested dict
context -> Counter(next_word), store counts and optionally compute MLE probabilities oradd-ksmoothing for unseen-next handling.
Common pitfalls
Pitfall: Sorting strings to test anagrams is simpler but
O(m log m)per string; counting characters is linear and scales better.
Pitfall: Off-by-one errors when converting inclusive time gaps into window boundaries cause wrong streak lengths in single-pass scans.
Pitfall: Forgetting Unicode normalization or
.casefold()will make identical-looking tokens compare unequal in real text data.
Practice these
The practice cards below cover the canonical variants — solve all of them and time yourself.
Practice questions
- Build a Next-Word PredictorGoogle · Data Scientist · Online Assessment · easy
- Implement Fibonacci with efficiency constraintsGoogle · Data Scientist · Onsite · medium
- Match payments to invoices by memo or amountGoogle · Data Scientist · Technical Screen · medium
- Implement percentage RMSE and bootstrap its CIGoogle · Data Scientist · Technical Screen · medium
- Implement longest subarray summing to kGoogle · Data Scientist · Onsite · medium
- Implement anagram check and stable deduplicationGoogle · Data Scientist · Technical Screen · medium
- Implement piecewise linear interpolation for time-to-emptyGoogle · Data Scientist · Technical Screen · medium
- Determine If Two Strings Are Anagrams EfficientlyGoogle · Data Scientist · Onsite · medium
- Normalize Columns in Binomial Matrix EfficientlyGoogle · Data Scientist · Technical Screen · medium
- Remove Duplicates While Preserving Order in ListGoogle · Data Scientist · Onsite · medium
- Count super-streak segments in an event streamGoogle · Data Scientist · Technical Screen · easy
Related concepts
- Arrays, Strings, Hash Maps, And Frequency CountingCoding & Algorithms
- Algorithms, Data Structures, And Complexity AnalysisCoding & Algorithms
- Core Data Structures, Algorithms, And ComplexityCoding & Algorithms
- Robust Coding And Numeric Edge CasesCoding & Algorithms
- Coding Fundamentals and Complexity for DS
- Arrays, Strings, and HashingCoding & Algorithms