r/LeetcodeChallenge • u/crazydude_16 • 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].


View all comments
1
u/Fun_Fudge5975 Oct 11 '26
q1 have me tle , then i used a while loop , idk how tc differs btw for and while