Amazon
10+ HCP Wellness Interview Questions and Answers
Q1. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
The task is to find the total number of ways to make change for a specified value using given denominations.
Use dynamic programming to solve this problem efficiently.
Create a 2D array to store the number of ways to make change for each value using different denominations.
Iterate through each denomination and update the array based on the number of ways to make change for each value.
Return the value at the last cell of the array as the final result.
Q2. Shopping Options Problem Statement
Given arrays representing the costs of pants, shirts, shoes, and skirts, and a budget amount 'X', determine the total number of valid combinations that can be purchased such t...read more
Determine total number of valid shopping combinations within budget
Iterate through all possible combinations of items from each array
Check if the total cost of the combination is within the budget
Return the count of valid combinations
Q3. Reverse Linked List Problem Statement
Given a Singly Linked List of integers, your task is to reverse the Linked List by altering the links between the nodes.
Input:
The first line of input is an integer T, rep...read more
Reverse a singly linked list by altering the links between nodes.
Iterate through the linked list and reverse the links between nodes
Use three pointers to keep track of the current, previous, and next nodes
Update the links between nodes to reverse the list
Return the head of the reversed linked list
Q4. Median in a Stream Problem Statement
Your task is to determine the median of integers as they are read from a data stream. The median is the middle value in the ordered list of numbers. If the list length is ev...read more
Find median of integers in a data stream as they are read.
Use two heaps - max heap for lower half of numbers and min heap for upper half.
Keep the size of two heaps balanced to find the median efficiently.
Handle even and odd number of elements separately to calculate median.
Return vector of medians after each element is read from the stream.
Q5. Max Submatrix Problem Statement
You are provided with a matrix MAT
consisting of integers, with dimensions N x M
(i.e., N rows and M columns). Your objective is to determine the maximum sum submatrix within thi...read more
Find the maximum sum submatrix in a given matrix.
Iterate over all possible submatrices and calculate their sums
Use Kadane's algorithm to find the maximum sum subarray in each row
Combine the sums of rows to find the maximum sum submatrix
Q6. The Ninja Port Problem
Ninja is in a city with 'N' colonies, where each colony contains 'K' houses. He starts at house number "sourceHouse" in colony number "sourceColony" and wants to reach house number "desti...read more
The Ninja Port Problem involves finding the minimum time for a ninja to travel between colonies and houses using secret paths and teleportation.
Calculate the minimum time considering teleportation within colonies, traveling between colonies, and secret paths.
Keep track of the number of secret paths used and ensure they are one-way.
Consider the constraints provided to optimize the solution.
Example: N=2, K=3, S=1, P=1, sourceHouse=1, sourceColony=1, destinationHouse=3, destinat...read more
Q7. Course Schedule II Problem Statement
You are provided with a number of courses 'N', some of which have prerequisites. There is a matrix named 'PREREQUISITES' of size 'M' x 2. This matrix indicates that for ever...read more
Given courses with prerequisites, determine a valid order to complete all courses.
Create a graph with courses as nodes and prerequisites as edges.
Use topological sorting to find a valid order to complete all courses.
Return an empty list if it's impossible to complete all courses.
Q8. Validate Binary Search Tree (BST)
You are given a binary tree with 'N' integer nodes. Your task is to determine whether this binary tree is a Binary Search Tree (BST).
BST Definition:
A Binary Search Tree (BST)...read more
Validate if a given binary tree is a Binary Search Tree (BST) or not.
Check if the left subtree of a node contains only nodes with data less than the node's data
Check if the right subtree of a node contains only nodes with data greater than the node's data
Recursively check if both left and right subtrees are also binary search trees
Q9. Clone a Binary Tree with Random Pointers
Given a binary tree where each node has pointers to its left, right, and a random node, create a deep copy of the binary tree.
Input:
The first line contains an integer ...read more
Clone a binary tree with random pointers and verify if cloning was successful by printing inorder traversal.
Create a deep copy of the binary tree with random pointers.
Print the inorder traversal of the cloned binary tree.
Verify cloning success by printing '1' if successful, '0' otherwise.
Q10. Group Anagrams Together
Given an array/list of strings STR_LIST
, group the anagrams together and return each group as a list of strings. Each group must contain strings that are anagrams of each other.
Example:...read more
Group anagrams together in a list of strings.
Iterate through the list of strings and sort each string to group anagrams together.
Use a hashmap to store the sorted string as key and the original string as value.
Return the values of the hashmap as the grouped anagrams.
Q11. Add Two Numbers Represented by Linked Lists
Your task is to find the sum list of two numbers represented by linked lists and return the head of the sum list.
Explanation:
The sum list should be a linked list re...read more
Add two numbers represented by linked lists and return the head of the sum list.
Traverse both linked lists simultaneously while keeping track of carry from previous sum
Create a new linked list to store the sum of the two numbers
Handle cases where one linked list is longer than the other by padding with zeros
Update the sum and carry values accordingly while iterating through the linked lists
Q12. Distance Between Two Nodes in a Binary Tree
Given a binary tree and the values of two distinct nodes, determine the distance between these two nodes in the tree. The distance is defined as the minimum number of...read more
Calculate the distance between two nodes in a binary tree.
Traverse the tree to find the paths from the root to each node
Find the lowest common ancestor of the two nodes
Calculate the distance by summing the distances from each node to the common ancestor
Design a live video broadcast platform.
Implement video streaming functionality using protocols like RTMP or WebRTC
Include features for live chat, reactions, and audience engagement
Ensure scalability and reliability by using cloud services like AWS or Azure
Provide analytics for viewership data and user engagement
Integrate monetization options such as ads or subscriptions
More about working at Amazon
Top SDE-2 Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month