🚀 Day 51 of #100DaysOfCode ✅ Solved: 1689. Partitioning Into Minimum Number of Deci-Binary Numbers Today’s problem looked tricky at first, but the solution turned out to be beautifully simple once the pattern was understood. 🔎 Problem Insight: A deci-binary number contains only digits 0 or 1. To form a number like "82734", think about each digit: If a digit is 8, we need at least 8 deci-binary numbers contributing 1 at that position. If a digit is 3, we need at least 3 deci-binary numbers at that position. 👉 So the minimum number of deci-binary numbers required is simply: 📌 The maximum digit in the given number 💡 Example: Input: "82734" Output: 8 🧠 Python Code: Python Copy code class Solution: def minPartitions(self, n: str) -> int: return int(max(n)) ⏱ Time Complexity: O(N) 💾 Space Complexity: O(1) This problem is a great example of how understanding the pattern simplifies the solution dramatically. #LeetCode #ProblemSolving #Python #DataStructures #CodingJourney #100DaysOfCode
Deci-Binary Numbers: Min Partitions Solution
More Relevant Posts
-
Weekly Challenge 6: Two Pointers Reversing an array the "Senior" way (Two Pointers) Reversing a list in Python is easy. Just type `list.reverse()` or `list[::-1]` and you are done, right? But what if you are in a technical interview and you are asked to do it from scratch, using **zero extra memory**? For Week 6 of my coding challenge, I implemented the **Two Pointers Technique** to reverse an array *in-place*. **The Logic:** You place one pointer at the start (index 0) and one at the end. You swap their values, and then step both pointers toward the middle until they meet. **Why it matters:** By doing this *in-place*, our Space Complexity is $O(1)$ (Constant Space). We don't need to duplicate the array in our RAM. If you are processing massive datasets, this memory optimization is critical! Check out the console trace below to see how the pointers move step-by-step. Code on my GitHub: https://lnkd.in/eyZ4KqiN #Python #Algorithms #TwoPointers #CodingChallenge #Optimization #DataStructures
To view or add a comment, sign in
-
Scale vector search to millions without rewriting your prototype code ⚡ Building semantic search typically starts with storing vectors in Python lists and computing cosine similarity manually. But brute-force comparison scales linearly with your dataset, making every query slower as your data grows. Qdrant is a vector search engine built in Rust that indexes your vectors for fast retrieval. Key features: • In-memory mode for local prototyping with no server setup • Seamlessly scale to millions of vectors in production with the same Python API • Built-in support for cosine, dot product, and Euclidean distance • Sub-second query times even for millions of vectors ☕️ Run this code: https://bit.ly/4cCI76w #VectorDatabase #Python #SemanticSearch #DataScience
To view or add a comment, sign in
-
-
Just practiced Pandas and data cleaning hits different when you're working with real messy data. Covered data types, type conversion, handling missing values, replacing inconsistent entries, and using category dtype to save memory — FuelType column went from 11488 bytes to 1460 bytes just by changing the dtype. Notebook here 👉 https://lnkd.in/d3djYPvp #Python #Pandas #DataAnalysis #LearningInPublic
To view or add a comment, sign in
-
Didn't know you could extract tables from a Word doc using Python until today. python-docx lets you loop through tables, pull cell data, and load it straight into a DataFrame. Spent some time cleaning it up — splitting on ':', transposing, fixing headers — but it worked. Also practiced groupby() and lambda functions inline. Small things but they make the code so much cleaner. Notebook here 👉 https://lnkd.in/dfTwrvqT #Python #Pandas #DataAnalysis #LearningInPublic
To view or add a comment, sign in
-
Topic 7/100 🚀 🧠 Topic 7 — Lambda Functions Want to write a quick function in just one line? ⚡ 👉 What is it? Lambda functions are small anonymous functions defined using the lambda keyword. 👉 Use Case: Used in real-world applications for: Quick operations inside map(), filter() Sorting with custom logic Short, throwaway functions 👉 Why it’s Helpful: Reduces boilerplate code Makes code concise Useful for functional programming 💻 Example: # Normal function def square(x): return x * x # Lambda version square = lambda x: x * x print(square(5)) 🧠 What’s happening here? We replaced a full function definition with a single-line lambda expression. ⚡ Pro Tip: Use lambdas for small logic only — avoid them for complex functions. 💬 Follow this series for more Topics #Python #BackendDevelopment #100TopicOfCode #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
-
Nobody Cares How You Built It 🐍 Spent days on an analysis. Custom functions. Optimized queries. Clean, modular code. Every edge case handled. Then dashboard is presented. The stakeholder looked at the output for 30 seconds and asked one question: "So, what does this mean for next quarter?" Not a single question about the method. Not a word about the code. They didn't care how it’s built. They never do. What they care about is the answer. The implication. What happens next. 👉 The analysis is not the deliverable. The decision it enables is. 👉 Lead with the answer. Save the method for when someone asks. #DataAnalytics #Python #AnalyticsThinking #LearningInPublic
To view or add a comment, sign in
-
Day 32 of my Python journey 🐍📊 – Standard Library Power: Math, Random & Higher-Order Functions! Building on OOP from Day 31, dove into Python's stdlib gems today for math ops, randomness, and functional programming magic. Math module shines with factorial (math.factorial(5) → 120) for quick permutations.docs.python Random module delivers randint(a, b) for inclusive integers (e.g., random.randint(1, 10)) and choice(seq) for picking from lists/sequences.geeksforgeek Map applies a func to iterables (map(lambda x: x*2, ) → ), filter keeps truthy elements (filter(lambda x: x>2, ) → ), reduce aggregates (functools.reduce(lambda x,y: x+y, ) → 6). Practiced: Simulated a lottery cart picker with random.choice(items), factorial odds calc, and map/filter on shopping totals. Efficient & fun! 🎲✨ Next: More stdlib or modules ahead! #Python #Day32 #StandardLibrary #MathModule #Random #MapFilterReduce #PythonOOP #CodingJourney #100DaysOfCode #LearnInPublic #CodeNewbie #DeveloperJourney #AndhraPradesh #PythonForBeginners
To view or add a comment, sign in
-
Speed up Pandas string operations by 5-10x by upgrading to pandas 3.0 🚀 Traditionally, pandas stores strings as object dtype, where each string is a separate Python object scattered across memory. This makes string operations slow and the dtype ambiguous, since both pure string columns and mixed-type columns show up as "object". pandas 3.0 introduces a dedicated str dtype backed by PyArrow, which stores strings in contiguous memory blocks instead of individual Python objects. Key benefits: • 5-10x faster string operations because data is stored contiguously • 50% lower memory by eliminating Python object overhead • Clear distinction between string and mixed-type columns Upgrade to pandas 3.0 with "pip install -U pandas". 📖 What's New in pandas 3.0: https://bit.ly/3NLjeew ☕️ Run this code: https://bit.ly/4ugIpGh #pandas #Python #DataScience #pyarrow
To view or add a comment, sign in
-
-
Topic 10/100 🚀 🧠 Topic 10 — Partial Functions What if you could pre-fill some arguments of a function and reuse it later? 🤯 👉 What is it? Partial functions allow you to fix a few arguments of a function and generate a new function with fewer parameters. 👉 Use Case: Used in real-world applications for: Pre-configuring functions Simplifying repeated function calls Building reusable utilities 👉 Why it’s Helpful: Reduces repetition Makes code cleaner Improves readability 💻 Example: from functools import partial def multiply(x, y): return x * y double = partial(multiply, 2) print(double(5)) # Output: 10 🧠 What’s happening here? We fixed the value of x = 2, creating a new function (double) that only needs one argument. ⚡ Pro Tip: Use partial functions when you find yourself passing the same arguments repeatedly. 💬 Follow this series for more Topics #Python #BackendDevelopment #100TopicOfCode #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
-
The best debugging session is a build. Recently put together a small project using Python and Pandas. What it forced me to think through: 🔹 Structuring DataFrames for the right operations — not just loading data, but designing it 🔹 Vectorized operations over loops — cleaner, faster, more Pythonic 🔹 Filtering, grouping, and aggregating with intent 🔹 Serialization — reading from and writing back to files mid-workflow 🔹 Knowing when Pandas is the right tool and when it's overkill That last point is underrated. A DataFrame isn't always the answer. Knowing when a plain Python dict does the job better — that's the actual skill. Real constraints teach what tutorials skip. #Python #Pandas #DataEngineering #BuildingInPublic #SoftwareCraft #DataScience
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