We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 42fe117 commit a9b790cCopy full SHA for a9b790c
src/main/java/com/fishercoder/solutions/_339.java
@@ -4,6 +4,22 @@
4
5
import java.util.List;
6
7
+/**
8
+ * 339. Nested List Weight Sum
9
+ *
10
+ * Given a nested list of integers, return the sum of all integers in the list weighted by their depth.
11
+ * Each element is either an integer, or a list -- whose elements may also be integers or other lists.
12
13
+ * Example 1:
14
+ * Input: [[1,1],2,[1,1]]
15
+ * Output: 10
16
+ * Explanation: Four 1's at depth 2, one 2 at depth 1.
17
18
+ * Example 2:
19
+ * Input: [1,[4,[6]]]
20
+ * Output: 27
21
+ * Explanation: One 1 at depth 1, one 4 at depth 2, and one 6 at depth 3; 1 + 4*2 + 6*3 = 27.
22
+ * */
23
public class _339 {
24
public static class Solution1 {
25
private int sum = 0;
0 commit comments