https://leetcode.com/problems/reverse-linked-list-ii/

  • Naively, this requires two passes

    • Once to collect data, if the counter passes left then we can begin to store the value of each node in an-array like structure (plain array or std::vector both work)
    • Once more to populate each node with corresponding data in the array when left is passed
  • Structure considerations

    • vector may be easier due to push_back() method and end()[-n] which allows us to obtain the last index
    • array size can be initialised with right - left, counter - left instead of push_back, and right - counter to obtain the index when populating