PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Warner Bros Discovery

Implement array rotations and CSV keyword search

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array manipulation and string parsing competencies, focusing on rotating arrays via modular index arithmetic and locating substring occurrences within a simple CSV while mapping each match to row, column, and character position.

  • medium
  • Warner Bros Discovery
  • Coding & Algorithms
  • Software Engineer

Implement array rotations and CSV keyword search

Company: Warner Bros Discovery

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem A — Rotate an array left/right by *k* You are given an integer array `nums` of length `n` and an integer `k`. 1. Implement `rotateLeft(nums, k)` that returns the array after rotating it left by `k` positions. 2. Implement `rotateRight(nums, k)` that returns the array after rotating it right by `k` positions. ### Notes / Constraints - `k` can be larger than `n`; treat `k` as `k % n`. - Handle edge cases like `n = 0` or `n = 1`. - Clarify in your solution whether you modify in-place or return a new array. ### Example - `nums = [1,2,3,4,5]`, `k = 2` - left rotate → `[3,4,5,1,2]` - right rotate → `[4,5,1,2,3]` --- ## Problem B — Find keyword occurrences in a CSV text You are given a CSV document as a single string `csvText`. - Rows are separated by newline characters `\n`. - Columns are separated by commas `,`. - Assume fields do not contain escaped commas or quoted strings (i.e., simple CSV). ### Task Given `csvText` and a keyword `key`, return all occurrences of `key` in the document. For each occurrence, return: - `row`: the 0-based row number - `col`: the 0-based column number - `pos`: the 0-based character index within that cell where the match begins Return results in row-major order. ### Variant Extend the function to accept multiple keywords `keys[]` and return occurrences for any of them (you may also include which keyword matched). ### Example `csvText = "foo,bar\nxxfood,barfoo"`, `key = "foo"` - Row 0, Col 0, Pos 0 ("foo") - Row 1, Col 0, Pos 2 ("xxfood") - Row 1, Col 1, Pos 3 ("barfoo") (Exact output format is up to you; it just needs to include row/col/pos.)

Quick Answer: This question evaluates array manipulation and string parsing competencies, focusing on rotating arrays via modular index arithmetic and locating substring occurrences within a simple CSV while mapping each match to row, column, and character position.

Warner Bros Discovery logo
Warner Bros Discovery
Nov 15, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0

Problem A — Rotate an array left/right by k

You are given an integer array nums of length n and an integer k.

  1. Implement rotateLeft(nums, k) that returns the array after rotating it left by k positions.
  2. Implement rotateRight(nums, k) that returns the array after rotating it right by k positions.

Notes / Constraints

  • k can be larger than n ; treat k as k % n .
  • Handle edge cases like n = 0 or n = 1 .
  • Clarify in your solution whether you modify in-place or return a new array.

Example

  • nums = [1,2,3,4,5] , k = 2
    • left rotate → [3,4,5,1,2]
    • right rotate → [4,5,1,2,3]

Problem B — Find keyword occurrences in a CSV text

You are given a CSV document as a single string csvText.

  • Rows are separated by newline characters \n .
  • Columns are separated by commas , .
  • Assume fields do not contain escaped commas or quoted strings (i.e., simple CSV).

Task

Given csvText and a keyword key, return all occurrences of key in the document.

For each occurrence, return:

  • row : the 0-based row number
  • col : the 0-based column number
  • pos : the 0-based character index within that cell where the match begins

Return results in row-major order.

Variant

Extend the function to accept multiple keywords keys[] and return occurrences for any of them (you may also include which keyword matched).

Example

csvText = "foo,bar\nxxfood,barfoo", key = "foo"

  • Row 0, Col 0, Pos 0 ("foo")
  • Row 1, Col 0, Pos 2 ("xxfood")
  • Row 1, Col 1, Pos 3 ("barfoo")

(Exact output format is up to you; it just needs to include row/col/pos.)

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Warner Bros Discovery•More Software Engineer•Warner Bros Discovery Software Engineer•Warner Bros Discovery Coding & Algorithms•Software Engineer 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.