You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/com/fishercoder/solutions/_284.java
+27-23Lines changed: 27 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,9 @@
7
7
/**
8
8
* 284. Peeking Iterator
9
9
*
10
-
* Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the element that will be returned by the next call to next().
10
+
* Given an Iterator class interface with methods: next() and hasNext(),
11
+
* design and implement a PeekingIterator that support
12
+
* the peek() operation -- it essentially peek() at the element that will be returned by the next call to next().
11
13
12
14
Here is an example. Assume that the iterator is initialized to the beginning of the queue: [1, 2, 3].
13
15
@@ -20,33 +22,35 @@ You call next() the final time and it returns 3, the last element. Calling hasNe
20
22
Follow up: How would you extend your design to be generic and work with all types, not just integer?
0 commit comments