I know, I know, but hear me out…
Many leetcode problems ask for changes to arrays or linked lists to be made in place. In the real world, I would strongly prefer to work with immutable arrays or linked lists and use pure functions to return the new desired result. I would object during code review if someone had the ability to do it this way and modified it in place instead.
In a coding round, you’re expected to write the code perfectly, think through all the edge cases, and “test” it manually by stepping through the code against some test cases to see if it works. In the real world, I would do TDD and simply rely on my test runner to tell me if my code works or not and where it fails. It’s less cognitive effort, less error-prone, and gets to the desired end result faster than trying to “test” it manually.
Why does leetcode require proficiency in these two things that are generally poor real world practices? Has anyone tried simply stating this in a coding interview? Did you get any credit for doing so?
I ask because I can solve most leetcode questions, and I can generally get to the optimal solution, but I can solve them SO much faster when I run the test suite and make the necessary changes based on the failing test cases, as opposed to trying to get it perfect before submitting. And I can do a lot more of them this way because it’s less mentally taxing. Which is what should be valued in the real world.
10+ YOE / $250k
Want to see the real deal?
More inside scoop? View in App
More inside scoop? View in App
blind
SUPPORT
FOLLOW US
DOWNLOAD THE APP:
FOLLOWING
Industries
Job Groups
- Software Engineering
- Product Management
- Information Technology
- Data Science & Analytics
- Management Consulting
- Hardware Engineering
- Design
- Sales
- Security
- Investment Banking & Sell Side
- Marketing
- Private Equity & Buy Side
- Corporate Finance
- Supply Chain
- Business Development
- Human Resources
- Operations
- Legal
- Admin
- Customer Service
- Communications
Return to Office
Work From Home
COVID-19
Layoffs
Investments & Money
Work Visa
Housing
Referrals
Job Openings
Startups
Office Life
Mental Health
HR Issues
Blockchain & Crypto
Fitness & Nutrition
Health Care & Insurance
Travel
Tax
Hobbies & Entertainment
Working Parents
Food & Dining
IPO
Side Jobs
Show more
SUPPORT
FOLLOW US
DOWNLOAD THE APP:
comments
It’s awful.
You’re expected to do it perfectly because some other kid has solved 500 LC problems and he solved it perfectly
It’s not meant to test anything remotely related to the real world, it’s meant to filter out people that haven’t solved LC problems
You can rely on the test runner, but still have to come up with test cases.
Writing error less code at once is a lot less time consuming than writing one line at once, compiling and debugging and writing another line
Also, these leetcode tests don't only test your knowledge and coding skills but also how smart you are. Your cognitive skills.
Taking 10 pointers simultaneously in mind and designing an approach is not a kids play.
I also didn’t mean to suggest writing one line of code at a time. I meant writing a solution that’s 80% accurate and then letting the tests catch the 2-3 issues in order to focus efforts on fixing the issues rather than finding the issues. At least, that’s how I do TDD at my day job 🤷♂️.
I find significant improvement in productivity if I think of whole approach and test cases and then start write code.
And trusting myself rather than relying on compiler. Sure may be alot more focused work but gets things done in lot less time for sure.
Immutable vs. mutable is hard because of all the code that has been written that’s mutable, plus garbage collection concerns.