Day 26 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Convert Binary to Octal We were given a binary number. Task was to convert it into octal. Octal uses base 8. And 1 octal digit = 3 binary bits. So the key idea is simple. Group the binary digits in sets of three. Example: Binary → 101110 Group into 3 bits: 101 | 110 Convert each group: 101 → 5 110 → 6 Octal = 56 💻 Approach 🔹️Take the binary string. 🔹️Check its length. 🔹️If length is not multiple of 3, add leading zeros. 🔹️Traverse the string in groups of 3 bits. 🔹️Convert each group using positional values (4, 2, 1). 🔹️Append the result to the final answer. Simple grouping logic. 📊 Complexity Analysis Time Complexity: O(n) Each bit is processed once. Space Complexity: O(n) Output string depends on input size. 📚 What I learned today: ▫️Binary can be converted easily using bit grouping. ▫️3 binary bits directly map to 1 octal digit. ▫️Padding zeros does not change the value. ▫️Understanding number system relationships simplifies conversions. Day 26 completed. Number system concepts getting clearer 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic
Binary to Octal Conversion Challenge Completed
More Relevant Posts
-
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
To view or add a comment, sign in
-
Day 37 : Practicing Backtracking on LeetCode 💡 Today’s live practical session in Alpha Plus 7.0 was all about execution. We took the theory of Backtracking and applied it directly to solve problems on LeetCode. Today’s Checklist: ✅ Backtracking Execution: Reinforced the core logic of exploring all possible combinations and retreating when necessary. ✅ Phone Keypad Problem: Successfully solved the classic "Letter Combinations of a Phone Number" problem on LeetCode. ✅ Mapping Logic: Mastered how to map numeric digits to character arrays and recursively generate every single valid string combination. #Backtracking #LeetCode #DSA #Algorithms #SoftwareEngineering #100DaysOfCode #ApnaCollege
To view or add a comment, sign in
-
-
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 5/100 — LeetCode Challenge Today's problem: Container With Most Water 🧠 Concept: Two Pointers 💡 Key Idea: Start with two pointers at the ends of the array and calculate the container area using the smaller height. Move the pointer with the smaller height to explore potentially larger areas. ⚡ Time Complexity: O(n) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ Interesting to see how a simple two-pointer strategy can turn a brute-force O(n²) solution into an efficient O(n) approach. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Day 58 of #100DaysOfCode Today, I solved LeetCode 2840 – Check if Strings Can be Made Equal With Operations II, a problem that builds upon string manipulation and constraint-based transformations. 💡 Problem Overview: Given two strings, the objective is to determine whether they can be made equal using a defined set of swap operations. The challenge lies in understanding which positions can influence each other. 🧠 Approach: To efficiently solve this problem, I focused on: ✔️ Identifying independent index groups based on allowed operations ✔️ Separating characters into even and odd indexed groups ✔️ Comparing sorted/grouped characters from both strings This ensures correctness while maintaining optimal performance. ⚡ Key Takeaways: Identifying independent groups simplifies complex transformations Sorting/grouping techniques are effective for comparison problems Understanding constraints leads directly to optimal solutions 📊 Complexity Analysis: Time Complexity: O(n log n) Space Complexity: O(n) Small improvements every day lead to significant growth over time 🚀 #LeetCode #100DaysOfCode #DSA #Strings #ProblemSolving #CodingJourney #SoftwareDevelopment
To view or add a comment, sign in
-
-
🚀 Day 6/100 — LeetCode Challenge Today's problem: 3Sum 🧠 Concept: Sorting + Two Pointers 💡 Key Idea: After sorting the array, fix one element and use two pointers to find the remaining pair that sums to the target while avoiding duplicate triplets. ⚡ Time Complexity: O(n²) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ This problem was a great exercise in combining multiple techniques to reduce brute-force complexity. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
Day 28 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Convert Numbers to Words We were given a number. Task was to convert it into words. Example: 123 → One Hundred Twenty Three This problem was more about mapping. And understanding place values. 💻 Approach 🔹️Create mappings for digits 0–9. 🔹️Create mappings for 10–19 (special cases). 🔹️Create mappings for tens like 20, 30, 40... 🔹️Also store place values like hundred and thousand. Then process the number step by step. 🔹️Traverse the number from left to right. 🔹️If more than two digits remain, handle place values. 🔹️If two digits remain and first digit is 1, use teen mapping. 🔹️Otherwise print tens and units separately. Continue until all digits are processed. 📊 Complexity Analysis Time Complexity: O(n) Each digit is processed once. Space Complexity: O(1) Only fixed mapping arrays are used. 📚 What I learned today: ▫️This problem is essentially a lookup + formatting problem using constant mapping tables. ▫️Handling special ranges (10–19) separately avoids incorrect word formation. ▫️Breaking the number into place-value segments (hundreds, tens, units) simplifies logic. ▫️Designing clean mapping structures is important for problems involving symbolic representation. Day 28 completed. Learning different problem patterns every day 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 12/100 — LeetCode Challenge Today's problem: Next Greater Element I 🧠 Concept: Monotonic Stack + HashMap 💡 Key Idea: Use a monotonic decreasing stack to find the next greater element for each number and store the result in a map for quick lookup. ⚡ Time Complexity: O(n) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ Reinforcing the monotonic stack pattern and understanding how it helps solve “next greater” problems efficiently. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Day 10/100 — LeetCode Challenge Solved 3Sum The brute force approach is simple: Try all triplets → O(n³) But that’s not scalable. 💡 Optimized Approach: 1) First, sort the array 2) Fix one element 3) Use two pointers to find the remaining pair 👉 This reduces the complexity significantly. Also handled duplicates carefully to avoid repeated triplets. 🧠 Time Complexity: O(n²) 💾 Space Complexity: O(1) (ignoring output) 💡 What I learned: Sometimes optimization is not about complex logic, but about: 1) Sorting 2) Using patterns like two pointers 3) Eliminating unnecessary work This problem felt like a step up from previous ones. Staying consistent. #LeetCode #DSA #100DaysOfCode #Cpp #TwoPointers #CodingJourney
To view or add a comment, sign in
-
-
Day 38 of my #50DaysOfCode challenge is done ✅ 📌 Problem Solved Print Bracket Number We were given a string str. It contains brackets. Task was to assign a number to each bracket. Each pair gets the same number. Based on order of opening. Let’s understand it simply. ◾️Imagine you are assigning IDs to tasks. ◾️Every time a new task starts, you give it a new ID. ◾️When that task ends, it keeps the same ID. ◾️Multiple tasks can be nested. ◾️But each one has its own number. That’s exactly how brackets behave. 💻 Approach (Using Stack) 🔹️Create an empty stack. 🔹️Initialize a counter = 0. 🔹️Traverse the string. 🔹️If opening bracket: ▪️Increase counter ▪️Push it into stack ▪️Print the counter 🔹️If closing bracket: ▪️Take top value from stack ▪️Print it ▪️Pop from stack Each pair gets same number. 📊 Complexity Analysis Time Complexity: O(n) Space Complexity: O(n) 📚 What I learned today: ▫️Stack helps in tracking nested structures. ▫️Assigning IDs during traversal simplifies pairing logic. ▫️LIFO nature perfectly matches bracket problems. ▫️Nested patterns are easier with stack-based thinking. Day 38 completed. Stack understanding getting stronger 🚀 #50DaysOfCode #CodingChallenge #Consistency #LearningInPublic
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