Coding problem
Customers who never ordered
The task
The marketing team sends a welcome offer to the customers who signed up but never placed an order.
Complete NeverOrdered(List<Customer> customers, List<Order> orders). Customer is a record with an Id and a Name; Order is a record with its own Id and the CustomerId of the customer who placed it. Return the customers who have no orders at all, in the order of the customer list. Orders whose CustomerId matches no customer change nothing. The lists and their items are never null, and customer ids are unique.
Signature
public record Customer(int Id, string Name); public record Order(int Id, int CustomerId); public static List<Customer> NeverOrdered(List<Customer> customers, List<Order> orders)
Examples
customers [(1, "amy"), (2, "ben"), (3, "cara")], orders [(10, 2), (11, 2)]→[(1, "amy"), (3, "cara")]. Only ben has orders.customers [(1, "amy")], orders []→[(1, "amy")]. With no orders at all, every customer never ordered.
Limits: Up to 200,000 customers and 300,000 orders.
The tests check: no customers, no orders, everyone having ordered, customers in their list order, orders of unknown customers, order ids that look like customer ids, two customers with the same name, and 200,000 customers with 300,000 orders in time.
Hints
Your code
Already included: using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks;
public record Customer(int Id, string Name);
public record Order(int Id, int CustomerId);
public static class Solution
{
// The customers with no orders at all, in customer-list order.
public static List<Customer> NeverOrdered(List<Customer> customers, List<Order> orders)
{
throw new NotImplementedException();
}
}This problem comes with TechInterviewNotes Full Access
Unlock all paid content on TechInterviewNotes.