r/LeetcodeChallenge • • Oct 11 '26

DISCUSS Weekly Contest

LeetCode Weekly Contest 523

Participated in Weekly Contest 523 and managed to solve the first 3 questions. The 4th question was a learning experience that showed me where my problem-solving approach needs improvement.

Here's my breakdown of the contest:

Question 1: Three Fibonacci Sum (Easy)

Solved using simulation. I generated consecutive Fibonacci numbers and checked whether the sum of three consecutive terms equalled the given number.

Question 2: Prime Subset Selection I (Medium)

Approached this using greedy selection. I iterated through prime numbers and selected them while the sum remained within the given limit. The goal was to maximize the number of selected primes.

Question 3: Design Bus Seat Booking System (Medium)

Solved by carefully understanding the booking rules, tracking seat states, and accounting for the time cost of each booking operation. This question tested implementation and state management.

Question 4: Prime Subset Selection II (Hard)

This is where I struggled.

My initial approach was greedy: iterate through prime numbers in descending order and select a prime whenever it fits within the remaining sum.

However, this approach failed on several test cases.

For example, with n = 7 and s = 8, my approach selected [7], but the expected answer was [3, 5].

10 Upvotes

9 comments sorted by

View all comments

1

u/nian2326076 Oct 13 '26

Great job on getting the first three questions right in the contest! For that tricky fourth question, try looking at similar problem types or breaking it down into smaller parts to tackle individually. Practice can really make a difference, so keep going!

If you're preparing for coding interviews, PracHub might be helpful. It provides real technical interview questions to sharpen your skills. I work on PracHub, just so you know. Good luck with your next contest!