AlgoMaster.io retweeted
๐๐จ๐ฐ ๐ญ๐จ ๐
๐ข๐ง๐ ๐ ๐๐ฒ๐๐ฅ๐ ๐ข๐ง ๐ ๐๐ข๐ง๐ค๐๐ ๐๐ข๐ฌ๐ญ
Use Floydโs Cycle Detection Algorithm, also known as the slow and fast pointer technique.
Start two pointers at the head:
- slow moves one step at a time
- fast moves two steps at a time
If the linked list has no cycle, fast will eventually reach the end.
If there is a cycle, fast will eventually catch up with slow inside the loop.
Why does this work?
Think of two runners on a circular track. If one runs faster than the other, they are guaranteed to meet eventually.
Time Complexity: O(n)
Space Complexity: O(1)
AlgoMaster.io retweeted
SOLID Principles Explained with Clear Examples:
๐ - ๐๐ข๐ง๐ ๐ฅ๐ ๐๐๐ฌ๐ฉ๐จ๐ง๐ฌ๐ข๐๐ข๐ฅ๐ข๐ญ๐ฒ ๐๐ซ๐ข๐ง๐๐ข๐ฉ๐ฅ๐
A class should have only one reason to change.
- Example: Instead of one giantย Userย class that handles authentication, profile updates, and sending emails, split it intoย UserAuth,ย UserProfile, andย EmailService.
๐ - ๐๐ฉ๐๐ง/๐๐ฅ๐จ๐ฌ๐๐ ๐๐ซ๐ข๐ง๐๐ข๐ฉ๐ฅ๐
Classes should be open for extension but closed for modification.
- Example: Define aย Shapeย interface with anย area()ย method. When you need a new shape, just add aย Circleย orย Triangleย class that implements it.
๐ - ๐๐ข๐ฌ๐ค๐จ๐ฏ ๐๐ฎ๐๐ฌ๐ญ๐ข๐ญ๐ฎ๐ญ๐ข๐จ๐ง ๐๐ซ๐ข๐ง๐๐ข๐ฉ๐ฅ๐
Subtypes must be substitutable for their base types without breaking behavior.
- Example: Ifย Birdย has aย fly()ย method, thenย Eagleย andย Sparrowย should both work anywhere aย Birdย is expected.
๐ - ๐๐ง๐ญ๐๐ซ๐๐๐๐ ๐๐๐ ๐ซ๐๐ ๐๐ญ๐ข๐จ๐ง ๐๐ซ๐ข๐ง๐๐ข๐ฉ๐ฅ๐
Don't force classes to implement interfaces they don't use.
- Example: Instead of one fatย Machineย interface withย print(),ย scan(), andย fax(), break it intoย Printable,ย Scannable, andย Faxable. Aย SimplePrinterย only implementsย Printable.
๐ - ๐๐๐ฉ๐๐ง๐๐๐ง๐๐ฒ ๐๐ง๐ฏ๐๐ซ๐ฌ๐ข๐จ๐ง ๐๐ซ๐ข๐ง๐๐ข๐ฉ๐ฅ๐
High-level modules should not depend on low-level modules. Both should depend on abstractions.
- Example: Yourย OrderServiceย should depend on aย PaymentGatewayย interface, not directly onย Stripeย orย PayPal.
The real power of SOLID is not in following each principle in isolation. It's in how they work together to make your code easier to change, test, and extend.
โป๏ธ Repost to help others in your network
AlgoMaster.io retweeted
If you want to get good at System Design in 1 month, learn these 30 concepts in the next 30 days:
Thread (with resources) โด
AlgoMaster.io retweeted
10 Must-Know Graph Algorithms for Coding Interviews:
1. ๐๐
๐ (๐๐๐ฉ๐ญ๐ก-๐
๐ข๐ซ๐ฌ๐ญ ๐๐๐๐ซ๐๐ก)
2. ๐๐
๐ (๐๐ซ๐๐๐๐ญ๐ก-๐
๐ข๐ซ๐ฌ๐ญ ๐๐๐๐ซ๐๐ก)
3. ๐๐จ๐ฉ๐จ๐ฅ๐จ๐ ๐ข๐๐๐ฅ ๐๐จ๐ซ๐ญ
4. ๐๐ง๐ข๐จ๐ง ๐
๐ข๐ง๐ (๐๐ข๐ฌ๐ฃ๐จ๐ข๐ง๐ญ ๐๐๐ญ)
5. ๐๐ฒ๐๐ฅ๐ ๐๐๐ญ๐๐๐ญ๐ข๐จ๐ง
6. ๐๐จ๐ง๐ง๐๐๐ญ๐๐ ๐๐จ๐ฆ๐ฉ๐จ๐ง๐๐ง๐ญ๐ฌ
7. ๐๐ข๐ฉ๐๐ซ๐ญ๐ข๐ญ๐ ๐๐ก๐๐๐ค
8. ๐
๐ฅ๐จ๐จ๐ ๐
๐ข๐ฅ๐ฅ
9. ๐๐ข๐ง๐ข๐ฆ๐ฎ๐ฆ ๐๐ฉ๐๐ง๐ง๐ข๐ง๐ ๐๐ซ๐๐
10. ๐๐ก๐จ๐ซ๐ญ๐๐ฌ๐ญ ๐๐๐ญ๐ก (Dijkstra)
โป๏ธ Repost to help others in your network
AlgoMaster.io retweeted
If you want to master Object-Oriented Programming (OOP), consider learning these 12 concepts:
1. ๐๐ฅ๐๐ฌ๐ฌ
2. ๐๐๐ฃ๐๐๐ญ
3. ๐๐ง๐ญ๐๐ซ๐๐๐๐
4. ๐๐ง๐๐๐ฉ๐ฌ๐ฎ๐ฅ๐๐ญ๐ข๐จ๐ง
5. ๐๐๐ฌ๐ญ๐ซ๐๐๐ญ๐ข๐จ๐ง
6. ๐๐ง๐ก๐๐ซ๐ข๐ญ๐๐ง๐๐
7. ๐๐จ๐ฅ๐ฒ๐ฆ๐จ๐ซ๐ฉ๐ก๐ข๐ฌ๐ฆ
8. ๐๐ฌ๐ฌ๐จ๐๐ข๐๐ญ๐ข๐จ๐ง
9. ๐๐ ๐ ๐ซ๐๐ ๐๐ญ๐ข๐จ๐ง
10. ๐๐จ๐ฆ๐ฉ๐จ๐ฌ๐ข๐ญ๐ข๐จ๐ง
11. ๐๐๐ฉ๐๐ง๐๐๐ง๐๐ฒ
12. ๐๐๐๐ฅ๐ข๐ณ๐๐ญ๐ข๐จ๐ง (๐๐ฆ๐ฉ๐ฅ๐๐ฆ๐๐ง๐ญ๐๐ญ๐ข๐จ๐ง)
Which other OOP concept would you add to this list?
โป๏ธ Repost to help others learn this
AlgoMaster.io retweeted
15 Blogs to Learn 15 Most Common Design Patterns:
1. Singleton: algomaster.io/learn/lld/singโฆ
2. Factory Method: algomaster.io/learn/lld/factโฆ
3. Abstract Factory: algomaster.io/learn/lld/abstโฆ
4. Builder: algomaster.io/learn/lld/builโฆ
5. Adapter: algomaster.io/learn/lld/adapโฆ
6. Facade: algomaster.io/learn/lld/facaโฆ
7. Decorator: algomaster.io/learn/lld/decoโฆ
8. Composite: algomaster.io/learn/lld/compโฆ
9. Proxy: algomaster.io/learn/lld/proxโฆ
10. Iterator: algomaster.io/learn/lld/iterโฆ
11. Observer: algomaster.io/learn/lld/obseโฆ
12. Strategy: algomaster.io/learn/lld/straโฆ
13. Command: algomaster.io/learn/lld/commโฆ
14. State: algomaster.io/learn/lld/statโฆ
15. Template Method: algomaster.io/learn/lld/tempโฆ
โป๏ธ Repost to help others in your network








