Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Find the Middle Element
00:00
5 left

Find the Middle Element

EasyPython

Problem

Find the mid element using Python.

Implement find_mid(nums), where nums is a non-empty list of integers, and return its middle value. For an even-length list, return the second of the two middle elements. The expected solution should use linear time and constant extra space.

Constraints

  • 1 <= len(nums) <= 100000
  • -10^9 <= nums[i] <= 10^9
  • nums is non-empty
  • For even lengths, return the second middle element

Function Signature

def find_mid(nums):
Interviewer

Your question is Find the Middle Element. 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.