温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Lintcode22 Flatten List solution 题解

发布时间:2020-08-03 00:48:05 来源:网络 阅读:498 作者:coderer 栏目:软件技术

【题目描述】

Given a list, each element in the list can be a list or integer. flatten it into a simply list with integers.

Notice:If the element in the given list is a list, it can contain list too.

给定一个列表,该列表中的每个要素要么是个列表,要么是整数。将其变成一个只包含整数的简单列表。

注意:如果给定的列表中的要素本身也是一个列表,那么它也可以包含列表。

【题目链接】

http://www.lintcode.com/en/problem/flatten-list/

【题目解析】

给定 [1,2,[1,2]],返回 [1,2,1,2]。

给定 [4,[3,[2,[1]]]],返回 [4,3,2,1]。

递归解法和非递归解法解答。容易题。

【参考答案】

http://www.jiuzhang.com/solutions/flatten-list/


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI