由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请问一道面试题Iterator over nested collections
相关主题
LinkedIn 面试题讨论问一个linkedin的面试题
L家面试题 iterator for nested integer求讨论C++ Q73: template (skillport)
谁有那个 nested hashmap iteration 的讨论阿?google on campus 面试多久出结果+面经
找intern找了一个多月了,发Amazon面经,求祝福C++ online Test 一题
贴一个C++ nested Iterator的code,求讨论和指正。C++ Q88: nested non-template class
骑驴找马结束,分享面试题回馈贵版问一个C++的binary search tree类实现问题 (转载)
求指点一道G家Iterator的题目再请教SQL问题
问一道C++ template的面试题Leetcode 大侠,加上 C++11 support 吧
相关话题的讨论汇总
话题: iterator话题: collection话题: design话题: example
进入JobHunting版参与讨论
1 (共1页)
s******e
发帖数: 108
1
Design an iterator for a collection of collections. The iterator should hide
the nesting, allowing you to iterate all of the elements belonging to all
of the collections as if you were working with a single collection.
For Example:
a={{1,2,3},4,{},{5,6,{7,{},{8}}},}.
The result of calling 8 time next() should be:
1,2,3,4,5,6,7,8.
c****p
发帖数: 6474
2
看着像DFS

hide

【在 s******e 的大作中提到】
: Design an iterator for a collection of collections. The iterator should hide
: the nesting, allowing you to iterate all of the elements belonging to all
: of the collections as if you were working with a single collection.
: For Example:
: a={{1,2,3},4,{},{5,6,{7,{},{8}}},}.
: The result of calling 8 time next() should be:
: 1,2,3,4,5,6,7,8.

d********t
发帖数: 9628
3
为啥要那么复杂?如果a是array的话直接next就好了

【在 c****p 的大作中提到】
: 看着像DFS
:
: hide

B*******1
发帖数: 2454
4
是不是用一个iterator,里面根据每个collection的类型再call相应对象的iterator去
打印出数。
A**u
发帖数: 2458
5
没人讨论这个?
1 (共1页)
进入JobHunting版参与讨论
相关主题
Leetcode 大侠,加上 C++11 support 吧贴一个C++ nested Iterator的code,求讨论和指正。
List x; and List x();骑驴找马结束,分享面试题回馈贵版
ME offer求比较。。。求指点一道G家Iterator的题目
谁知道globalnest,是骗子不?问一道C++ template的面试题
LinkedIn 面试题讨论问一个linkedin的面试题
L家面试题 iterator for nested integer求讨论C++ Q73: template (skillport)
谁有那个 nested hashmap iteration 的讨论阿?google on campus 面试多久出结果+面经
找intern找了一个多月了,发Amazon面经,求祝福C++ online Test 一题
相关话题的讨论汇总
话题: iterator话题: collection话题: design话题: example