I have cross checked my code like so many times
Click here.
- Object last(): This method will return last element in TreeSet if TreeSet is not null else it will throw NoSuchElementException.
In case if there is no element in the TreeSet you should output ‘-1’.
2 Likes
Thanks it was such a silly mistake XD