A collection of rare, step-by-step code elucidations.
Hello! Ever searched for a solution to a 1% acceptance rate problem, only to find... nothing? Even when you do find one, a 50-line C++ file with zero comments isn't always helpful.
This repository is my contribution to filling that void!
When I started programming, I jumped into Competitive Programming to fill the gaps in my knowledge of Computer Science algorithms and data structures. I practiced extensively on Beecrowd (formerly URI Online Judge), enjoying its friendly interface and categorized difficulty levels.
I'm providing here some revised solutions I created at that time, solving some of the most intricated and challenging competitive programming problems in the platform, sidealong with their step-by-step logic breakdown and commented code, in order to help other students.
Some of these solutions cost me a bunch of time and deep reflection to build, ending up being really creative and smart, but achieving the first positions in the ranks! Enjoy them! 🎉
My strategy to master a new subject has always been to tackle the hardest problems first. In my experience—from college entrance exams in Brazil to engineering coursework—this yields the best results in the shortest time.
However, finding a good solution for a hard problem is difficult. It can take weeks to solve a single puzzle. When you hit that wall, the standard process is to look for guidance: scan a solution, break it down, understand the logic, and then implement it yourself.
The Problem: I frequently faced amazing, challenging problems but couldn't find one single suggestion. No tips, no comments, just void.
I lamented this "hiding" culture. While ranks matter to some, I believe the real gold lies in understanding how to unpuzzle these intricate challenges.
This repository is my contribution to filling that void.
This isn't just a code dump. It is an educational archive.
- Documentation: I focus on problems with a difficulty level of 7 or above (scale 1-10).
- Evolution: You will see my code evolve. I include my original solutions (from when I was learning, sometimes messy) alongside AI-revised and optimized versions.
- Polyglot: While I started with JavaScript, I provide C++ and Python comparisons to match the "top league" performance standards.
You might ask: "Why solve competitive programming problems in JS?"
I know it isn’t the traditional competitive-programming weapon — C++ owns that territory.
But I was building my career in the JS ecosystem, and choosing JS for algorithmic challenges helped me sharpen:
- efficient JS data structures
- memory patterns
- dynamic optimization
- bitwise manipulation
- low-level tuning inside a high-level language
Eventually, I also implemented C++ and Python versions whenever JS hit its limits or when comparison was useful.
Finding performant public solutions for JS was incredibly rare. I struggled with that, so now I am fixing it for the next person.
To keep things organized and scalable for future platforms, the archive is structured as follows:
/
├── BeeCrowd/ # Solutions for Beecrowd (URI)
│ ├── 1023-Drought/ # Problem ID and Name
│ │ ├── README.md # Step-by-step logic explanation
│ │ ├── solution.js # Clean, commented, revised code
│ │ ├── solution.cpp # C++ version for performance comp
│ │ ├── solution_original.js # My raw, original submission
│ │ └── input_samples.txt
│ └── ...
├── CodeForces/ # (Future placeholder)
└── README.md
Every solution folder in this archive contains:
- Step-by-Step Explanation: A detailed Markdown file breaking down the logic, the algorithm used, and the history of the attempt.
- Fully Commented Code: Optimized solutions in JS, C++, and Python (where possible), including headers with rank and runtime.
- Original Solution: The accepted code I wrote years ago, untouched by AI. This serves as a baseline to show logic improvements and refactoring.
I am building this in the open, but I can't find every bug or optimization alone.
HAVE THE COURAGE TO SHARE.
If you have a better approach—a faster algorithm, a bug fix, or a cleaner syntax—don't hoard it.
- Fork this repository.
- Create a folder for a new hard problem (following the structure above) OR improve an existing one.
- Submit a Pull Request.
Let's make this the best-explained archive of hard problems on the internet, together.
All solutions are organized by their problem ID.
- 1023 - Drought
- 1034 - Ice Statues Festival
- 1053 - Continuous Drawing
- 1058 - Independent Attacking Zones
- 1141 - Growing Strings
- 1231 - Words
- 1324 - Higgs Boson
- 1346 - Child Play
- 1530 - How Many Substrings
Created with ❤️ by Rafael Molina Ogallas. Happy Coding!