Blogs Hub

by AskGif | Oct 16, 2020 | Category :coding

Customers Who Never Order - Sql - Easy - LeetCode

Customers Who Never Order - Sql - Easy - LeetCode

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 &nbsp;|<br />+----+-------+<br />| 1 &nbsp;| Joe &nbsp; |<br />| 2 &nbsp;| Henry

read more...

by AskGif | Oct 16, 2020 | Category :coding

Duplicate Emails - Sql - Easy - LeetCode

Duplicate Emails - Sql - Easy - LeetCode

Write a SQL query to find all duplicate emails in a table named Person. +----+---------+<br />| Id | Email &nbsp; |<br />+----+---------+<br />| 1 &nbsp;| a@b.com |<br />| 2 &nbsp;| c@d.com |<br />| 3 &nbsp;| a@b.com |<br />+----+---------+<br />For example, your query should return the fo

read more...

by AskGif | Oct 16, 2020 | Category :coding

Employees Earning More Than Their Managers - Sql - Easy - LeetCode

Employees Earning More Than Their Managers - Sql - Easy - LeetCode

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 &nbsp;| Salary | ManagerId |<br />+----+-------+--------+-----------+<br />| 1 &nbsp;| Joe &nbsp; |

read more...

by AskGif | Oct 16, 2020 | Category :coding

Second Highest Salary - Sql - Easy - LeetCode

Second Highest Salary - Sql - Easy - LeetCode

Write a SQL query to get the second highest salary from the Employee table. +----+--------+<br />| Id | Salary |<br />+----+--------+<br />| 1 &nbsp;| 100 &nbsp; &nbsp;|<br />| 2 &nbsp;| 200 &nbsp; &nbsp;|<br />| 3 &nbsp;| 300 &nbsp; &nbsp;|<br />+----+--------+<br />For example, given the

read more...

by AskGif | Oct 16, 2020 | Category :coding

Combine Two Tables - Sql - Easy - LeetCode

Combine Two Tables - Sql - Easy - LeetCode

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 &nbsp; &nbsp;|<br />+-------------+---------+<br

read more...

by AskGif | Oct 16, 2020 | Category :coding

Number of Recent Calls - Queue - Easy - LeetCode

Number of Recent Calls - Queue - Easy - LeetCode

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

read more...

by AskGif | Oct 16, 2020 | Category :coding

Moving Stones Until Consecutive - Brainteaser - Easy - LeetCode

Moving Stones Until Consecutive - Brainteaser - Easy - LeetCode

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. &nbsp;Formally, let's say the stones are currently at positions x, y,

read more...

by AskGif | Oct 15, 2020 | Category :coding

Nim Game - Brainteaser - Easy - LeetCode

Nim Game - Brainteaser - Easy - LeetCode

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

read more...

by AskGif | Oct 15, 2020 | Category :coding

N-th Tribonacci Number - Recursion - Easy - LeetCode

N-th Tribonacci Number - Recursion - Easy - LeetCode

The Tribonacci sequence Tn is defined as follows:&nbsp; T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n &gt;= 0. Given n, return the value of Tn. &nbsp; Example 1: Input: n = 4<br />Output: 4<br />Explanation:<br />T_3 = 0 + 1 + 1 = 2<br />T_4 = 1 + 1

read more...

by AskGif | Oct 15, 2020 | Category :coding

Design Parking System - Design - Easy - LeetCode

Design Parking System - Design - Easy - LeetCode

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

read more...

by AskGif | Oct 15, 2020 | Category :coding

Flower Planting With No Adjacent - Graph - Easy - LeetCode

Flower Planting With No Adjacent - Graph - Easy - LeetCode

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

read more...

by AskGif | Oct 14, 2020 | Category :coding

Find the Town Judge - Tree - Easy - LeetCode

Find the Town Judge - Tree - Easy - LeetCode

In a town, there are N people labelled from 1 to N. &nbsp;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

read more...