Skip to main content

Posts

Showing posts from April, 2021

Variable Sized Arrays in C++ - Hacker Rank Solution

  Problem Consider an  -element array,  , where each index   in the array contains a reference to an array of   integers (where the value of   varies from array to array). See the  Explanation  section below for a diagram. Given  , you must answer   queries. Each query is in the format  i j , where   denotes an index in array   and   denotes an index in the array located at  . For each query, find and print the value of element   in the array at location   on a new line. Click  here  to know more about how to create variable sized arrays in C++. Input Format The first line contains two space-separated integers denoting the respective values of n (the number of variable-length arrays) and q (the number of queries). Each line i of the n subsequent lines contains a space-separated sequence in the format k a[i]0 a[i]1 … a[i]k-1 describing the k-element ...