You are given an integer array nums of length n and an integer k.
rotateLeft(nums, k)
that returns the array after rotating it left by
k
positions.
rotateRight(nums, k)
that returns the array after rotating it right by
k
positions.
k
can be larger than
n
; treat
k
as
k % n
.
n = 0
or
n = 1
.
nums = [1,2,3,4,5]
,
k = 2
[3,4,5,1,2]
[4,5,1,2,3]
You are given a CSV document as a single string csvText.
\n
.
,
.
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.
Extend the function to accept multiple keywords keys[] and return occurrences for any of them (you may also include which keyword matched).
csvText = "foo,bar\nxxfood,barfoo", key = "foo"
(Exact output format is up to you; it just needs to include row/col/pos.)