Day 7 ✅ Binary Search (Interview prep in Python) Today’s problems: ✅ Binary Search ✅ Search a 2D Matrix ✅ Search in Rotated Sorted Array ✅ Find Minimum in Rotated Sorted Array ✅ Koko Eating Bananas What clicked for me today: 👉 Binary Search is not just “find a number” — it’s “find the first position where a condition becomes true” 👉 Rotated array problems became easier once I always asked: which half is sorted? and is my target in that half? 👉 Koko Eating Bananas was the best reminder that you can binary search on the answer (speed) using a feasibility check Koko was the toughest — once I framed it as “can I finish in h hours at speed mid?”, the rest became systematic. If you’re prepping too: which one of these is your hardest — 3, 4, or 5? (comment the number) 💬 Link to solutions in the comments. #Python #DSA #LeetCode #InterviewPrep #BuildInPublic
Binary Search Interview Prep in Python
More Relevant Posts
-
Day 6/100 – #100DaysOfCode 🚀 Solved LeetCode #35 – Search Insert Position (Python). Today I practiced Binary Search to efficiently find the index of a target element in a sorted array. If the target is not present, return the position where it should be inserted. Approach: 1) Initialize two pointers: start and end. 2) Calculate mid index using (start + end) // 2. 3) If nums[mid] equals target, return mid. 4) If target is greater, move start to mid + 1. 5) Otherwise, move end to mid - 1. 6) If not found, return start as the correct insert position. Time Complexity: O(log n) Space Complexity: O(1) Binary Search is a must-know technique for technical interviews 💪 #LeetCode #Python #DSA #BinarySearch #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
✅ *Python Scenario-Based Interview Question* 🧠 You have a sentence: ``` sentence = "Python is fun and powerful" ``` *Question:* Reverse the order of words in the sentence. *Expected Output:* ``` "powerful and fun is Python" ``` *Python Code:* ``` reversed_sentence = ' '.join(sentence.split()[::-1]) print(reversed_sentence) ``` *Explanation:* – `split()` breaks the sentence into words – `[::-1]` reverses the word list – `' '.join()` puts them back into a string 💬 *Tap ❤️ for more!*
To view or add a comment, sign in
-
🚨 Python Interview Trap: == vs is Many beginners think == and is are the same in Python… but they are NOT. ✔ == → compares values ✔ is → compares memory location (object identity) Example 👇 a = [1,2,3] b = [1,2,3] print(a == b) → True print(a is b) → False Why? Even though the values are the same, Python created two different objects in memory. Now look at this 👇 a = 256 b = 256 print(a is b) → True But… a = 257 b = 257 print(a is b) → False 📌 Reason: Python internally caches integers from -5 to 256. 💡 Interview Tip: Use == when comparing values, and is when checking object identity. Small concepts like this are commonly asked in Python interviews. #Python #CodingInterview #DataScience #MachineLearning #LearnInPublic #100DaysOfCode
To view or add a comment, sign in
-
🔍 Finding Second Largest Element in Python Practiced a common interview problem: 👉 Find the second largest element in an array ✅ Approach 1: Two Loops First loop → find maximum Second loop → find second maximum ⏱ Time Complexity: O(n) 💾 Space Complexity: O(1) 🚀 Approach 2: Optimized Single Loop Maintain two variables (first, second) Update both in one traversal ⏱ Time Complexity: O(n) 💾 Space Complexity: O(1) 🎯 Key Insight: Both approaches are linear, but the single-loop solution is cleaner and more efficient in practice since it avoids traversing the array twice. Improving logic step-by-step helps build strong problem-solving fundamentals 🚀 def sec_larg(arr): max = 0 for i in range(0,len(arr)): if arr[i]>max: max = arr[i] sec_max = 0 for i in range(0,len(arr)): if(arr[i]>sec_max and arr[i]!=max): sec_max = arr[i] return sec_max arr = [3,2,1,8,] res = sec_larg(arr) print(res) #Python #DSA #CodingInterview #ProblemSolving 10000 CodersManoj Kumar Reddy ParlapalliManivardhan Jakka
To view or add a comment, sign in
-
One of the Most Asked Python Interview Questions: 'is' vs '==' Explained At first glance, they may seem similar — but they test two completely different concepts: ◽ '==' → Checks value ◽ 'is' → Checks object identity (memory reference) Many developers get this wrong in interviews because both can sometimes return the same result — but for very different reasons. I created a short notebook explaining this concept with clear examples to strengthen fundamentals. Strong basics = Strong interviews 💡 Github - https://lnkd.in/gWztaE5H #Python #Programming #InterviewPreparation #PythonBasics #Learning #Developers #Coding
To view or add a comment, sign in
-
𝗣𝘆𝘁𝗵𝗼𝗻 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗣𝗮𝘁𝘁𝗲𝗿𝗻𝘀 | 𝗶𝘁𝗲𝗿𝘁𝗼𝗼𝗹𝘀.𝗽𝗲𝗿𝗺𝘂𝘁𝗮𝘁𝗶𝗼𝗻𝘀() | 📅 𝗗𝗮𝘆 𝟮𝟲 If you’re writing 3 nested loops for permutations, stop. Day 26 of my Python interview prep journey 🚀 𝗧𝗼𝗱𝗮𝘆’𝘀 𝗰𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲: 👉 Generate all permutations of a string 👉 Of fixed length k 👉 In lexicographic order Most people try to brute-force this with loops 😵💫 That’s where Python quietly flexes. 💡 Interview pattern from today: When the problem says “𝘢𝘭𝘭 𝘢𝘳𝘳𝘢𝘯𝘨𝘦𝘮𝘦𝘯𝘵𝘴” → 𝘵𝘩𝘪𝘯𝘬 𝘪𝘵𝘦𝘳𝘵𝘰𝘰𝘭𝘴.𝘱𝘦𝘳𝘮𝘶𝘵𝘢𝘵𝘪𝘰𝘯𝘴. from 𝗶𝘁𝗲𝗿𝘁𝗼𝗼𝗹𝘀 import 𝗽𝗲𝗿𝗺𝘂𝘁𝗮𝘁𝗶𝗼𝗻𝘀 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗺𝗮𝘁𝘁𝗲𝗿𝘀 𝗶𝗻 𝗶𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝘀: • Shows knowledge of Python’s standard library • Avoids unnecessary complexity • Reads like intent, not effort Python rewards clarity over cleverness. Knowing what tool to use is the real skill. 📌 𝗗𝗮𝘆 𝟮𝟲 𝘁𝗮𝗸𝗲𝗮𝘄𝗮𝘆: If the problem smells like combinations or arrangements — 👉 itertools is your first stop. #Python #HackerRank #InterviewPrep #ProblemSolving #DailyCoding #LearnInPublic #Consistency
To view or add a comment, sign in
-
-
Most Python bugs I see in interviews come from one tiny misunderstanding: sort() vs sorted() are not the same thing. A quick example: nums = [3, 1, 2] a = nums.sort() # modifies nums in place, returns None b = sorted(nums) # returns a new sorted list so if you write: return a you get: None whereas the command return b returns [1, 2, 3] It’s a small detail, but it shows up everywhere — especially when you’re mixing transformations with stateful operations. Understanding the difference saves you from subtle, painful bugs.
To view or add a comment, sign in
-
📘 Preparing for Python interviews made me revise core concepts like: ✔️ List vs Tuple ✔️ Decorators & Generators ✔️ Exception handling ✔️ Memory management ✔️ is vs == ✔️ Unit testing Interviews test your understanding of concepts — not just syntax. Back to strengthening fundamentals 💻✨ Follow Middi Amrutha #Python #InterviewPrep #SoftwareEngineer #Learning
To view or add a comment, sign in
-
Most asked Python interview question 🐍💡 👉 Python is called an interpreted language because it executes code line by line, without a separate compilation step. That’s why it’s easy to debug and super flexible. 🔖 Save this for interviews 👨💻 Follow Learn More Technologies for daily tech content #PythonInterview #PythonBasics #LearnPython #PythonDeveloper #CodingInterview #ProgrammingReels #TechReels #learnmoretechnologies
To view or add a comment, sign in
-
One common Python interview question: ▫️What’s the difference between List and Tuple? 🔹 List → Mutable (can be modified) 🔹 Tuple → Immutable (cannot be modified) my_list = [1, 2, 3] my_tuple = (1, 2, 3) ▪️If your data will change → use List. ▪️If your data should stay constant → use Tuple. Simple concept. Big impact on performance, memory, and clean code decisions 👌. #Python #Programming #SoftwareDevelopment #DataScience #AI #LearningJourney
To view or add a comment, sign in
More from this author
-
"Coding Milestone Unlocked: Building a Bootstrap-Free Spotify Clone with HTML, JavaScript, and Pure CSS!"
Kodati Revanth 2y -
Unveiling My Learning Project: A Full-Stack Note-Making App Adventure
Kodati Revanth 2y -
Navigating My React.js Journey: Building My First File Explorer Project
Kodati Revanth 2y
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
Solutions repo ✅ https://github.com/RevanthKodati01/DSA