Top voted solution uses bit manipulation: changes cell to 2 (binary: 10) or 3 (binary:11) to represent 0 or 1 in the next state. Then recover the true value by doing bitwise right shift by 1 (>>1).
But why is that necessary?
Why not recover it by %2? (2%2 = 0(dead), and 3%2=1(alive)).
And even simpler, change cell to 'AliveToDead' or 'DeadToAlive', and recover it by using if statements on those 2 strings!
None of them is slower than bitwise manipluation.
What am I missing? Is the top voted solution unnecessarily complex without benefits?
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
Travel
Health Care & Insurance
Tax
Hobbies & Entertainment
Working Parents
Food & Dining
IPO
Side Jobs
Show more
SUPPORT
FOLLOW US
DOWNLOAD THE APP:
comments
The thing about leetcode is that some best rated solution won’t give you best performance, even they have a better big O.
Best rated solutions are often concise, short, use less variables, simpler data structures etc. that’s a great way you show your interviewer that you are ACM qualified - where only coding speed matters.
If you show these kind of tricks, I am pretty sure you can come up “normal” solutions very fast.