🚀 Daily LeetCode Challenge: Check If All 1’s Are at Least K Places Apart Today’s problem tested the importance of clean logic and careful return placement. The challenge: Given a binary array nums and an integer k, determine if all 1s are at least k indices apart. 🔎 Approach Track the index of the last seen 1. For each new 1, check the gap with the previous one. If the gap is smaller than k, return False. Otherwise, update the last index and continue. If no violations are found, return True. 🔗 https://lnkd.in/grFSDb3w #LeetCode #DailyCodingChallenge #Python #Algorithms #ProblemSolving #CodingJourney #100DaysOfCode #SoftwareEngineering
Check if all 1's are at least k apart in a binary array
More Relevant Posts
-
Day 12 of #30DaysOfCode with Educative 🟦 Challenge: Middle of the Linked List (Easy) Approach: Slow–fast pointer technique Insight: Traverse the list with two pointers: the slow pointer moves one step at a time, and the fast pointer moves two steps. When the fast pointer reaches the end, the slow pointer naturally lands on the middle node; for even-length lists, this lands on the second middle, exactly as required. Tricky Part: The only small care point is the loop condition, checking both fast and next pointer to fast avoids null-pointer issues and cleanly handles both odd and even list lengths. #Educative #Python #SoftwareEngineering #ContinuousLearning #ProblemSolving
To view or add a comment, sign in
-
Day 7/30: Loops, Lists, and Logic: Building Hangman in Python Today, I had to implement a Game Loop (while loop) that keeps the program alive until a specific win/loss condition is met. I used Python's random module and while loops to recreate the tension of the classic paper-and-pencil game in the terminal. Features: ✅ Random word generation from a large database. ✅ ASCII art that updates with every wrong guess. ✅ Input validation to handle repeated guesses. Making progress every single day. 🚀 Link: https://lnkd.in/dJYvzwnj #Python #GameDev #Coding #DailyProgress #TechSkills #istudyatsqi #codewithsteff #datascience
To view or add a comment, sign in
-
-
🚀 Day 14/50 — DSA Problem-Solving Challenge 🔍 Problem: Check Valid Anagram 🔹 Platform: HackerRank 🔹 Difficulty: Easy 💡 Problem Statement Given two strings, determine whether they are anagrams of each other. Two strings are anagrams if they contain the same characters with the same frequency, regardless of order. 🧠 Key Takeaways ✔ Understand how character frequency helps detect anagrams ✔ Sorting is an easy approach, but counting characters is more efficient ✔ Handles multiple cases like different lengths, repeated characters, etc. 🔧 Logic Used If lengths differ → Not an anagram Count occurrences of each character in both strings Compare both frequency maps If all counts match → Valid anagram #DSA #Day14 #CodingChallenge #ProblemSolving #Python #50DaysChallenge #LearningEveryday #Anagram
To view or add a comment, sign in
-
-
Daily LeetCode Question | Day 1 ✅ LeetCode 1351: Count Negative Numbers in a Sorted Matrix ✔️ Used the two-pointer (staircase) approach starting from the top-right corner of the matrix. At each step, I leveraged the row-wise and column-wise sorted property to eliminate multiple elements at once instead of checking every cell. 🔹 Approach: Two Pointers (Staircase Search) 🔹 Time Complexity: O(m + n) 🔹 Space Complexity: O(1) This optimized approach avoids brute force and binary search, making it both efficient and interview-friendly. #LeetCode #DSA #TwoPointers #ProblemSolving #Python #CodingJourney
To view or add a comment, sign in
-
-
LeetCode 191: Number of 1 Bits (also known as finding the Hamming Weight). The Efficiency Secret: While you can solve this using a while loop with bit-shifting or a string conversion, Python’s built-in bit_count() method is implemented directly at the C-level in the interpreter. It provides the most efficient way to count set bits in an integer. The Results: 🎯 Runtime: 0 ms (Beats 100.00%) 🧠 Memory: 17.53 MB (Beats 92.87%) This solve marks a great addition to my recent streak of 100% efficiency beats in both memory and runtime across various string and math problems. Consistency is paying off! #LeetCode #Python #BitManipulation #CleanCode #Optimization #SoftwareEngineering #Consistency
To view or add a comment, sign in
-
-
#100DaysLearningChallenge with Saurabh Shukla Sir 🎯 Day 70: Static vs Dynamic Linking Ever wondered why some programs run smoothly on any machine, while others need specific libraries to even start? That’s where static vs dynamic linking comes in. 🔹 C++ gives you a choice Static linking: all required code is bundled inside the executable Dynamic linking: libraries are linked at runtime 🔹 Python mostly follows dynamic linking Modules and shared libraries are loaded when the program runs Same destination, different paths. One focuses on control, the other on flexibility. #Day70 #StaticLinking #DynamicLinking #CPP #Python #100DaysLearningChallenge
To view or add a comment, sign in
-
**Day 90: Permutation in String 🧩** Check if `s2` contains a permutation of `s1` using a **Sliding Window**! Track character counts and a `matches` variable to update the state in O(1) as you slide. No re-sorting needed, just pure O(n) efficiency! ⚡ #Day90 #SlidingWindow #LeetCode #Python #Coding #Algorithm #DSA #100DaysOfCode
To view or add a comment, sign in
-
Theory is good. Proof is better. 🐢 vs ⚡ We’ve all studied Multithreading in Python. We know the definitions. But have we actually performed the benchmark? I decided to put the theory to the test. wrote two scripts to download high-res images: 1️⃣ Single-Threaded: The standard loop we all write. 2️⃣ Multi-Threaded: Using ThreadPoolExecutor. That is a 60% performance increase just by changing how we handle I/O waiting time. Check out the video to see the race, and grab the code on my GitHub to try it yourself! 👇 https://lnkd.in/gZASrAUj #Python #RealWorldCoding #DataAnalysis #Multithreading #Performance
To view or add a comment, sign in
-
#Day3 of #100DaysofAI Day 3 was packed with Python control flow mastery and function building! Revised if/elif/else, for/while loops with break/continue, list comprehensions, then wrote 8 practical functions (add/subtract/multiply/divide, even/odd checker, prime tester, reverse number, Fibonacci generator). Built a Simple Calculator and Number Guessing Game as mini-projects. Key takeaway: print() shows output, return computes values — functions must return, never assign print() to variables. Control flow is logic's backbone! #AIJourney #LearningInPublic #Python #ArtificialIntelligence #BuildInPublic
To view or add a comment, sign in
-
Day 35/ 100- Plus One Today I worked on the Plus One problem, where a number is represented as an array of digits and we need to increment it by one. => Key Idea Start from the last digit Handle carry properly when digits are 9 If all digits are 9, add a new leading 1 => Optimized Approach Traverse from right to left Update digits in-place Time Complexity: O(n) Space Complexity: O(1) (excluding output) code https://lnkd.in/gsiFHb8c #Python #DSA #100DaysOfCode #ProblemSolving #CodingJourney #LeetCode
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
#CareerGrowth