55. Linked-List: (hard)
3. Flatten LL✅ 4. Clone LL with random pointer & next pointer✅ --------------------------------------------------------------------------------------------------------------- 1. Reverse in groups of size K⭐ Do not alter node's values, instead only change links ---------------------------- Approach - Check if k nodes exist & reverse one group at a time ----------------------------------------------------------------------------------------------------------------------------- 2. Rotate a LL Brute - time: O(n) space:O(n) store all elements in an array & then rotate the array & then over write the LL with this rotated array elements -------------- Better - time: O(nk) space: O(1) do this k times- remove last node and add it to the front before this do (k = k % n) so we can reduce extra iterations ---------------- Optimal - time: O(n) space: O(1) just change link of (n-k)th node and point it to null the nodes from (n-k+1)th node to the last ...