新农上路-加分请看每个版右边栏
- 积分
- 86
- 学分
- 个
- 大米
- 升
- 人参
- 枚
- 水井
- 尺
- 小麦
- 颗
- 萝卜
- 根
- 小米
- 粒
- UID
- 245427
- 注册时间
- 2016-10-6
- 最后登录
- 1970-1-1
- 在线时间
- 小时
- 好友
- 收听
- 听众
- 日志
- 相册
- 帖子
- 主题
- 分享
- 精华
|
面试官准时到达,应该是个白人女人,在写题的过程中很帮助。下面是题,各位看官能打赏点最好啦。
Iterator<T>
-hasNext() -> boolean
-next() -> T
Write a class InterleaveIterator<T> that implements the Iterator<T> and takes as the argument to its constructor "Iterator<Iterator<T>> input". The goal is to flatten the input, returning the input elements in *interleaved* order.
For example:
input.next() -> Iterator with contents{A1, A2, A3}
input.next() -> Iterator with contents{B1}
input.next() -> Iterator with contents{C1, C2}
input.hasNext() -> false.鐣欏璁哄潧-涓浜-涓夊垎鍦
Write a class InterleavedIterator<T> such that:
InterleavedIterator<T> c = new InterleavedIterator<T>(input);
c.next() -> A1
c.next() -> A2
c.next() -> A3
c.next() -> B1
c.next() -> C1
c.next() -> C2
. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
补充内容 (2016-11-1 23:28):
c.next() -> A1
c.next() -> B1. from: 1point3acres.com/bbs
c.next() -> C1. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
c.next() -> A2
c.next() -> C2
c.next() -> A3 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
补充内容 (2016-11-1 23:29):
发帖的时候 输出写错了 多谢coolgod指出 |
评分
-
5
查看全部评分
-
|