You are given an array consisting only of integers 0, 1, and 2. Your task is to sort the array in-place such that all 0s come first, followed by all 1s, and then all 2s. You must not use any built-in sorting functions. The solution should ideally run in a single pass with constant extra space.
Example:
Input: [2, 0, 2, 1, 1, 0]
Output: [0, 0, 1, 1, 2, 2]
Explain the concept of multithreading in Java, where multiple threads run concurrently to improve application performance and responsiveness. Describe how threads are created and managed using the Thread class and the Runnable interface, and outline the key concepts involved in multithreading such as the thread lifecycle (new, runnable, running, waiting, terminated), synchronization for handling shared resources, and ensuring thread safety. Additionally, highlight the differences between extending the Thread class and implementing the Runnable interface when creating threads.
Explain the Java Collection Framework and its significance in application development, including how it provides standardized interfaces and classes for storing, managing, and manipulating groups of objects. Additionally, describe the internal working of a HashMap in Java: how key-value pairs are stored using hashing, how the hash function determines the bucket index, and what happens when collisions occur. Include an explanation of collision handling techniques (like chaining with linked lists or balanced trees in modern Java), resizing mechanisms, and performance considerations such as time complexity for insertion, deletion, and lookup operations.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?