🚀 Day 50 of My Python Journey Today I solved Complement of Base 10 Integer on LeetCode. 🔍 Problem Overview: The task is to find the bitwise complement of a given base-10 integer. The complement is obtained by flipping all bits in its binary representation — changing every 0 to 1 and every 1 to 0. 🧠 Approach: 1️⃣ Convert the integer into its binary representation. 2️⃣ Traverse the binary string and flip each bit (1 → 0, 0 → 1). 3️⃣ Convert the resulting binary string back to a decimal integer. ⚡ Key Learnings: • Practiced binary representation and bit manipulation • Improved understanding of number systems (binary ↔ decimal) • Strengthened string manipulation and logical thinking in Python 📊 Complexity: • Time Complexity: O(n) • Space Complexity: O(n) Under the Guidance of : Rudra Sravan kumar and Manoj Kumar Reddy Parlapalli #Day50 #Python #LeetCode #DataStructures #Algorithms #CodingJourney #ProblemSolving #100DaysOfCode 🚀
Python LeetCode Challenge: Complement of Base 10 Integer
More Relevant Posts
-
🚀 Day 2/30 – Stack & Queue Implementation using Python 🐍📚 Continuing my 30 Days Python Challenge with one of the most important Data Structures fundamentals! Today, I built a Stack & Queue implementation in Python to strengthen my understanding of LIFO and FIFO concepts, along with how data flows in real-world applications 💻 What I focused on today: ✨ Implementing Stack operations: push, pop, peek ✨ Implementing Queue operations: enqueue, dequeue ✨ Strengthening DSA logic and problem-solving skills This challenge is all about consistency, learning in public, and becoming better every single day 🚀 👉 Would love your feedback! Day 3 coming tomorrow… stay tuned 👀 #Python #30DaysChallenge #PythonProjects #DataStructures #Stack #Queue #CodingJourney #LearnPython #BuildInPublic #ProblemSolving
To view or add a comment, sign in
-
Day 22/100 – #100DaysOfCode 🚀 Solved LeetCode #560 – Subarray Sum Equals K (Python). Today I learned how prefix sum and hashmap can be used together to efficiently count subarrays with a given sum. Approach: 1) Initialize count = 0 and curr_sum = 0. 2) Use a hashmap to store prefix sum frequencies (start with {0:1}). 3) Traverse the array and keep adding elements to curr_sum. 4) Check if (curr_sum - k) exists in the hashmap. 5) If it exists, add its frequency to count. 6) Update the hashmap with the current prefix sum. Time Complexity: O(n) Space Complexity: O(n) Understanding prefix sum + hashmap pattern is a game changer 💪 #LeetCode #Python #DSA #HashMap #PrefixSum #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Started my #30DaysOfPython journey today. 🚀 Here are some of the basics I picked up: 1. Python is a high-level, interpreted, open-source, object-oriented language created by Guido van Rossum. 2. Unlike many languages, Python uses indentation instead of curly brackets to define blocks of code. 3. I also revisited core data types like: (i) Numbers (ii) Strings (iii) Booleans (iv) Lists (v) Dictionaries (vi) Tuples (vii) Sets 4. One simple but useful thing: type() helps check the data type of any value. Day 1 done. One step closer to becoming more confident with Python. 🐍 #Python #30DaysOfPython #SoftwareDevelopment #LearningInPublic #CareerTransition
To view or add a comment, sign in
-
Simple way to understand vector search in RAG I made a small Python example using SentenceTransformers + FAISS to understand how retrieval works in RAG. What happens here: A few documents are converted into embeddings Those embeddings are stored in FAISS A user question is also converted into an embedding FAISS finds the most similar document chunks This is the basic idea behind RAG: store meaning as vectors, then retrieve the most relevant context before generation Very small code, but it explains a very important concept. Text → Embedding → Similarity Search → Relevant Chunks That is why vector databases are so important in RAG systems. #RAG #FAISS #Embeddings #AIEngineering #Python #LLM Code source: https://lnkd.in/g-cm4BB2
To view or add a comment, sign in
-
-
Day 20/100 – #100DaysOfCode 🚀 Solved LeetCode #448 – Find All Numbers Disappeared in an Array (Python). Today I worked on an array problem to find all the numbers in the range [1, n] that are missing from the given array. Approach: 1) Convert the array into a set for quick lookup. 2) Traverse numbers from 1 to n. 3) Check if each number exists in the set. 4) If not present, add it to the result list. 5) Return the final list of missing numbers. Time Complexity: O(n) Space Complexity: O(n) Learning how sets help in fast lookup and simplify problems 💪 #LeetCode #Python #DSA #Arrays #HashSet #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 64 of the #three90challenge 📊 Today I learned about Functions in Python — a key concept for writing clean and reusable code. Instead of repeating the same logic multiple times, functions allow us to define it once and reuse it whenever needed. What I practiced today: • Creating functions using def • Passing inputs (parameters) • Returning outputs using return • Writing reusable and organized code Example thinking: Instead of writing the same code again and again, functions help turn it into a single reusable block. Example: def calculate_total(a, b): return a + b print(calculate_total(5, 10)) This makes code more efficient, readable, and scalable. From writing code → to structuring it better 🚀 GeeksforGeeks #three90challenge #commitwithgfg #Python #DataAnalytics #LearningInPublic #Consistency #Upskilling #PythonBasics
To view or add a comment, sign in
-
Python didn’t throw an error… and that’s the problem x = 10 x = "10" Later: print(x + 5) This crashes. Not when the mistake happened… but later, when the variable was actually used. That’s the difference. Python lets you change types freely (dynamic typing), but errors only show up at runtime. In C++, this wouldn’t even compile. You’d catch it immediately. So the real question is: Do you want errors early… or flexibility first and consequences later? Day 3/30 #Python #C++ #LearningInPublic #30DaysOfCode
To view or add a comment, sign in
-
-
Finding Maximum Sum of k Consecutive Elements in Python Check out this simple sliding window trick to get the maximum sum of k consecutive numbers in an array. I used my own code to solve it: Python Copy code nums = [7,1,5,1,3,2] k = 3 n = len(nums) window = sum(nums[:k]) sums = window for i in range(k,n): window = window - nums[i-k] + nums[i] if sums < window: sums = window print(sums) How it works: Start with the sum of the first k numbers Slide the window by removing the first number and adding the next Keep track of the maximum sum Fast, simple, and efficient! #Python #DSA #Coding #Algorithms #LearnByDoing #DeveloperLife
To view or add a comment, sign in
-
Learn in Public — Day 15 Today I studied Selection Sort and implemented it in Python. 🔹 Key Idea: Selection Sort repeatedly finds the minimum element from the unsorted part of the array and places it at the correct position in the sorted part. 🔹 How it works: 1️⃣ Start from the first element 2️⃣ Find the smallest element in the remaining array 3️⃣ Swap it with the current position 4️⃣ Repeat for the rest of the array 🔹 Complexity: Time Complexity: O(n²) Space Complexity: O(1) (in-place sorting) Even though Selection Sort is not efficient for large datasets, it’s a great algorithm for understanding how sorting works internally. Every small step builds the foundation for mastering algorithms. #LearnInPublic #100DaysOfCode #Python #Algorithms #DataStructures
To view or add a comment, sign in
-
More from this author
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