美文网首页
LeetCode:284

LeetCode:284

作者: hxc92 | 来源:发表于2017-11-14 15:09 被阅读0次
# Below is the interface for Iterator, which is already defined for you.
#
# class Iterator(object):
#     def __init__(self, nums):
#         """
#         Initializes an iterator object to the beginning of a list.
#         :type nums: List[int]
#         """
#
#     def hasNext(self):
#         """
#         Returns true if the iteration has more elements.
#         :rtype: bool
#         """
#
#     def next(self):
#         """
#         Returns the next element in the iteration.
#         :rtype: int
#         """

class PeekingIterator(object):
    def __init__(self, iterator):
        """
        Initialize your data structure here.
        :type iterator: Iterator
        """
        

    def peek(self):
        """
        Returns the next element in the iteration without advancing the iterator.
        :rtype: int
        """
        

    def next(self):
        """
        :rtype: int
        """
        

    def hasNext(self):
        """
        :rtype: bool
        """
        

# Your PeekingIterator object will be instantiated and called as such:
# iter = PeekingIterator(Iterator(nums))
# while iter.hasNext():
#     val = iter.peek()   # Get the next element but not advance the iterator.
#     iter.next()         # Should return the same value as [val].

相关文章

  • 2019-02-08

    LeetCode 284. Peeking Iterator Description Given an Itera...

  • Leetcode - Bulls and Cows

    My code: reference:https://discuss.leetcode.com/topic/284...

  • LeetCode:284

  • LeetCode算法题-Longest Harmonious S

    这是悦乐书的第270次更新,第284篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第...

  • LeetCode算法题-Trim a Binary Search

    这是悦乐书的第284次更新,第301篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第...

  • 284.掌握批判思考正确方法

    知六·洋豆豆向您荐书 第284天 【洋豆豆荐书】第284天~掌握批判思考正确方法 284. 《超越感觉》[美]文森...

  • 非对称加密

    加密:公钥加密,生日的后四位9112491 = __284解密:私钥解密284*11 =3124

  • 284

    幸福路人春风20180315第284天 助人之前先敲门。

  • 284

    时间过得真快,一转眼5天的假期就要结束了,回去要赶紧把落下的东西捡起来,因为这次过来办的点网卡很贵,所以基本上也没...

  • 284

    九个月14天。 襄阳好热! 上午去给布丁看病。 希望宝贝快快好! 晚上布丁,妈妈,舅舅一家去了时代天街。

网友评论

      本文标题:LeetCode:284

      本文链接:https://www.haomeiwen.com/subject/yxhfvxtx.html