| about | help | code help+videos | done | prefs |
generate2D
Given two integers (say n and p), return a homogenous ArrayList of ArrayList of Integer objects such that it holds n ArrayLists, each containing p zeroes. NOTE: You cannot use the following legacy syntax: ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>(); You will need to use the syntax that the Java version used by codingBat accepts: ArrayList<ArrayList<Integer>> result = new ArrayList<>(); This still makes sure you can only insert objects of type ArrayList<Integer> into result. generate2D(2, 3) → [[0, 0, 0], [0, 0, 0]] generate2D(3, 2) → [[0, 0], [0, 0], [0, 0]] generate2D(1, 5) → [[0, 0, 0, 0, 0]] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 5 Post-solution available
Copyright Nick Parlante 2017 - privacy