Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything. Table: Customers. +----+-------+<br />| Id | Name |<br />+----+-------+<br />| 1 | Joe |<br />| 2 | Henry
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+<br />| Id | Email |<br />+----+---------+<br />| 1 | a@b.com |<br />| 2 | c@d.com |<br />| 3 | a@b.com |<br />+----+---------+<br />For example, your query should return the fo
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+<br />| Id | Name | Salary | ManagerId |<br />+----+-------+--------+-----------+<br />| 1 | Joe |
Write a SQL query to get the second highest salary from the Employee table. +----+--------+<br />| Id | Salary |<br />+----+--------+<br />| 1 | 100 |<br />| 2 | 200 |<br />| 3 | 300 |<br />+----+--------+<br />For example, given the
Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people: Table: Person +-------------+---------+<br />| Column Name | Type |<br />+-------------+---------+<br
You have a RecentCounter class which counts the number of recent requests within a certain time frame. Implement the RecentCounter class: RecentCounter() Initializes the counter with zero recent requests.<br />int ping(int t) Adds a new request at time t, where t represents some tim
Three stones are on a number line at positions a, b, and c. Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the stones are currently at positions x, y,
You are playing the following Nim Game with your friend: Initially, there is a heap of stones on the table.<br />You and your friend will alternate taking turns, and you go first.<br />On each turn, the person whose turn it is will remove 1 to 3 stones from the heap.<br />The one who remov
The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn. Example 1: Input: n = 4<br />Output: 4<br />Explanation:<br />T_3 = 0 + 1 + 1 = 2<br />T_4 = 1 + 1
Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the ParkingSystem class: ParkingSystem(int big, int medium, int small) Initializes object of the ParkingSystem
You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes the existence of a bidirectional path from garden xi to garden yi. In each garden, you want to plant one of 4 types of flowers. There is no garden that has more than three paths coming into or l
In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody.<br />Everybody (except for the town judge) trusts the town judge.<br />There is exactly one p