🚀 Day 17 of #100DaysOfCode Solved the Concatenation of Consecutive Binary Numbers problem today using Bit Manipulation + Modulo Arithmetic in Java. Instead of converting numbers to binary strings, we shift the current result left by the number of bits in i and add i. We increase the bit count only when i is a power of 2 using: (i & (i - 1)) == 0 #Java #DSA #BitManipulation #LeetCode #CodingJourney #PlacementPrep
Java Bit Manipulation Solution for Concatenation of Consecutive Binary Numbers
More Relevant Posts
-
Day 56 of #100DaysOfLeetCode 💻✅ Solved #205. Isomorphic Strings problem in Java. Approach: • Used two arrays to track character mappings for both strings • Traversed both strings simultaneously • Checked if the mapping values at current characters are equal • If not equal, returned false (mapping mismatch) • Updated both arrays with the current index + 1 • This ensures consistent one-to-one mapping between characters Performance: ✓ Runtime: 8 ms (Beats 72.19% submissions) ✓ Memory: 44.16 MB (Beats 22.15% submissions) Key Learning: ✓ Learned how to maintain mapping consistency between two strings ✓ Practiced using arrays for character indexing ✓ Strengthened understanding of string pattern matching problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 36 of #100DaysOfLeetCode 💻✅ Solved #111. Minimum Depth of Binary Tree on LeetCode using Java. Approach: • Used recursive approach to calculate minimum depth • Returned 0 when root is null (base case) • If one subtree is null, avoided taking minimum of 0 (handled edge case carefully) • Returned 1 + minimum depth of valid subtree • Ensured correct handling of skewed trees Performance: ✓ Runtime: 6 ms ✓ Memory: 82.20 MB Key Learning: ✓ Understood difference between minimum depth and maximum depth logic ✓ Learned importance of handling null subtree cases correctly ✓ Improved confidence in solving binary tree recursion problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinaryTree #Recursion #TreeProblems #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 34 of #100DaysOfLeetCode 💻✅ Solved #110. Balanced Binary Tree on LeetCode using Java. Approach: • Used a bottom-up recursive approach to calculate height • Returned -1 immediately if any subtree is unbalanced • Compared left and right subtree heights at each node • Checked if the height difference is greater than 1 • Stopped early to optimize unnecessary computations Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) ✓ Memory: 45.33 MB (Beats 95.41% submissions) Key Learning: ✓ Understood how to combine height calculation with balance checking ✓ Learned early termination technique in recursion ✓ Improved problem-solving for tree-based recursive problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinaryTree #Recursion #TreeProblems #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 34/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 709. To Lower Case Used ASCII manipulation to convert uppercase letters to lowercase by adding 32, without using built-in functions. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) Strengthening understanding of character encoding and string manipulation basics. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
One smart swap can completely change a string. Day 53 of 100 Days DSA Today’s problem was to find the lexicographically largest string possible with at most one swap. The key idea was tracking the largest character on the right side of every position and performing the first swap that increases the string order. A simple observation leads to an efficient O(n) solution. #100DaysOfCode #DSA #Java #CodingJourney #ProblemSolving #AMU #AligarhMuslimUniversity
To view or add a comment, sign in
-
-
Day 51 of #100DaysOfLeetCode 💻✅ Solved #217. Contains Duplicate problem in Java. Approach: • Sorted the array using Arrays.sort() • Traversed the array starting from index 1 • Compared each element with its previous element • If any two adjacent elements are equal, returned true • If no duplicates are found, returned false Performance: ✓ Runtime: 24 ms (Beats 26.49% submissions) ✓ Memory: 76.56 MB (Beats 96.73% submissions) Key Learning: ✓ Practiced sorting-based approach for detecting duplicates ✓ Learned how sorting helps bring duplicate elements together ✓ Strengthened understanding of array traversal techniques Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 41/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 3427. Sum of Variable Length Subarrays Used a nested loop approach to calculate subarray sums for each index by dynamically determining the starting point using max(0, i - nums[i]). ⏱️ Time Complexity: O(n²) 📦 Space Complexity: O(1) Strengthening understanding of subarray problems and index-based range calculations. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
#Today I practiced a fundamental Data Structures concept — Subarrays using Java. #A Subarray is a continuous part of an array. It means the elements must appear next to each other in the original order Example Array [1, 2,3,4 5] #First loop (i) → Starting index of subarray #Second loop (j) → Ending index of subarray #Third loop (k) → Prints elements between start and end
To view or add a comment, sign in
-
-
🚀 Day 39/100 Today’s problem: Reverse String II 🔹 Worked on reversing characters in a string based on a given value k🔹 Used char[] and two-pointer approach for efficient swapping 💡 What I Learned:✔ How to handle string manipulation using arrays in Java✔ Importance of index control while working with loops✔ How to solve problems step-by-step instead of reversing the whole string directly✔ Improved logic building for partial reversal problems 💡 Key Insight:Instead of reversing the entire string, we reverse only specific parts (every 2k characters), which requires careful indexing. Consistency is slowly turning into confidence 💪 #Day39 #Java #DSA #CodingJourney #LeetCode #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 45 of #100DaysOfLeetCode 💻✅ Solved Simple #268. Missing Number problem in Java. Approach: • Calculated the expected sum of numbers from 0 to n using the formula n(n+1)/2 • Traversed the array and calculated the actual sum of the elements • Subtracted the actual sum from the expected sum • The difference gives the missing number in the array Performance: ✓ Runtime: 0 ms (Beats 100% submissions) 🚀 ✓ Memory: 47.60 MB (Beats 29.84% submissions) Key Learning: ✓ Practiced using mathematical formulas to simplify problems ✓ Learned how sum comparison can help find a missing element efficiently ✓ Strengthened problem-solving skills with arrays Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
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