Given a positive integer n, compute the ‘clumsy factorial’ of n. A clumsy factorial is computed using a series of operations (multiplication, division, addition, subtraction) in a fixed order applied to the integers from n down to 1. The operations follow this order: multiplication ‘*’, division ‘/’, addition ‘+’, subtraction ‘-’, and are repeated cyclically. Division is performed as floor division, and multiplication and division are processed left to right before addition and subtraction.
You are given an array representing the preorder traversal of a binary search tree (BST). Your task is to construct the BST from this preorder traversal and return the root of the tree.
You are given the head of a singly linked list. For each node in the list, find the value of the next node that has a strictly larger value than the current node. If no such node exists, return 0 for that node. Return the result as an array where the value at index i represents the next greater node for the i-th node.
You are given a string s, and your task is to return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once. The subsequence must be in the same order as the original string, but the characters should not repeat.
A string consisting of only ‘(’ and ‘)’ characters is considered a valid parentheses string (VPS) if it satisfies the following conditions: it is empty, can be split into two valid VPS’s, or can be written in the form of ‘(A)’ where A is a VPS. You are given a VPS string seq. The task is to split it into two subsequences, A and B, such that both A and B are valid parentheses strings. The goal is to minimize the maximum nesting depth between A and B, and you need to return an array where each element is 0 if the character is part of A, and 1 if it’s part of B.
You are given a list of integers representing the number of hours worked each day. A day is considered tiring if the number of hours worked is strictly greater than 8. A well-performing interval is an interval of days where the number of tiring days is strictly larger than the number of non-tiring days. Your task is to return the length of the longest well-performing interval.