607. Sales Person LeetCode Solution

In this guide, you will get 607. Sales Person LeetCode Solution with the best time and space complexity. The solution to Sales Person problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.

Table of Contents

  1. Problem Statement
  2. Complexity Analysis
  3. Sales Person solution in C++
  4. Sales Person solution in Java
  5. Sales Person solution in Python
  6. Additional Resources
607. Sales Person LeetCode Solution image

Problem Statement of Sales Person

Table: SalesPerson

+—————–+———+
| Column Name | Type |
+—————–+———+
| sales_id | int |
| name | varchar |
| salary | int |
| commission_rate | int |
| hire_date | date |
+—————–+———+
sales_id is the primary key (column with unique values) for this table.
Each row of this table indicates the name and the ID of a salesperson alongside their salary, commission rate, and hire date.

Table: Company

+————-+———+
| Column Name | Type |
+————-+———+
| com_id | int |
| name | varchar |
| city | varchar |
+————-+———+
com_id is the primary key (column with unique values) for this table.
Each row of this table indicates the name and the ID of a company and the city in which the company is located.

Table: Orders

+————-+——+
| Column Name | Type |
+————-+——+
| order_id | int |
| order_date | date |
| com_id | int |
| sales_id | int |
| amount | int |
+————-+——+
order_id is the primary key (column with unique values) for this table.
com_id is a foreign key (reference column) to com_id from the Company table.
sales_id is a foreign key (reference column) to sales_id from the SalesPerson table.
Each row of this table contains information about one order. This includes the ID of the company, the ID of the salesperson, the date of the order, and the amount paid.

See also  879. Profitable Schemes LeetCode Solution

Write a solution to find the names of all the salespersons who did not have any orders related to the company with the name “RED”.
Return the result table in any order.
The result format is in the following example.

Example not found

Constraints not found

Complexity Analysis

  • Time Complexity: Google AdSense
  • Space Complexity: Google Analytics

607. Sales Person LeetCode Solution in C++

SELECT SalesPerson.name
FROM Orders
INNER JOIN Company
  ON (Orders.com_id = Company.com_id AND Company.name = 'RED')
RIGHT JOIN SalesPerson
  USING (sales_id)
WHERE Orders.sales_id IS NULL;
/* code provided by PROGIEZ */

607. Sales Person LeetCode Solution in Java

N/A
// code provided by PROGIEZ

607. Sales Person LeetCode Solution in Python

N/A
# code by PROGIEZ

Additional Resources

Happy Coding! Keep following PROGIEZ for more updates and solutions.