✅ Day 98 of 100 Days LeetCode Challenge Problem: 🔹 #338 – Counting Bits 🔗 https://lnkd.in/gXdNxX66 Learning Journey: 🔹 Today’s problem focused on counting the number of 1s in the binary representation of numbers from 0 to n. 🔹 I initialized an array ans of size n+1. 🔹 For each number i, I converted it to binary using bin(i)[2:]. 🔹 Counted the number of '1' bits by iterating through the binary string. 🔹 Stored the count in ans[i] and returned the final array. Concepts Used: 🔹 Bit Manipulation (Binary Representation) 🔹 Array Traversal 🔹 String Processing 🔹 Brute Force Approach Key Insight: 🔹 Each number’s bit count can be computed independently. 🔹 Converting to binary and counting '1' works, but can be optimized further using DP or bit tricks. Complexity: 🔹 Time: O(n log n) (binary conversion for each number) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #100DaysOfCode #Python #CodingJourney #ProblemSolving #LearningInPublic
Counting Bits in Binary Representation
More Relevant Posts
-
Built a Rainfall Prediction model and deployed it live. Here is what actually happened behind the scenes Decision Tree gave me 100% training accuracy. I got excited. Then I checked the test score and realised the model had just memorised the data. It learned nothing real. Naive Bayes gave me 73.9% on both train and test. Consistent That is the one I deployed. 3 models trained. 1 deployed. 1 lesson — a consistent score beats a perfect score every time live app here: https://lnkd.in/d-xaufug Full project and code: https://lnkd.in/d_d2Tx7R Akarsh Vyas Tanishq Vyas #DataScience #MachineLearning #Python #Streamlit #BuildInPublic #MLProject
To view or add a comment, sign in
-
Days 68-69 of the #three90challenge 📊 Today I explored NumPy operations — specifically indexing and slicing arrays. After understanding NumPy basics, this step made it easier to access and manipulate data efficiently. What I practiced today: • Accessing elements using indexing • Extracting subsets of data using slicing • Working with multi-dimensional arrays • Performing operations on selected data Example thinking: Instead of looping through data manually, I can directly select and operate on specific parts of an array. Example: import numpy as np arr = np.array([10, 20, 30, 40, 50]) print(arr[1:4]) # Output: [20 30 40] This makes data manipulation faster and more intuitive. From handling data → to controlling it efficiently 🚀 GeeksforGeeks #three90challenge #commitwithgfg #Python #NumPy #DataAnalytics #LearningInPublic #Consistency #Upskilling
To view or add a comment, sign in
-
🚀 Day 39/60 — LeetCode Discipline Problem Solved: Sqrt(x) Difficulty: Easy Today’s challenge was to compute the square root of a number without using built-in functions. Instead of brute force, I used Binary Search — a classic, elegant approach that narrows down the answer efficiently. 💡 Key Learnings: • Binary Search application beyond arrays • Handling edge cases (x < 2) • Avoiding overflow using conditions carefully • Finding floor value of square root • Optimized thinking over brute force ⚡ Performance: Runtime: 4 ms Like walking in a foggy path, I didn’t see the answer directly… But step by step— cutting the search space in half— the truth revealed itself. That’s the beauty of algorithms. #LeetCode #60DaysOfCode #DSA #BinarySearch #ProblemSolving #CodingJourney #Python #Consistency #TechGrowth
To view or add a comment, sign in
-
-
🚀 Solved a great problem today: “Consecutive 1’s Not Allowed” At first glance, it looked like a simple binary string problem… but it quickly turned into a lesson in pattern recognition and dynamic thinking. 📌 What the problem was about: Count all binary strings of length n such that no two 1’s are consecutive. 💡 What I learned: Instead of brute forcing all combinations (which would be exponential), the key was to observe a pattern: If a string ends with 0 → we can add 0 or 1 If it ends with 1 → we can only add 0 This leads to a recurrence: 👉 dp[n] = dp[n-1] + dp[n-2] Which is basically the Fibonacci pattern in disguise. 🧠 Big takeaway: Many problems are not about coding harder… they’re about seeing the hidden pattern behind the problem. This was a reminder that: Brute force is rarely the answer Thinking in terms of state transitions is powerful Optimization often comes from observation, not syntax 📷 Sharing my solution screenshot below 👇 #DataStructures #DynamicProgramming #ProblemSolving #Python #LearningInPublic #DataAnalyticsJourney
To view or add a comment, sign in
-
-
✅ Day 95 of 100 Days LeetCode Challenge Problem: 🔹 #869 – Reordered Power of 2 🔗 https://lnkd.in/gkNXaSFM Learning Journey: 🔹 Today’s problem focused on checking whether the digits of a number can be rearranged to form a power of 2. 🔹 I created a helper function to extract and store the digits of a number. 🔹 Then I sorted the digits of the input number for comparison. 🔹 Next, I generated powers of 2 iteratively and compared their sorted digit lists with the input. 🔹 If any match was found, I returned True. Otherwise, continued until the digit length exceeded the input. Concepts Used: 🔹 Digit Extraction 🔹 Sorting 🔹 Simulation of Powers of 2 🔹 Brute Force Optimization Key Insight: 🔹 Instead of generating permutations (which is expensive), sorting digits allows quick comparison. 🔹 Any valid rearrangement must have the same digit frequency as some power of 2. Complexity: 🔹 Time: O(log n * d log d) 🔹 Space: O(d) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
A plain LLM call says: "The answer to 6 × 7 is 42." An agent calls multiply(6, 7), gets 42, then says: "The answer is 42." One returns text. The other runs code. We put together langgraph-zero-to-agent at Theseus AI Lab. Free, open source, 4 modules. Python basics is all you need to start. Module 1: you wire the graph by hand. Every node, every edge, every tool binding. Module 2: same agent, rebuilt with create_agent(). You see what abstraction actually buys you. Module 3: a coding assistant with a local shell. It writes Python files and runs them on your machine. Module 4: OpenAI Responses API. Web search, code interpreter, reasoning built in. 🔗 https://lnkd.in/dpgwyqq8 #LangGraph #AIAgents #Python #OpenSource
To view or add a comment, sign in
-
-
Most RAG pipelines fail before they ship. Not because of the model. Because of the retrieval. I fixed the following in production: → Hybrid search with BM25 → Added metadata filters → Chunked documents by section → Reranked top results Latency dropped significantly. Groundedness improved substantially. The model was not the issue. The pipeline was the problem. Save this if you are building RAG. #RAG #AIEngineering #LLM #Python #BuildInPublic
To view or add a comment, sign in
-
-
✅ Day 92 of 100 Days LeetCode Challenge Problem: 🔹 #2011 – Final Value of Variable After Performing Operations 🔗 https://lnkd.in/gX-JQNUJ Learning Journey: 🔹 Today’s problem was about evaluating a sequence of increment and decrement operations. 🔹 I initialized a variable ans = 0 to track the value. 🔹 Used a hashmap to map each operation to its effect: • "++X" and "X++" → +1 • "--X" and "X--" → -1 🔹 Iterated through the operations and updated ans accordingly. 🔹 Returned the final computed value. Concepts Used: 🔹 HashMap / Dictionary 🔹 String Matching 🔹 Simple Simulation Key Insight: 🔹 Instead of using multiple condition checks, mapping operations to values simplifies logic and improves readability. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
🗓 7 April 2026 LeetCode Problem #128 – Longest Consecutive Sequence Solved the problem of finding the longest consecutive sequence in an unsorted array. Key insight: use a set for O(1) lookups and only start counting sequences from numbers that are the beginning of a sequence. Takeaways: - Using the right data structure reduces time complexity from O(n²) to O(n). - Avoid redundant work while scanning arrays. - Handle edge cases like empty or single-element arrays efficiently. This problem reinforces how a smart approach beats brute force every time! #LeetCode #Algorithms #Python #DataStructures #ProblemSolving #Coding #TechLearning
To view or add a comment, sign in
-
-
Day 118 Backtracking patterns are repeating — and getting clearer. #Day118 🧩 39. Combination Sum How today went: • Used index i to control choices • Two options at each step: → stay at i (reuse same element) → move to i + 1 (try next element) • Track current total • If total == target → store result • If total > target → backtrack What clicked: It’s all about: → controlling index → tracking total → backtracking at the right time Same pattern, more confidence. #LeetCode #DSA #Python #Backtracking #Recursion #LearningInPublic #Consistency
To view or add a comment, sign in
-
Explore related topics
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