Given a singly linked list, implement a class that supports the initialization of the list and the ability to return a random node’s value with equal probability.
You are given an integer array nums. Design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of the shuffling.
Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order. The solution must run in O(n) time and use O(1) extra space.
In a file system where both directories and files are stored, we are given a string representation of the system. The string includes the directory structure, with tab characters (’\t’) representing subdirectories and newline characters (’\n’) representing file and directory boundaries. Each directory and file has a unique absolute path. Compute the length of the longest absolute path to a file. If no file exists, return 0.
Given an integer n, simulate a process on a list of integers from 1 to n where every other number is removed, alternating the direction from left to right and right to left until only one number remains. Return the last remaining number.