Java 1ms DFS recursive solution and 2ms BFS iterative solution
DFS recursive:\n\n    public List> levelOrder(TreeNode root) {\n    \t\tList> res = new ArrayList<>();\n    \t\tif (root == null)\n    \t\t\treturn res;\n    \t
DFS recursive:\n\n    public List<List<Integer>> levelOrder(TreeNode root) {\n    \t\tList<List<Integer>> res = new ArrayList<>();\n    \t\tif (root == null)\n    \t\t\treturn res;\n    \t\tlevelOrderHelper(res, root, 0);\n    \t\treturn res;\n    \t}\n    \t\n    \tpublic void levelOrderHelper(List<List<Integer>> res, TreeNode root, int level) {\n    \t\tif (root == null)\n    \t\t\treturn;\n    \t\tList<Integer> curr;\n    \t\tif (level >= res.size()) {\n    \t\t\tcurr = new ArrayList<>();\n    \t\t\tcurr.add(root.val);\n    \t\t\tres.add(curr);\n    \t\t} else {\n    \t\t\tcurr = res.get(level); \n    \t\t\tcurr.add(root.val); \n    \t\t\t//res.add(curr); // No need to add the curr into the res, because the res.get(index) method does not remove the index element\n    \t\t}\n    \t\tlevelOrderHelper(res, root.left, level + 1);\n    \t\tlevelOrderHelper(res, root.right, level + 1);\n    \t}\n\nBFS iterative:\n\n    public List<List<Integer>> levelOrder(TreeNode root) {\n    \t\tList<List<Integer>> res = new ArrayList<>();\n    \t\tif (root == null)\n    \t\t\treturn res;\n    \t\tQueue<TreeNode> q = new LinkedList<>();\n    \t\tq.add(root);\n    \t\twhile(!q.isEmpty()) {\n    \t\t\tint levelSize = q.size();\n    \t\t\tList<Integer> currLevel = new ArrayList<>();\n    \t\t\tfor(int i = 0; i < levelSize; i++) {\n    \t\t\t\tTreeNode currNode = q.poll();\n    \t\t\t\tcurrLevel.add(currNode.val);\n    \t\t\t\tif (currNode.left != null)\n    \t\t\t\t\tq.add(currNode.left);\n    \t\t\t\tif (currNode.right != null)\n    \t\t\t\t\tq.add(currNode.right);\n    \t\t\t}\n    \t\t\tres.add(currLevel);\n    \t\t}\n    \t\treturn res;\n    \t}
['Depth-First Search', 'Breadth-First Search', 'Recursion', 'Iterator', 'Java']