You are given an array of integers where each element represents the cost of hiring a worker. You need to hire exactly k workers by running k sessions. In each session, choose the worker with the lowest cost from either the first ‘candidates’ workers or the last ‘candidates’ workers. If there is a tie, choose the worker with the smallest index.
You are given an array of even length containing integers. In each step, repeatedly remove the smallest and the largest numbers from the array, calculate their average, and continue until the array is empty. The goal is to find how many distinct averages were calculated during this process.
In a tree with n nodes labeled from 0 to n - 1, each node has a gate with a price to open. Alice starts at node 0 and Bob starts at node bob. Alice moves towards a leaf node, and Bob moves towards node 0. At every node, both Alice and Bob either pay the price to open the gate, or they receive a reward. If they reach a node simultaneously, they share the price/reward equally. Return the maximum net income Alice can achieve if she travels towards the optimal leaf node.
Given an integer array nums and an integer k, return the number of subarrays where the Least Common Multiple (LCM) of all the elements in the subarray equals k. A subarray is a contiguous subsequence of elements in the array.
You are given a 0-indexed array of positive integers, nums. Find the number of triplets (i, j, k) such that 0 <= i < j < k < nums.length and nums[i], nums[j], nums[k] are distinct.
You are given the root of a binary search tree (BST) and an array of queries. For each query, find the largest value smaller than or equal to the query value and the smallest value greater than or equal to the query value in the tree.