Day 27 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Convert Octal to Binary We were given an octal number. Task was to convert it into binary. Instead of converting directly, we used a two-step process. First → Octal to Decimal. Then → Decimal to Binary. 💻 Approach Step 1: Octal to Decimal 🔹️Take each digit of the octal number. 🔹️Multiply it with (8^i). 🔹️Increase power (i) as we move left. 🔹️Add all values to get decimal number. Step 2: Decimal to Binary 🔹️Divide the decimal number by 2 repeatedly. 🔹️Store the remainders. 🔹️Continue until the number becomes 0. 🔹️Read the remainders in reverse order. That gives the binary number. 📊 Complexity Analysis Time Complexity: O(log n) Space Complexity: O(1) Only a few variables are used. 📚 What I learned today: ▫️Number system conversions can be chained. ▫️Octal to decimal uses powers of 8. ▫️Binary conversion uses repeated division by 2. ▫️Breaking the problem into steps makes it easier. Day 27 completed. Practicing number system conversions 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic
Octal to Binary Conversion Challenge Solved
More Relevant Posts
-
Day 8 / 100 Days of Code Challenge 💻🔥 Solved LeetCode 160 — Intersection of Two Linked Lists 🔗 🔍 Problem • Given two singly linked lists, find the node where they intersect • If no intersection exists, return null ⚙️ Approach (Two Pointer Switching) • Use two pointers starting at headA and headB • Traverse both lists simultaneously • When a pointer reaches the end, redirect it to the other list’s head 🔄 • Continue until both pointers meet • The meeting point is the intersection node (or null if no intersection) 💡 Key Learning • Equalizing path lengths without explicitly calculating them • Efficient pointer manipulation technique • Clean and optimal solution without extra space ⏱ Complexity • Time: O(n + m) ⏳ • Space: O(1) 📦 Consistency continues 🚀 #100DaysOfCode #LeetCode #DSA #LinkedList #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Day 41 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Remove Nth Node from End of Linked List We were given a linked list. And a value n. Task was to remove the nth node from the end. Let’s understand it simply. ◾️Imagine a line of people. ◾️You are told to remove the 2nd person from the end. ◾️You don’t know the length directly. ◾️So you need a smart way to reach that position. That’s the challenge. 💻 Approach (Two Pointers) 🔹️Take two pointers: fast and slow. 🔹️Move fast pointer n steps ahead. 🔹️Then move both fast and slow together. 🔹️When fast reaches end, slow is before target node. 🔹️Remove the node by updating links. Only one traversal needed. 📊 Complexity Analysis Time Complexity: O(n) Space Complexity: O(1) 📚 What I learned today: ▫️Two-pointer technique helps in single pass solutions. ▫️Maintaining gap between pointers is important. ▫️Linked list problems need careful pointer updates. ▫️Edge cases like deleting head must be handled. Day 41 completed. Linked list concepts getting stronger 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 6/100 — LeetCode Challenge Solved LeetCode 704: Binary Search Simple problem, but it tests your understanding of the basics. 💡 Approach: 1) Use two pointers: low and high 2) Find mid element 3) Compare with target and eliminate half of the search space 👉 Repeat until target is found or search space becomes empty. What I realized: Binary Search is not just about the idea, but about handling boundaries correctly (low <= high, mid calculation, etc.) 🧠 Time Complexity: O(log n) 💾 Space Complexity: O(1) Sometimes mastering the basics is more important than jumping to advanced problems. Back to consistency 💪 #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #CodingJourney
To view or add a comment, sign in
-
🚀 Day 45/100 – LeetCode Challenge 🔗 Problem: Linked List Components (LeetCode 817) 💡 Difficulty: Medium Today’s problem was all about understanding connected components in a linked list using a smart approach. 🧠 Key Insight: Instead of checking every possible combination, I used a HashSet for quick lookups. A component is counted only when a sequence ends, i.e., when the current node is in nums but the next node is not. ⚡ Approach: Convert nums into a set for O(1) lookup Traverse the linked list Count only when a component ends 📈 Time Complexity: O(n) 📦 Space Complexity: O(n) ✨ What I learned: Sometimes, solving problems efficiently is about identifying where something ends rather than where it starts. Consistency is key 🔥 Halfway through the journey — staying committed! #Day45 #100DaysOfCode #LeetCode #DataStructures #LinkedList #CodingJourney #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 5/100 — LeetCode Challenge Solved Search in Rotated Sorted Array This problem looks like a normal binary search at first, but the rotation makes it tricky. 💡 Key idea: 1) At every step, one half of the array is always sorted 2) Identify the sorted half 3) Check if the target lies in that range 4) Narrow down the search space accordingly It’s all about modifying binary search with the right conditions. 🧠 Time Complexity: O(log n) 💾 Space Complexity: O(1) ⚠️ Couldn’t record the video today due to some issues, but didn’t want to break the consistency. Will be back with better content tomorrow. Consistency > perfection. #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #CodingJourney
To view or add a comment, sign in
-
-
🚀 Turning TLE into an Optimized Approach! Solved LeetCode 448: Find All Numbers Disappeared in an Array today 👉 Initially tried a brute force approach, but it resulted in TLE ⛔ That pushed me to rethink and optimize my solution. 💡 Final Approach: Used a frequency table (Counting Sort concept) to track occurrences of elements efficiently. 🔍 Key Learnings: Brute force helps build intuition, but optimization is key Frequency arrays can significantly reduce time complexity 💻 Approach Summary: Count frequency of each number (1 to n) Traverse the frequency array to find missing numbers Every TLE is a lesson in disguise — pushing us towards better solutions #LeetCode #DSA #ProblemSolving #CodingJourney #Optimization #CPlusPlus #KeepLearning
To view or add a comment, sign in
-
-
🚀 Day 11 of Solve With Me ⚡ Today’s problem: Third Maximum Number (LeetCode 414) 💻 The task is to find the third distinct maximum number in an array. If the third maximum does not exist, return the maximum number. 🔹 Approach Instead of sorting the array, we track the top three distinct maximum numbers while iterating. Idea: Maintain three variables → max1, max2, max3 Update them while traversing the array. Shift values when a new larger number appears. Ignore duplicates. If max3 doesn't exist, return max1. 🔹 Example Input: [2,2,3,1] Distinct numbers → 3, 2, 1 Third maximum → 1 Input: [1,2] No third maximum → return 2 ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) #leetcode #problemsolving #dsa #day11 #codingpractice 🚀
To view or add a comment, sign in
-
-
🚀 Day 3/100 — LeetCode Challenge I thought this needed nested loops at first. Turns out, it doesn’t. Solved LeetCode 53: Maximum Subarray My first instinct was to check all subarrays (O(n²)), but that’s inefficient. Then I came across a much cleaner idea: 👉 Instead of checking everything, just keep track of the current sum 1) If the current sum becomes negative → reset it to 0. 2) Keep updating the maximum sum along the way. This approach (Kadane’s Algorithm) makes the solution much more efficient. 💡 What I learned: You don’t always need to explore all possibilities — sometimes dropping bad states early leads to the optimal solution. 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) Small problem, but a very powerful pattern. #LeetCode #DSA #100DaysOfCode #Cpp #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
🚀 Day 20/100 – LeetCode Challenge ✅ Problem Solved: Single Number II Today’s problem pushed me to think beyond basic approaches and dive deeper into bit manipulation. The challenge was to find the element that appears only once while every other element appears three times. Instead of using extra memory, I used a clever bitwise technique to track counts using two variables. This approach efficiently filters out elements appearing three times and keeps only the unique one. 💡 Key Learning: Bit manipulation can replace counting mechanisms Tracking states using bits is a powerful technique Optimized solutions often avoid extra space completely ⚡ Complexity: Time: O(n) Space: O(1) Day by day, building stronger problem-solving skills and consistency 💪 #Day20 #100DaysOfCode #LeetCode #DSA #Cpp #CodingJourney #ProblemSolving #BitManipulation
To view or add a comment, sign in
-
-
Day 78/100 – #100DaysOfLeetCode 🚀 🧩 Problem: LeetCode 141 – Linked List Cycle (Easy) 🧠 Approach: Use Floyd’s Cycle Detection (Tortoise & Hare). Move one pointer one step and another two steps. If they meet, a cycle exists. 💻 Solution: # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def hasCycle(self, head: Optional[ListNode]) -> bool: slow = head fast = head while fast and fast.next: slow = slow.next fast = fast.next.next if slow == fast: return True return False ⏱ Time | Space: O(n) | O(1) 📌 Key Takeaway: Using two pointers at different speeds is an efficient way to detect cycles without extra space. #leetcode #dsa #development #problemSolving #CodingChallenge
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