FastPrepOdd Numbers Up and Back
Problems/Odd Numbers Up and Back

Odd Numbers Up and Back

Nutanix logoNutanix● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This comes from a Nutanix intern candidate's report of a first-round phone interview. The report marks the result as a fail. It lists one coding task for the round, along with a talk about a systems project and an introduction. According to the report, global variables, helper functions and loops were all off limits, which leaves a function that calls itself. The report shows one short example for this function, odd(start, end). Its output mirrors itself around the largest odd value in the range.

The report gives no limits and does not cover even end points or a range with no odd value. Here we chose the following. Even values at either end are not listed. A range with no odd value gives an empty list. The function returns a list instead of printing. 0 <= start <= end <= 2000. The rule against loops is not tested here, and the editorial shows the recursive form. The examples are ours.

Our version is about 80% the same as the reported question.

You are given two whole numbers start and end with start <= end.

List the odd numbers from start up to end, and then come back down to start. More exactly, let o_1 < o_2 < ... < o_k be the odd numbers between start and end (both included). Return o_1, o_2, ..., o_k followed by o_(k-1), ..., o_2, o_1 (the number at position k - 1, not o_k minus 1). The largest odd number o_k appears only once.

If start or end is even, it is not listed. If there is no odd number in the range, return an empty list.

Interview note: the interview version allowed no global variables, no helper functions and no loops, so it had to be one recursive function. The judge only checks the returned list, so any method is accepted here. The editorial shows the recursive version.

Function

oddUpAndBack(start: int, end: int) → int[]

Examples

Example 1

start = 3end = 9return = [3,5,7,9,7,5,3]

The odd numbers from 3 to 9 are 3, 5, 7, 9. After reaching 9 the list goes back down through 7, 5, 3. The top value 9 is listed once, so the answer has 7 numbers.

Example 2

start = 4end = 10return = [5,7,9,7,5]

4 is even, so the list starts at 5. 10 is also even, so the top odd value is 9. Up gives 5, 7, 9 and down gives 7, 5.

Example 3

start = 6end = 6return = []

The only number in the range is 6, which is even. There is no odd number, so the answer is an empty list.

Constraints

  • 0 <= start <= end <= 2000

More Nutanix Phone Screen questions

  • Swap Adjacent Linked List NodesPHONE SCREEN · Seen Mar 2025
  • Top K Most Frequent ValuesPHONE SCREEN · Seen Mar 2025
  • Unique Triplets Summing to ZeroPHONE SCREEN · Seen Sep 2024
  • Find the Duplicate in a Read-Only ArrayPHONE SCREEN · Seen Apr 2021
  • Kth Largest Element in an ArrayPHONE SCREEN · Seen Feb 2020
  • Kth Smallest Element in a BSTPHONE SCREEN · Seen Feb 2020
  • Outline of a Binary TreePHONE SCREEN · Seen Jan 2020
  • Print All File and Folder PathsPHONE SCREEN · Seen Dec 2019
  • Inorder Predecessor in a BSTPHONE SCREEN · Seen Jan 2019
  • K Largest and K Smallest ValuesPHONE SCREEN · Seen Jan 2019

Similar questions at other companies

  • Checked Recursive SumHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
  • Factorial Without MultiplicationWayve · PHONE SCREEN
  • Power with Integer ExponentsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Raise a Number to an Integer PowerAdobe · PHONE SCREENAdobe interview questions
  • Pow(x, n)Bloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Preorder of a Special Binary TreeNielsen · OA
  • Multiply Without the Multiplication OperatorMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Fibonacci with Input ValidationMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • FactorialAMD · ONSITE INTERVIEWAMD interview questions
  • Path Between Two Nodes of a Fibonacci TreeDatabricks · ONSITE INTERVIEWDatabricks interview questions

Interview reports that mention this question

  • Nutanix SWE Intern Phone Screens: 20 Experiences (Part 3 of 3)

Nutanix interview experiences

  • Nutanix SWE Intern OA Questions: 16 Experiences (Part 2 of 3)
  • Nutanix U.S. SWE Intern Interviews: 54 Experiences (Part 1 of 3)
  • Nutanix SWE OA and Interviews, Level Not Reported: 9 Experiences
  • Nutanix Intern Debugging Round and Interviews: 25 Experiences
All Nutanix interview questionsSee Nutanix hiring insights
Saved
class Solution {
    public int[] oddUpAndBack(int start, int end) {
        // Write your code here.
    }
}
Checking account…