Given an integer n, form a binary string by concatenating the binary representations of all integers from 1 to n. Convert this concatenated binary string to its decimal equivalent and return the result modulo 10^9 + 7.
In a tournament with n teams, each round involves pairing teams for matches. The number of matches depends on whether n is even or odd. Calculate the total number of matches played in the tournament until a winner is determined.
In a school cafeteria, sandwiches are placed in a stack and students queue up to get one. Each student has a preference for the type of sandwich, and they either take the sandwich from the stack or move to the back of the queue if the sandwich is not to their liking. The goal is to determine how many students are unable to get a sandwich.
A restaurant with a single chef serves customers. Each customer arrives at a specific time and waits for the chef to prepare their order. The chef can only serve one customer at a time and prepares orders in the order they were received. The goal is to calculate the average waiting time of all customers. The waiting time of a customer is the time between their arrival and when they receive their order.
You have a 2-D grid representing a box, and a number of balls that will be dropped into the box. The box has diagonal boards in each cell, which can redirect the balls either left or right. Your task is to determine the path of each ball dropped from the top of the box. The ball can either fall out of the bottom, or get stuck if it hits a ‘V’ shaped pattern between two boards or is redirected into a wall.
You are managing an order system for a marketplace where both buy and sell orders are placed in batches. Each order contains a price, a quantity, and a type (either buy or sell). You need to calculate how many orders remain unfulfilled in the system after processing all the orders.