Day 43 of LeetCoding everyday until I get a J-O-B: Check If a String Contains All Binary Codes of Size K. If K = 2, the possible codes are 00, 01, 10, 11. We need to prove every combination exists inside our string. The Noob Trap: Generating all $2^k$ combinations upfront to cross them off. If K = 20, you need over a million strings. You just blew up your RAM. The Senior Fix: Math & Sliding Windows 1. The Math Filter: For a string to even physically fit all combinations, its length must be at least 2^k + K - 1. If it's shorter? Instant return False. Just like my job applications. 2. The Set: We slide a window of size K across the string, dumping every slice into a Python Set (which automatically vaporizes duplicates). 3. The Check: At the end, we check if len(seen) == (1 << k). (We use a Bitwise Left Shift because we are elite). See more: https://lnkd.in/gUki2imQ #LeetCode #Python #DataStructures #Engineering #TechHumor
More Relevant Posts
-
My thesis was stuck. A matrix had the wrong shape and I had no idea why. I could have printed the entire dataset to find the error. I did not. Instead I used Python's debugger. One breakpoint. One look at the intermediate state. Wrong dimensions. Found in seconds. That moment changed how I work. Not because debugging saved my thesis. But because it taught me something I still use every day: You do not need to see all the data to understand what is wrong. You just need to see the right data at the right moment. Since then, every time a pipeline breaks or a model behaves unexpectedly, I reach for the debugger first. Not print statements. Not guesswork. A breakpoint. An intermediate result. A clear answer. Debugging is not a last resort. It is the fastest way to understand what your code is actually doing. What is your go-to strategy when something breaks unexpectedly? #Python #Debugging #DataScience #MachineLearning #FreelanceDataScientist
To view or add a comment, sign in
-
-
Day 5/10 🚀 This is where you stop copying code and start writing it. Functions — the core of every real Python project. Without them? Repetition, messy code, hard to scale. With them? Write once, reuse everywhere. 📋 What I covered today: 01 → Functions & definitions 02 → Positional, keyword & default arguments 03 → *args & **kwargs 04 → Scope — local & global 05 → map, filter, reduce 06 → Lambda functions 07 → Closures & recursion 08 → Decorators & generators 09 → Mini Project — Salary Pipeline Build a small pipeline using map, filter & reduce to find top earners above average salary — a real-world data engineering pattern. Day 1 ✅ Day 2 ✅ Day 3 ✅ Day 4 ✅ Day 5 ✅ 5 more to go. Drop a 🐍 if *args and **kwargs ever confused you 😄 #Python #Functions #DataEngineering #LearningInPublic #CleanCode #10DaysOfPython
To view or add a comment, sign in
-
Day 14/100 – Data Structures & Algorithms Today, I worked on the problem “First Unique Character in a String.” Overview The task is to identify the first non-repeating character in a string and return its index. If no such character exists, the result is -1. Approach I used a two-pass strategy: • First pass to store character frequencies using a hashmap • Second pass to identify the first character with a frequency of one Complexity • Time Complexity: O(n) • Space Complexity: O(1) Key Takeaway This problem reinforces how effective hashmaps are for frequency-based problems and how a simple two-pass approach can lead to optimal solutions. Staying consistent and building problem-solving intuition step by step. #Day14 #100DaysOfCode #DSA #Python #LeetCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
Today I worked on a classic string manipulation problem that looks simple but tests your understanding of logic and edge cases. 🔍 Problem: Given a string and a substring, count how many times the substring appears in the main string. ⚠️ The catch? 👉 You must count overlapping occurrences as well. 💡 Approach I Used: Instead of using built-in shortcuts, I applied a sliding window technique: ++Loop through the string ++Extract a substring of the same length ++Compare it with the target substring ++Increment count when matched This ensures we don’t miss overlapping patterns. 🧠 Key Learning: Sometimes, simple problems reveal powerful concepts. This one reinforces: ++String slicing ++Loop boundaries ++Sliding window logic 📌 Example: "ABCDCDC" → "CDC" appears 2 times (including overlap) 💻 Check out the visuals: 🖼️ Problem breakdown 🧑💻 Python solution 🔥 Why this matters? This pattern is widely used in: --Text processing --Pattern matching --Data parsing #Python #HackerRank #CodingPractice #DataStructures #ProblemSolving #100DaysOfCode #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
-
-
💡 Solved “Remove Nodes From Linked List” Using a Stack — But Can It Be Better? Today I worked on the Remove Nodes From Linked List problem, and it was a fun one. 🔍 Problem Statement: Remove every node that has a node with a greater value somewhere to its right. Example: 5 → 2 → 13 → 3 → 8 ✅ Output: 13 → 8 ⚙️ My Approach: Stack I used a stack to maintain values in decreasing order: Traverse the linked list If current value is greater than stack top → pop smaller values Push current value Rebuild the linked list from remaining values ✨ Why it works: The stack keeps only values that are valid survivors after checking future nodes. 💻 🐍 Python code👍 🤩 👍: https://lnkd.in/gcAaycjY 📊 Complexity: Time: O(n) Space: O(n) 🧠 Takeaway: Sometimes using extra space makes the logic cleaner and easier to implement. But now I’m curious... 👉 Can you give the best solution for this problem? (Perhaps O(n) time with O(1) extra space?) Would love to see different approaches from the community 👇 #LinkedList #DataStructures #Algorithms #Python #CodingInterview #ProblemSolving #LeetCode Rajan Arora
To view or add a comment, sign in
-
-
Continuing from my previous post https://lnkd.in/gtyziw-6 here is the actual implementation part of the same project. In this video, I’ve shown my full Jupyter Notebook workflow where I performed the analysis step by step. What this includes: • Data preprocessing and filtering • Handling missing and incorrect values • Feature-level analysis • Applying statistical logic to derive insights This is where the real learning happened — not in theory, but in execution. Debugging errors, fixing logic, and making sure the output actually makes sense. Still improving, but this is a solid step toward building practical data skills. #jupyter #python #dataanalytics #statisticsproject #handsonlearning #careerbuilding #datasciencejourney
To view or add a comment, sign in
-
Day 105 of 365 days of code :" 1) Daily temperatures Approach: monotonic stack 1) create an array of the size same as of the given temperatures array 2) fill it with 0; declare an empty stack-> used for holding the index and the temperature 3)iterate through the temperatures array 4) while stack is not empty and the temperature in the top element of the stack is less than the current value in the temperatures array pop the index,temperature pair and assign it to resindex and restemp a) res[resindex]=index-resindex //index is the current position in temperatures array 6) insert the index and temperatures[index] as a pair inside the stack 7) return res g'night #365daysOfCode #NeetCode #leetcode #DSA #python #LeetCode #ProblemSolving #Algorithms #365dayschallenge
To view or add a comment, sign in
-
-
🚀 Simplifying Trees in DSA! 🌳💻 While Arrays and Linked Lists are great linear structures, hierarchical data requires a Non-Linear approach—like Trees! To make revising easier, I created this visual cheat sheet. Just like a real-world tree has a Root and Leaves, a Tree data structure starts at the Root Node and branches out to Intermediate and Leaf Nodes. Here is what I have visually summarized in these notes: ✅ The core difference between Linear and Non-Linear structures ✅ 7 Types of Trees (including BST, Strict, Complete, and Skew Trees) ✅ Array Representation vs. Logical View ✅ Tree Traversal logic (Pre-order, In-order, Post-order) complete with Python code! 🐍 Visualizing the flow from the root down to the leaf nodes is a game-changer for understanding algorithms. Take a look and let me know in the comments—what is your favorite data structure to work with? 👇 #DSA #DataStructures #Algorithms #Python #CodingJourney #TechNotes #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
Day 5 of #14DaysOfPython Completed Strings (core + advanced) and consolidated everything in one place. Strings are a major part of problem solving — most questions are based on text manipulation. Concepts Covered: Indexing and slicing Traversing using loops (for, while) Built-in methods: lower(), upper(), strip(), replace() ASCII basics using ord() and chr() String immutability Concatenation and repetition Membership operators (in, not in) String comparison Advanced methods: split(), join(), find(), count() String formatting (f-strings) Escape characters Validation methods: isalpha(), isdigit(), isalnum() Problems practiced: Palindrome check Reverse a string Count vowels and consonants Remove spaces Anagram check Character frequency Remove duplicate characters First non-repeating character Key takeaway: Most string problems follow the same pattern — iterate through characters, apply conditions, and keep track of counts. Understanding this pattern makes complex problems easier to solve. Strings topic completed. Moving to next. #HackerRank #Python #ProblemSolving #CodingJourney #Developer #LearningInPublic #codegnan
To view or add a comment, sign in
-
-
Day 12/30 🔹 Problem: Print multiplication table of a number 🔹 What I focused on today: Using loops to repeat calculations efficiently 🔹 My Thinking Process: Take a number as input Use a loop from 1 to 10 Multiply the number with each value Print the result step by step 👉 Repetition becomes easy with loops 🔹 Inputs I used: A number 🔹 Code: num = int(input("Enter a number: ")) for i in range(1, 11): result = num * i print(num, "x", i, "=", result) 🔹 Example: Input: 5 Output: 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 ... 5 x 10 = 50 🔹 Key Takeaway: Loops help automate repetitive tasks, making code more efficient and scalable #Day12 #Python #30DaysOfCode #LearningInPublic #DataAnalytics #ProblemSolving
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