PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Disney

Solve matrix add, frequency count, longest consecutive

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in basic numerical and array operations (matrix addition), associative data structures for frequency counting (hash maps), and set-based algorithmic reasoning for the longest consecutive sequence problem.

  • Medium
  • Disney
  • Coding & Algorithms
  • Data Scientist

Solve matrix add, frequency count, longest consecutive

Company: Disney

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are asked to solve the following 3 coding tasks (in any language). Implement each as a function. ## 1) Add two matrices **Input:** Two 2D integer arrays `A` and `B`, each of shape `m x n`. **Task:** Return a new matrix `C` of shape `m x n` where `C[i][j] = A[i][j] + B[i][j]`. **Assumptions:** - `A` and `B` have the same dimensions. **Example:** - `A = [[1,2],[3,4]]`, `B = [[5,6],[7,8]]` → `[[6,8],[10,12]]` --- ## 2) Count occurrences of names **Input:** A list/array of strings `names`. **Task:** Return a dictionary / hash map from name → frequency (count of how many times it appears). **Example:** - `names = ["Amy","Bob","Amy"]` → `{ "Amy": 2, "Bob": 1 }` --- ## 3) Longest consecutive sequence **Input:** An integer array `nums` (can contain duplicates and negative numbers). **Task:** Return the length of the longest sequence of consecutive integers that can be formed from the elements of `nums` (order in the array does not matter). **Complexity requirement:** Aim for **O(n)** time using a hash set (typical “Longest Consecutive Sequence” problem). **Examples:** - `nums = [100,4,200,1,3,2]` → `4` (sequence `1,2,3,4`) - `nums = [0,3,7,2,5,8,4,6,0,1]` → `9` (sequence `0..8`) **Clarifications:** - Duplicates should not inflate the sequence length. - If `nums` is empty, return `0`.

Quick Answer: This question evaluates proficiency in basic numerical and array operations (matrix addition), associative data structures for frequency counting (hash maps), and set-based algorithmic reasoning for the longest consecutive sequence problem.

Related Interview Questions

  • Implement an LRU cache - Disney (medium)
  • Filter ads by a single rule - Disney (medium)
  • Determine if chasing points will meet - Disney (medium)
  • Solve grid shortest path with BFS - Disney (Medium)
  • Implement BFS shortest path in grid - Disney (Medium)
Disney logo
Disney
Sep 13, 2025, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
5
0

You are asked to solve the following 3 coding tasks (in any language). Implement each as a function.

1) Add two matrices

Input: Two 2D integer arrays A and B, each of shape m x n.

Task: Return a new matrix C of shape m x n where C[i][j] = A[i][j] + B[i][j].

Assumptions:

  • A and B have the same dimensions.

Example:

  • A = [[1,2],[3,4]] , B = [[5,6],[7,8]] → [[6,8],[10,12]]

2) Count occurrences of names

Input: A list/array of strings names.

Task: Return a dictionary / hash map from name → frequency (count of how many times it appears).

Example:

  • names = ["Amy","Bob","Amy"] → { "Amy": 2, "Bob": 1 }

3) Longest consecutive sequence

Input: An integer array nums (can contain duplicates and negative numbers).

Task: Return the length of the longest sequence of consecutive integers that can be formed from the elements of nums (order in the array does not matter).

Complexity requirement: Aim for O(n) time using a hash set (typical “Longest Consecutive Sequence” problem).

Examples:

  • nums = [100,4,200,1,3,2] → 4 (sequence 1,2,3,4 )
  • nums = [0,3,7,2,5,8,4,6,0,1] → 9 (sequence 0..8 )

Clarifications:

  • Duplicates should not inflate the sequence length.
  • If nums is empty, return 0 .

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Disney•More Data Scientist•Disney Data Scientist•Disney Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.