✅ Day 97 of 100 Days LeetCode Challenge Problem: 🔹 #1281 – Subtract the Product and Sum of Digits of an Integer 🔗 https://lnkd.in/gxTAZc6U Learning Journey: 🔹 Today’s problem involved extracting digits of a number and performing two operations simultaneously. 🔹 I initialized two variables: one for product (pr) and one for sum (sm). 🔹 Using a while loop, I extracted each digit using n % 10. 🔹 Updated the product by multiplying the digit and updated the sum by adding it. 🔹 Reduced the number using integer division (n //= 10) after each step. 🔹 Finally returned the difference between product and sum. Concepts Used: 🔹 Digit Extraction 🔹 While Loop 🔹 Arithmetic Operations 🔹 Number Manipulation Key Insight: 🔹 Both product and sum can be computed in a single traversal of digits. 🔹 Efficient use of modulus and division avoids converting the number to a string. Complexity: 🔹 Time: O(d) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
LeetCode Challenge Day 97: Subtract Product and Sum of Digits
More Relevant Posts
-
✅ 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
-
-
Day 47 of #GeekStreak60: The Binary State Machine! 0️⃣1️⃣ Tackled the "Consecutive 1's not allowed" problem on @GeeksforGeeks today. Key Learning: Counting valid combinations often looks like a backtracking problem, which leads to an O(2^n) time trap. By analyzing the strict rules of binary generation, I modeled the problem as a Finite State Machine. Because a 1 can only follow a 0, but a 0 can follow anything, I simply tracked the counts of strings ending in each digit iteratively. This completely eliminated the need to generate the strings themselves, dropping the time complexity to a highly efficient O(n) and the auxiliary space down to a perfect O(1)! (Fun fact: This strict state transition actually generates the Fibonacci sequence under the hood!) Less than two weeks left in the 60-day sprint! 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #DynamicProgramming #StateMachines #Optimization
To view or add a comment, sign in
-
-
✅ Day 90 of 100 Days LeetCode Challenge Problem: 🔹 #476 – Number Complement 🔗 https://lnkd.in/gzE6gM7d Learning Journey: 🔹 Today’s problem focused on finding the complement of a number by flipping its binary bits. 🔹 I first converted the integer to its binary representation using bin(num)[2:]. 🔹 Then, I created a helper function to flip each bit: • '0' → '1' • '1' → '0' 🔹 After generating the flipped binary string, I converted it back to an integer using int(..., 2). 🔹 Returned the final complemented value. Concepts Used: 🔹 Binary Representation 🔹 Bit Manipulation 🔹 String Traversal 🔹 Base Conversion Key Insight: 🔹 The complement operation is essentially a bitwise NOT, but only within the significant bits of the number (ignoring leading zeros). 🔹 Converting to binary simplifies the flipping logic for beginners. Complexity: 🔹 Time: O(log n) 🔹 Space: O(log n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
The Magic of the Mirror: Image Flipping with NumPy! 🤳🔄 Day 85/100 Ever wondered how your phone 'mirrors' your selfies instantly? It’s just one line of array slicing! For Day 85 of my #100DaysOfCode, I explored Image Flipping and Mirroring. In the world of Computer Vision, an image is just a matrix, and to flip it, we simply reverse the order in which we read the rows or columns. Technical Highlights: 🔄 Axis Reversal: Mastering the [::-1] slicing syntax to reverse array indices without complex loops. 🤳 Mirror Logic: Implementing horizontal flips to simulate the front-camera 'selfie' experience. 🌊 Vertical Reflection: Creating water surface reflection effects by reversing the row order of 2D matrices. 🤖 AI Data Augmentation: Learning how flipping images is used in Machine Learning to double the size of training datasets and prevent model bias. Do check my GitHub repository here : https://lnkd.in/d9Yi9ZsC #100DaysOfCode #ComputerVision #NumPy #Python #BTech #IILM #AIML #ImageProcessing #DataAugmentation #SoftwareEngineering #LearningInPublic #WomenInTech
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
-
-
✅ 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
To view or add a comment, sign in
-
-
Just solved a LeetCode problem with 100% runtime efficiency — but here’s the real strategy behind it 👇 When I approach problems like this, I don’t jump straight into code. I break it into patterns: 🔹 Identify what the problem really wants → Not just “digit sum & product” — it’s about processing numbers efficiently digit by digit 🔹 Optimize early → Instead of storing digits, I compute sum & product in a single pass (O(n) time, O(1) space) 🔹 Keep it simple → Clean logic > overcomplicated tricks 🔹 Validate edge thinking → What happens with 0? Single digits? Large numbers? This mindset is what I’m focusing on as I grow in problem-solving — not just solving, but solving smartly. #LeetCode #ProblemSolving #Python #CodingJourney #DataStructures #Algorithms #TechGrowth #Consistency #LearningInPublic #FutureEngineer
To view or add a comment, sign in
-
-
✅ Day 89 of 100 Days LeetCode Challenge Problem: 🔹 #1480 – Running Sum of 1D Array 🔗 https://lnkd.in/gSTZrxF7 Learning Journey: 🔹 Today’s problem focused on computing the running (prefix) sum of an array. 🔹 Instead of using an extra array, I optimized the solution by modifying the input array in-place. 🔹 Starting from index 1, I updated each element as: • nums[i] += nums[i-1] 🔹 This way, each index stores the cumulative sum up to that point. 🔹 Finally, returned the modified array. Concepts Used: 🔹 Prefix Sum 🔹 In-place Computation 🔹 Array Traversal Key Insight: 🔹 The previous element already stores the prefix sum, so we can reuse it directly. 🔹 Eliminates the need for extra space while maintaining linear time. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
A simple problem maybe more complex than expected. Still not getting it right after more than 20 iterations, I mean with realistic and random knob/tab shape. Tried a few LLMs. Question: given a photo folder create Python code to generate a jigsaw puzzle like patchwork from these pictures. Here is my latest test, feeding outputs between tests. First iterations were about basic knobs/tabs shapes creation. Getting realistic knob/tabs shapes took more work. Mismatch between boundary shapes and pictures orientation not respected. The latest generated code now has three passes. You may to try on your side. #ArtificialIntelligence #MachineLearning #LargeLanguageModels #LLM #PythonDevelopment #SoftwareEngineering #ComputerVision #ImageProcessing #GenerativeAI #AIEngineering #PromptEngineering #AlgorithmDesign #DataScience #DeepLearning #TechInnovation #ProblemSolving #SoftwareDevelopment #CodingLife #Debugging #EngineeringChallenges #RAndD #AppliedAI #AIProjects #OpenSourceAI
To view or add a comment, sign in
-
-
Your model isn't bad. Your features are. 80% of ML performance comes from feature engineering. Not from picking XGBoost over Random Forest. Not from tuning n_estimators. From the hours you spend turning raw columns into something a model can actually learn from. Free notebook covers: → Polynomial & interaction features (the trick most beginners skip) → Log transforms for skewed distributions → Binning continuous variables (and when it hurts more than it helps) → Date/time feature extraction (hour, day of week, is_holiday) → Categorical encoding beyond one-hot (target, frequency) → Text feature extraction (length, word count, TF-IDF basics) → Scaling strategies (standardize vs normalize vs neither) If your model is stuck at 70% accuracy, the fix is usually in the features, not the algorithm. https://lnkd.in/gj7SgH7y Day 1 of 7. Every day this week: a hands-on notebook. #DataScience #FeatureEngineering #MachineLearning #Python #MLEngineering #InterviewPrep #Pandas #Sklearn
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