id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

frew@mclean.com heap-1 > grandparentHeap
prev  |  next  |  chance

Return the value of the grandparent for the given index, or -1 if no grandparent.


grandparentHeap([0, 2, 4, 5, 6, 7, 10, 20, 8, 11, 9], 3) → -1
grandparentHeap([0, 2, 4, 5, 6, 7, 10, 20, 8, 11, 9], 2) → -1
grandparentHeap([0, 2, 4, 5, 6, 7, 10, 20, 8, 11, 9], 4) → 2

...Save, Compile, Run (ctrl-enter)

public int grandparentHeap(int[] heap, int index) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy