y*****e 发帖数: 712 | 1 同意,我也是L的粉丝啊,我最近在学着用L的kafka camus hadoop pipeline,用的很
浅,但还是很能appreciate这些技术后面的智慧和才华。而且L的documentation写的也
很好,哎,星星眼。。。。
这题java的interface
public interface NestedInteger{
public boolean isInteger();
public Integer getInteger();
public List getList();
}
int depthSum(List input){}
我不是太懂c++, vector 约等于 arraylist,所以可能是
int depthSum(Vector &input)这样 |
|
z***e 发帖数: 58 | 2 #3 O(n)
public static int depthSum(String[] strs){
int depth = 1;
int totalDepth = 0;
for(String str : strs){
if(str.equals("{")){
depth ++;
totalDepth = Math.max(depth, totalDepth);
} else if(str.equals("}")){
depth --;
}
}
int sum =0;
int currentDepth = 0;
for(String str : strs){
if(str.equals("{")){
currentDepth ++;
... 阅读全帖 |
|
z***b 发帖数: 127 | 3 Given a nested list of integers, returns the sum of all integers in the list
weighted by their depth
For example, given the list {{1,1},2,{1,1}} the function should return 10 (
four 1's at depth 2, one *2 at depth 1)
Given the list {1,{4,{6}}} the function should return 27 (one 1 at depth 1,
one 4 at depth 2, and *one 6 at depth 3)
public int depthSum (List input)
{
//Implement this function
}
/**
* This is the interface that allows for creating nested lists. You should
not i... 阅读全帖 |
|
z***b 发帖数: 127 | 4 Given a nested list of integers, returns the sum of all integers in the list
weighted by their depth
For example, given the list {{1,1},2,{1,1}} the function should return 10 (
four 1's at depth 2, one *2 at depth 1)
Given the list {1,{4,{6}}} the function should return 27 (one 1 at depth 1,
one 4 at depth 2, and *one 6 at depth 3)
public int depthSum (List input)
{
//Implement this function
}
/**
* This is the interface that allows for creating nested lists. You should
not i... 阅读全帖 |
|
发帖数: 1 | 5 写成leetcode那个格式,比如
class Solution(object):
def depthSum(self, nestedList):
还是只写一个函数就可以了? |
|