亏了80万跑路了,求安慰 |
给了他20分钟做这道题,没做出来
https://leetcode.cn/problems/pascals-triangle/
花了几分钟写了个,不知道对不对,十来年没写这玩意儿了
gernerateYanghuiAngle(int rows){
Map<String, List<int>> map = <String, List<int>>{};
for(int i = 1; i <= rows; i++){
List<int> tmp = [];
if(i != 1) {
int len = i;
for(int j = 0; j < len; j++){
tmp.add(0);
}
for (int k = 0; k < tmp.length; k++) {
tmp[k] = (k == 0 || k == len-1)?1:map["${i-1}"][k]+map["${i-1}"][k-1];
}
map["$i"] = tmp;
}
map["$i"] = i == 1?[1]:tmp;
}
print("map.len = ${map.length}");
map.forEach((key, value) {
print("${key == "1"?"[ ":""}$value${key != rows?",":""} ${key == "$rows"?"]":""}");
});
}
过早客微信公众号:guozaoke • 过早客新浪微博:@过早客 • 广告投放合作微信:fullygroup50 鄂ICP备2021016276号-2 • 鄂公网安备42018502001446号