linked list values

Write a function, linkedListValues, that takes in the head of a linked list as an argument. The function should return an array containing all values of the nodes in the linked list.

test_00:

test_01:

test_02:

test_03:

solutions

iterative

  • n = number of nodes
  • Time: O(n)
  • Space: O(n)

recursive

  • n = number of nodes
  • Time: O(n)
  • Space: O(n)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store