We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Isnt it kinda weird that the author seem to mean index 0 in their queries but uses "1" instead, e.g., for query 1 3 we actually mean the first list (1). It means that we need to shift the index so that when we assign int x to the value, it should be x = value -1 (and int y = value -1).
Its not wrong, it just felt like adding an unneccesary layer of complexity. Perhaps its part of the exercise, i could also misunderstand the reasoning behind it.
The solution, as i see it is to shift the lists in both images and in the tests, so images show lists 0, 1, 2, 3 ,4 ... instead of 1,2,3,4,,, and so the test doesnt expect the list in place 1 but rather in place 0
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Java Arraylist
You are viewing a single comment's thread. Return to all comments →
Isnt it kinda weird that the author seem to mean index 0 in their queries but uses "1" instead, e.g., for query 1 3 we actually mean the first list (1). It means that we need to shift the index so that when we assign int x to the value, it should be x = value -1 (and int y = value -1).
Its not wrong, it just felt like adding an unneccesary layer of complexity. Perhaps its part of the exercise, i could also misunderstand the reasoning behind it.
The solution, as i see it is to shift the lists in both images and in the tests, so images show lists 0, 1, 2, 3 ,4 ... instead of 1,2,3,4,,, and so the test doesnt expect the list in place 1 but rather in place 0