🚀 Day 42/150 of hashtag#150DaysOfDSA 📌 Task: Binary Search Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. You must write an algorithm with O(log n) runtime complexity. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
Binary Search in Sorted Array with O(log n) Complexity
More Relevant Posts
-
🚀 Day 43/150 of hashtag#150DaysOfDSA 📌 Task: Find First and Last Position of Element in Sorted Array Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 34/150 of hashtag#150DaysOfDSA 📌 Task: Search Insert Position Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 49/150 of hashtag#150DaysOfDSA 📌 Task: Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 32/150 of hashtag#150DaysOfDSA 📌 Task: Plus One You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's. Increment the large integer by one and return the resulting array of digits. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 33/150 of hashtag#150DaysOfDSA 📌 Task: Sqrt(x) Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
53 🚀 Day 53/150 of hashtag#150DaysOfDSA 📌 Task: Non-decreasing Array Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. An array is non-decreasing if nums[i] ≤ nums[i + 1] holds for every i (0-based) such that 0 ≤ i ≤ n - 2. #150DaysOfCode #DSA #CPP #Algorithms #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
I know problems confusing at first — understanding the approach, the code, and why one solution is better than another isn’t always easy. So I created a simple and easy-to-follow document that breaks everything down step by step 👇 ✔️ Why brute force is not efficient ✔️ How optimization thinking works ✔️ When and why HashMap becomes the best solution ✔️ Everything explained in just a few pages No overcomplication — just clear intuition and practical understanding. Give it a quick read once 👇 📄 #DSA #LeetCode #Algorithms #CodingMadeSimple #SoftwareEngineering #LearningJourney
To view or add a comment, sign in
-
🔥Day 114 of Problem Solving (Hashed Key) ✅Group Anagrams (https://lnkd.in/gfTPavkf) > We need a way to identify all anagrams with the same signature. A sorted version of the string works as a canonical key. A more optimized key is the 26-length frequency array, which reduces sorting cost and gives linear processing per word. #DSA #HashMap #Strings #Algorithms #DataStructures #ProblemSolving #100DaysOfCode #SoftwareEngineering #CodingJourney
To view or add a comment, sign in
-
-
Day 5/150 — Neetcode Journey 🚀 Solved: Evaluate Reverse Polish Notation, Binary Search, Search a 2D Matrix 💡 Key Insight: Binary Search isn’t just for 1D arrays — it can be extended to problems like 2D matrices with proper indexing logic ⚠️ Challenge: Understanding how to map 2D problems into a format where binary search can be applied efficiently 🧠 What I learned: 1. Stack is useful for expression evaluation (like Reverse Polish Notation) 2. Binary Search is more versatile than it first seems 3. Many problems become easier when you change how you view the data Slowly building problem-solving intuition. #DataStructures #Algorithms #CodingJourney #DSA #LearningInPublic
To view or add a comment, sign in
-
-- Solved: Maximum Depth of Binary Tree (LeetCode 104) -- Problem: Given the root of a binary tree, return its maximum depth — the number of nodes along the longest path from the root to a leaf. -- Approach (Recursive DFS): - The idea is simple but powerful: > If the node is NULL → depth is 0 > Recursively compute the depth of left and right subtrees > Return: 1 + max(leftDepth, rightDepth) > This works because at every node, we are asking: “What is the longest path going down from here?” -- Complexity: Time: O(n) Space: O(h) #DSA #LeetCode #Recursion #BinaryTree #ProblemSolving #CodingJourney #algorithm
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development