Solved 3318. Find X-Sum of All K-Long Subarrays I with frequency and ordering logic.

Day 87/100 of DSA & LeetCode grind 🔥 Today's problem: 3318. Find X-Sum of All K-Long Subarrays I What I learned: • It's not always about prefix sums or classic sliding window. • Sometimes the real game is frequency + ordering logic. • For every window of size k, we: Count freq of each number Keep only the top x most frequent values (tie-break by bigger value 😮) Sum value * freq for those Key skills practiced: ✅ HashMap for freq tracking ✅ Sliding window add/remove in O(1) ✅ Custom sorting rule (by freq desc, value desc) ✅ Turning the problem statement into steps that code can actually do Why I liked this problem: This is the type of question that looks like brute force, but teaches you how to maintain state while the window moves. That's super important for real interviews. Mindset: DSA is not just solving one question. It's building patterns you can reuse. Still going. Still consistent. 🚀 #Day87 #LeetCode #DSA #100DaysOfCode #Java #SlidingWindow #ProblemSolving #Consistency

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories