Google | Phone Screen | Return the node by index
Anonymous User
555

Return the node by index,

Given a linked list that contains for each node at position k an additional reference to the node at position k*2

e[0] -> e[1] -> e[2] -> e[3] -> e[4] -> e[5] -> e[6] -> e[7] -> e[8]

Additional reference: e[2] -> e[4] -> e[8]

class e {
	val: int
	next: null,
	add_ref: null, -> current index * 2
}
Example:
	Input: 15
	Output: e[15]
Comments (4)