DEV Community

xscoox
xscoox

Posted on

πŸš€ Day 2 of #100DaysOfCode – Mastering Binary Search in TypeScript

Hey Devs! πŸ‘‹

Today, I deep-dived into Binary Search and explored some interesting problems using TypeScript. Here's what I worked on:

πŸ” What I Learned:
βœ… Binary Search in Depth – Understanding the intuition behind it
βœ… Floor & Ceil in a Sorted Array – Using Binary Search efficiently
βœ… Recursive Approach – Improved understanding of recursion while implementing

🧩 Floor & Ceil Problem:
➑️ Floor: Largest element ≀ target
➑️ Ceil: Smallest element β‰₯ target

Image description

Image description

πŸ”₯ Key Takeaways:
➑️ Binary Search makes floor & ceil problems efficient.
➑️ Iterative & Recursive approaches both provide valuable insights.
➑️ Understanding edge cases is crucial, like when the target is smaller/larger than all elements.

I’m really enjoying this challenge so far! Next up, I plan to explore strivers DSA sheet and searching in rotated sorted arrays.

πŸ’‘ What are your thoughts on my implementation? Any improvements or alternative approaches? Let’s discuss!

Top comments (0)