FastPrepMaximum Invitations on an N-ary Tree
Problems/Maximum Invitations on an N-ary Tree

Maximum Invitations on an N-ary Tree

Rippling logoRippling● MediumINTERNFULLTIMEPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report omits numeric bounds. The unweighted invitation objective and adjacency restriction match the source at about 95%.

You are given a tree in which each node may have any number of children. Its nodes are 0 through n - 1, and node 0 is the root. The array parent has parent[0] = -1; every other entry names that node's parent.

Choose as many nodes as possible to receive invitations. Two nodes connected by a tree edge cannot both receive an invitation. Return the maximum number of invited nodes. Every node contributes one invitation; there are no node weights.

Function

maximumInvitations(parent: int[]) → int

Examples

Example 1

parent = [-1,0,0,1,1]return = 3

Inviting nodes 2, 3, and 4 is valid. No selection can contain more than three nodes.

Example 2

parent = [-1,0,0,0]return = 3

Invite all three leaves and leave the root uninvited.

Constraints

  • 1 <= parent.length <= 20000.
  • The array describes one valid tree rooted at 0.
  • A parent index need not be smaller than its child index.

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • House Robber IIIOkta · PHONE SCREENOkta interview questions
  • House Robber IIIGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • House Robber IIIVisa · PHONE SCREENVisa interview questions
  • Normalize Loan Merchants to Root BusinessesAffirm · PHONE SCREENAffirm interview questions
  • Minimum Root-to-Leaf Cut CostGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Predicate Expression Tree EvaluatorMongoDB · PHONE SCREENMongoDB interview questions
  • Maximum Nonadjacent Sum in a General TreeZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions
  • Minimum-Cost Root-to-Leaf Path in an N-ary TreeBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Every Full Binary Tree With n NodesAdobe · PHONE SCREENAdobe interview questions
  • Tree Path GCDNewton School · PHONE SCREEN

Interview reports that mention this question

  • Rippling Intern Interview History: 17 Experiences (Part 5 of 5)
  • Rippling New Grad SDE Interviews: 11 Experiences

Rippling interview experiences

  • Rippling Senior SWE Full Loop Questions: 1 Experience
  • Rippling Experienced SWE Phone Screens: 2 Experiences
  • Rippling Design Rounds and Onsites: 17 Experiences (Part 3 of 3)
  • Rippling Phone Coding Screens: 14 Experiences (Part 2 of 3)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int maximumInvitations(int[] parent) {
        // write your code here
    }
}
Checking account…