Category: Binary tree coding problemYou are given the root of a binary tree. You need to install the minimum number of cameras on the tree nodes such that every node in the tree is...Input: Binary tree Output: Integer
codingHardVerified Question#2
2. [CodeSignal] Warehouse Emergency Deliveries
Category: Array coding problemAmazon has opened a new warehouse recently. There are no products in the warehouse currently. The warehouse is under inspection for n days. The...Input: Array Output: Integer
codingHardVerified Question#3
3. [CodeSignal] Permutation Sorter
Category: Combinatorics coding problemAmazon engineers are testing a new tool, the Permutation Sorter, built to reorder sequences using limited operations. Given a permutation of...Input: Integer(s) Output: Integer
codingHardVerified Question#4
4. [CodeSignal] Maximum Product Rating
Category: Array coding problemThe engineers at Amazon are working on a new rating system for their products. For each product, an array customer_rating is maintained for the...Input: Array Output: Computed result
codingMediumVerified Question#5
5. [CodeSignal] Drone Hub Travel
Category: Array coding problemAmazon is expanding its next-generation drone delivery network, consisting of m hubs arranged in a circular ring (Hub 1 is adjacent to Hub m)....Input: Array Output: Computed result
codingMediumVerified Question#6
6. [CodeSignal] Minimum Security Groups
Category: Array coding problemA financial services company has requested AWS for a private deployment of its cloud network. There are n servers in the network where the security...Input: Array Output: Integer
codingMediumVerified Question#7
7. [CodeSignal] Maximum Secure Deliveries
Category: Array coding problemYou are given an array deliveryLogs of size n, where each element represents the number of parts delivered in the i-th log. You are also given...Input: Array Output: Integer
codingMediumVerified Question#8
8. Maximum Interval Overlap
Category: Interval-based coding problemYou are given a list of closed intervals on the number line, where each interval [start, end] includes both endpoints. Find the maximum number of...Input: List Output: Integer
system designSeniorapi design#1
1. [OA] Design a Service Health Monitor — Real-time performance tracking of microservices
In Amazon, ensuring the health and performance of microservices is vital for maintaining the user experience. You are tasked with designing a ServiceHealthMonitor class that keeps track of the health status of various services.Class:ServiceHealthMonitor - Method:report_health(service_name: str, status: bool) -> None — Updates the health status for the given service. - Method:get_health(service_name: str) -> bool — Returns the current health status of the specified service.Example 1: Input: service_name="serviceA", status=true Output: None Explanation: Successfully reported serviceA as healthy.Example 2: Input: service_name="serviceA" Output: true Explanation: The current health status of serviceA is healthy.Constraints: - The service_name can be up to 50 characters long. - Health statuses are updated at most every minute.
system designSeniordistributed systems#2
2. [OA] Design a Distributed Config Manager — Centralized configuration for hundreds of microservices
In Amazon, managing configurations for numerous services is a challenge that must be handled efficiently. This design involves creating a class for a DistributedConfigManager that allows various services to fetch their configurations dynamically.Class:DistributedConfigManager - Method:get_config(service_name: str) -> Dict[str, Any] — Fetches the configuration for the given service. - Method:set_config(service_name: str, config: Dict[str, Any]) -> bool — Sets the configuration for the specified service and returns success status.Example 1: Input: service_name="serviceA" Output: { "timeout": 30, "retry": 5 } Explanation: The configuration for serviceA is fetched successfully from the centralized manager.Example 2: Input: service_name="serviceB" Output: True Explanation: The configuration for serviceB has been set successfully.Constraints: - The service_name length must be ≤ 50 characters. - Config values can be any valid JSON structure up to a depth of 10.
codingHardinfra#3
3. [OA] Dockerfile Optimization — Enhance the layering of a microservice deployment
In Amazon, deploying microservices efficiently is essential for performance and cost management. This task requires you to optimize a given Dockerfile to minimize the image size and improve build times. You need to create a Dockerfile for the Go service that uses go build and makes use of multi-stage builds for optimization.Method:optimize_dockerfile(base_image: str) -> str — Takes a base image string and returns an optimized Dockerfile as a string.Example 1: Input: "golang:1.17" Output: "FROM golang:1.17 AS builder..." Explanation: The returned Dockerfile is optimized using multi-stage builds to create a leaner image.Example 2: Input: "ubuntu:20.04" Output: "FROM ubuntu:20.04 AS builder..." Explanation: The returned Dockerfile sets up a multi-stage build appropriate for Go applications.Constraints: - The base image string will always be in the format of "<os>:<version>". - The optimized Dockerfile should not exceed 500 lines.
codingHardinfra#4
4. [OA] Terraform — Manage the state of a multi-region infrastructure
In Amazon, multi-region deployments are critical for redundancy and low latency. Using Terraform, you are required to manage infrastructure in two regions for a new service rollout. You need to write a script that initializes the state for a given Terraform configuration, allowing it to seamlessly deploy infrastructure across two regions while ensuring that state files are synchronized.Method:initialize_state(config: str) -> bool — Initializes the Terraform state using the provided configuration string. Returns True if successful.Example 1: Input: "aws_instance = { region: us-east-1 }" Output: True Explanation: The script successfully initialized the state for the specified AWS region.Example 2: Input: "aws_instance = { region: us-west-2 }" Output: True Explanation: The script successfully initialized the state for the specified AWS region.Constraints: - config length ≤ 1000 characters. - The number of regions can be up to 50.