Many Java API classes have methods that return a Collection. Since Java 8, methods can also return a Stream. Since the Stream is more flexible and efficient in many cases, should we return a Steam or Collection for our API methods?
LeetCode – Linked List Random Node (Java)
Given a singly linked list, return a random node’s value from the linked list. Each node must have the same probability of being chosen. Follow up: What if the linked list is extremely large and its length is unknown to you? Could you solve this efficiently without using extra space? Java Solution This problem is … Read more