LeetCode May Challenge PlayList - • First Bad Version | First Bad Version...
LeetCode 30 Day Challenge PlayList - • Move Zeroes LeetCode | Move Zeroes to...
Given a queue of integers, we need to retrieve the first unique integer in the queue.
Implement the FirstUnique class:
FirstUnique(int[] nums) - Initializes the object with the numbers in the queue.
int showFirstUnique() - Returns the value of the first unique integer of the queue, and returns -1 if there is no such integer.
void add(int value) - Insert value to the queue.
For Example -
Example 1:
FirstUnique firstUnique = new FirstUnique([7,7,7,7,7,7]);
firstUnique.showFirstUnique(); // return -1
firstUnique.add(7); // the queue is now [7,7,7,7,7,7,7]
firstUnique.add(3); // the queue is now [7,7,7,7,7,7,7,3]
firstUnique.add(3); // the queue is now [7,7,7,7,7,7,7,3,3]
firstUnique.add(7); // the queue is now [7,7,7,7,7,7,7,3,3,7]
firstUnique.add(17); // the queue is now [7,7,7,7,7,7,7,3,3,7,17]
firstUnique.showFirstUnique(); // return 17
Example 2:
FirstUnique firstUnique = new FirstUnique([2,3,5]);
firstUnique.showFirstUnique(); // return 2
firstUnique.add(5); // the queue is now [2,3,5,5]
firstUnique.showFirstUnique(); // return 2
firstUnique.add(2); // the queue is now [2,3,5,5,2]
firstUnique.showFirstUnique(); // return 3
firstUnique.add(3); // the queue is now [2,3,5,5,2,3]
firstUnique.showFirstUnique(); // return -1
This problem is the Day 28 of LeetCode 30 Day Challenge Problem.
Website - https://webrewrite.com/
Paypal - https://www.paypal.me/programmingtuto...
On this page of the site you can watch the video online First Unique Number (LeetCode 30 Day Challenge) | Programming Tutorials with a duration of hours minute second in good quality, which was uploaded by the user Programming Tutorials 28 April 2020, share the link with friends and acquaintances, this video has already been watched 3,569 times on youtube and it was liked by 64 viewers. Enjoy your viewing!