Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Build Linked List from Mock API
00:00
5 left

Build Linked List from Mock API

EasyPython

Problem

Call a mock API, parse the returned JSON array and build a linked list from it.

Asked in the technical screen stage. The grader provides the mock API response as a JSON string.

Contract

Implement build_linked_list(api_response). Parse the JSON array and return the head of a singly linked list containing the values in the same order. Use the provided ListNode structure with val and next fields. Return None for an empty array.

Constraints

  • The API response is valid JSON containing an array of integers.
  • 0 <= length of the array <= 500
  • -10^9 <= each array value <= 10^9
  • The returned list must preserve order and duplicate values.

Function Signature

def build_linked_list(api_response):
Interviewer

Your question is Build Linked List from Mock API. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.