Chief Hopper Discussions | | HackerRank

Chief Hopper

  • + 0 comments

    Java O(n)

     public static int chiefHopper(List<Integer> arr) {
            int energy = 0;
    
            for (int i = arr.size() - 1; i >= 0; i--) {
                energy = (energy + arr.get(i) + 1) / 2;
            }
    
            return energy;
        }