I recently assisted several classmates in completing Amazon HackerRank OA (includes SDE Intern and New Grad). The mainstream of Amazon OA is 2 Coding questions (90 minutes), and occasionally 3 questions appear, but the overall question style is stable. To help you prepare for the exam efficiently, I have sorted out the five high-frequency real questions that have appeared most frequently and have a high repetition rate in many recent OA sessions, and attached detailed problem-solving ideas and code templates for your reference.

Amazon HackerRank OA Overall
- Platform:HackerRank
- Question volume: Mainstream 2 Coding questions (Minor 3 questions)
- Duration:90 minutes
- Difficulty: The first question is Easy-Medium, the second question is Medium-Hard
- Features: The second question has a longer description, many boundary conditions, and greater time pressure.
The following are 5 recent high-frequency representative real questions in May 2026:
Detailed explanation of Amazon HackerRank OA high-frequency real questions
1. Inventory allocation algorithm (Medium-Hard)
Topic: During a limited-time sale event, a customer submits a request [customerId, quantity, bidAmount, timestamp]. Priority by bid, round robin allocation by timestamp for the same bid, up to 1 piece per person at a time until inventory is exhausted. Returns a list of customer IDs (in ascending order) that did not obtain any items.
Problem-solving ideas:
- First sort by bidAmount in descending order and timestamp in ascending order.
- Simulate round-robin allocation using priority queue or sorting
- Record the number of items each customer has received
Core code framework(Python):
Def getUnfulfilledCustomers(requests, totalInventory):
# requests = [customerId, quantity, bidAmount, timestamp]
customers = sorted(requests, key=lambda x: (-x[2], x[3]))
from collections import defaultdict
allocated = defaultdict(int)
for customers:
cid, qty, bid, ts = cust
while qty > 0 and totalInventory > 0 and allocated[cid] < qty:
allocated[cid] += 1
totalInventory -= 1
unfulfilled = [cid for cid, req in requests if allocated[cid[0]] == 0]
return sorted(set(unfulfilled))
2. Movie search (Django code snippet repair)
Topic: gives a Search_movies The Django view code snippet (see below) is required to implement or improve the movie search interface. Interface support:
- Refine filter by year
Year, or rangeMin_year/Max_year; - Press director
Director,screenwriterWriterFuzzy search (case insensitive); - By rating
RatingDescending order, by popularity if tiedPopularityDescending order; - Returns a JSON list containing the movie's detailed fields.
Reference code
Def search_movies(request):
Year = request.GET.get(‘year’)
Min_year = request.GET.get(‘min_year’)
Max_year = request.GET.get(‘max_year’)
Director = request.GET.get(‘director’)
Writer = request.GET.get(‘writer’)
Movies_qe = Movie.objects.all()
if year:
movies_qe = movies_qe.filter(year=int(year))
else:
if min_year:
movies_qe = movies_qe.filter(year__gte=int(min_year))
if max_year:
movies_qe = movies_qe.filter(year__lte=int(max_year))
if director:
movies_qe = movies_qe.filter(director__icontains=director.strip())
if writer:
movies_qe = movies_qe.filter(writers__icontains=writer.strip())
movies_qe = movies_qe.order_by('-rating', '-popularity')
movies = []
for movie in movies_qe:
movies.append({
'_id': str(movie.id),
'title': movie.title,
'year': movie.year,
'duration': movie.duration,
'rating': movie.rating,
'popularity': movie.popularity,
'genre': movie.genre,
'description': movie.description,
'director': movie.director,
'writers': movie.writers,
'stars': movie.stars,
})
return JsonResponse(movies, safe=False)
3. SQL: Query of winning bidders on auction website (high frequency)
Topic: The website adopts "increased bidding". Buyers can increase the price an unlimited number of times, and the amount of each increase is preset by the seller. The buyer with the highest bid (i.e. The last bid) wins the bid. Please write a SQL query to return information about all lots:
| Field | Illustrate |
|---|---|
| Name | Lot name |
| Starting_price | Starting price |
| Bid_step | Price increase per time |
| Bids | Total number of bids |
| Current_price | Current price = starting price + bid increase × number of bids |
| Current_winner | Buyer username of last bid |
Result press Name Sort in ascending order.
Assume table structure
ItemsTable: id, name, starting_price, bid_stepBidsTable: id, item_id, bidder_name, bid_time (each bid record)
Problem-solving ideas
- Exist
BidsPress in the tableItem_idGroup to obtain the number of bids and the buyer who made the last bid; - The last bidder can pass the window function
ROW_NUMBER() OVER (PARTITION BY item_id ORDER BY bid_time DESC)Or use when aggregatingLAST_VALUE/ Correlated subquery obtained; - And
ItemsTable JOIN, calculationCurrent_price.
Reference SQL:
SELECT
i.name,
i.starting_price,
i.bid_step,
COUNT(b.id) AS bids,
i.starting_price + i.bid_step * COUNT(b.id) AS current_price,
(SELECT buyer_username FROM bids
WHERE item_id = i.id
ORDER BY bid_time DESC LIMIT 1) AS current_winner
FROM items i
LEFT JOIN bids b ON i.id = b.item_id
GROUP BY i.id
ORDER BY i.name ASC;
4. REST API: Country phone code formatting
Topic: Call the API to obtain the area code based on the country name. The phone number is formatted as +area code phone number. If the country is not found, -1 is returned.
Problem-solving ideas:
- Call https://jsonmock.hackerrank.com/api/countries?name={country}
- Get the last area code in the callingCodes array
- Formatted return
5. Password strength verification
Topic: Determine whether the password is a "weak password" or a "strong password" based on the rules.
Weak password conditions:
- Contains common words
- Numbers only
- Uppercase only or lowercase only
- Length < 6
Problem-solving ideas: Check the rules one by one and return the corresponding results.
From inefficiency in answering questions to successfully passing Amazon OA
This time I am very happy to help this group of students successfully pass the Amazon HackerRank OA. I found that when many students were preparing for OA, it was not very efficient to just answer the questions on their own, and they were particularly prone to suffer from time allocation and boundary processing of complex question types.
If you are also preparing for Amazon SDE Intern, New Grad, or HackerRank OA from other major manufacturers, and feel that reviewing alone is inefficient and the direction is unclear, you are welcome to contact Programhelp.
We will provide professional advice based on your specific level and weaknesses OA practical assistanceServices and one-on-one coaching.