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.