Rotate a linked list to the right by k places.
Given the head of a linked list, rotate the list to the right by k places.
Input: head = [0,1,2], k = 4
Output: [2,0,1]
Explanation: The list has a length of 3. Rotating by 4 is mathematically equivalent to rotating by 1 (4 mod 3 = 1).
Implement the next permutation algorithm.
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not possible, it must rearrange it as the lowest possible order.
Input: nums = [3,2,1]
Output: [1,2,3]
Explanation: The sequence is strictly decreasing…
Encode and Decode Strings
Encode a list of strings into a single string and decode it back.
Input: strs = ["","hello",""]
Output: ["","hello",""]
Explanation: Prepends chunk lengths and a delimiter (e.g., "0#5#hello0#") to safely encode and perfectly restore empty strings.