Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Recursion Algorithm Problem
00:00
5 left

Recursion Algorithm Problem

EasyPython

Problem

Tell me about an algorithm question that involved recursion and how you solved it.

For this exercise, demonstrate the approach by implementing recursive_sum(nums), which recursively returns the sum of all integers in nums.

Function: def recursive_sum(nums):

Input: A list of integers. Output: One integer sum.

Examples: nums = [1, 2, 3, 4] returns 10; nums = [] returns 0.

Constraints: 0 <= len(nums) <= 1000; values range from -10^4 to 10^4.

Constraints

  • 0 <= len(nums) <= 1000
  • -10^4 <= nums[i] <= 10^4
  • The function must use recursion

Function Signature

def recursive_sum(nums):
Interviewer

Your question is Recursion Algorithm Problem. 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.