✅ Day 9 of #DSAPrep > Problem: Square Root of a Number > Platform: LeetCode > Concept: Mathematical Computation Computed the square root of a number using exponentiation, > Key Idea: - num ** 0.5 gives the square root - int() returns the floor value > Example: 36 → 6 > Time Complexity: O(1) > Space Complexity: O(1) Sometimes the simplest approach is the cleanest one ✅ Consistency continues 🚀 #DSAPrep #Python #Algorithms #ProblemSolving #CodingJourney
Computing Square Root with Exponentiation
More Relevant Posts
-
✅ Day 14 of #DSAPrep >Topic: Time Complexity & Space Complexity > Concept: Big-O Notation Today I focused on understanding how to analyze the efficiency of algorithms. Learned how time complexity represents how the execution time grows with input size, and space complexity shows how much memory an algorithm uses. Covered key complexities: O(1) → Constant Time O(log n) → Logarithmic O(n) → Linear O(n²) → Quadratic Also understood how to compare different approaches and choose the most optimal solution. > Time Complexity: Measures performance > Space Complexity: Measures memory usage #DSAPrep #Algorithms #Python #ProblemSolving #CodingJourney #BigO
To view or add a comment, sign in
-
✅Day 12 of #DSAPrep > Problem: Product of Array Except Self > Platform: LeetCode > Concept: Prefix Sum + Suffix Product Solved using an optimized approach by calculating the product of elements on the left and right side separately. First pass stores left products, second pass multiplies right products — without using division. > Time Complexity: O(n) > Space Complexity: O(1) #DataStructures #Algorithms #Python #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Solved Today’s GeeksforGeeks POTD: Sum of Subarray Minimums using Python 🐍 Problem: Given an array of positive integers, the task is to find the sum of the minimum element of every possible subarray. Approach: A brute-force approach would check all subarrays, leading to O(n²) complexity. Instead, I used a more efficient approach with a Monotonic Stack. ✔️ For each element, we determine: • The Previous Smaller Element (PSE) • The Next Smaller Element (NSE) ✔️ This helps calculate how many subarrays consider that element as their minimum. Contribution formula: Element Contribution = arr[i] × left_count × right_count This allows the problem to be solved efficiently. 💡 Time Complexity: O(n) 💡 Space Complexity: O(n) Consistent practice with DSA problems like this strengthens algorithmic thinking and optimization skills. #geekstreak60 #npci #geeksforgeeks #dsa #python #algorithms #codingpractice #problemSolving
To view or add a comment, sign in
-
-
🚀 Day 9 of #100DaysOfCode Today’s problem: Valid Anagram ✅ 🔍 What I learned: How to check if two strings are anagrams Importance of sorting vs frequency counting Strengthened my understanding of strings & hashing concepts 💡 Approach: I used a simple and clean method: Sort both strings Compare them If equal → Anagram ✔️ 📊 Result: ✅ All test cases passed (54/54) ⏱️ Runtime: 19 ms 🔥 Key takeaway: Sometimes a simple solution is enough, but there’s always room to optimize using hash maps for better performance. Consistency > Perfection 💯 Let’s keep going! #LeetCode #DSA #CodingJourney #Day9 #Python #ProblemSolving
To view or add a comment, sign in
-
-
Day 59 of 365 Days of code Couldn't solve problems properly in an optimized way, never mind, i still managed to solve it using a slow and a fast pointer. Qn 1) find the duplicate number The array will contain a duplicate element, we must find the element which has duplicate, without using an hashset. sounds scary :(. Approach: fast and slow pointers Gd nit #365daysOfCode #NeetCode #leetcode #DSA #python #LeetCode #ProblemSolving #Algorithms #365dayschallenge
To view or add a comment, sign in
-
-
LeetCode Problem 3070: "Count submatrices with top left element and sum less than k": You are given a 0-indexed integer matrix grid and an integer k. Return the number of submatrices that contain the top-left element of the grid, and have a sum less than or equal to k. Approach: use Prefix sum to calculate the total value of submatrix including the top left element upto a given cell. This approach is optimal and straightforward. #Python #DSA #LeetCode #ProblemSolving #CompetitiveProgramming #DailyCoding
To view or add a comment, sign in
-
-
🚀 Solved Today’s GeeksforGeeks POTD: Largest Number in One Swap using Python 🐍 Problem: Given a numeric string s, return the lexicographically largest string that can be obtained by swapping at most one pair of characters. Approach: Used a greedy approach with last occurrence tracking: • Stored the last position of each digit (0–9) • Traversed the string from left to right • Checked if a larger digit exists later in the string • Performed one optimal swap to maximize the number This problem helped reinforce: ✔️ Greedy algorithm thinking ✔️ String manipulation techniques ✔️ Efficient optimization with constant space 💡 Time Complexity: O(n) 💡 Space Complexity: O(1) Small optimizations can make a big difference in algorithmic efficiency. Consistency continues! 💪 #geekstreak60 #npci #geeksforgeeks #dsa #python #algorithms #problemsolving #codingjourney
To view or add a comment, sign in
-
-
Day 42 of consistency 🚀 Today’s problem was about counting binary strings of length n without consecutive 1s. A simple-looking question, but it beautifully turns into a DP + Fibonacci pattern problem. Key takeaway: not every counting problem needs brute force — sometimes, just tracking valid endings is enough. Little by little, these patterns start repeating — and that’s where real improvement happens. #GeeksforGeeks #DSA #Python #DynamicProgramming #CodingJourney #ProblemSolving #100DaysOfCode #geekstreak60 #npci
To view or add a comment, sign in
-
-
✅ Day 11 of #DSAPrep > Problem: Contains Duplicate > Platform: LeetCode > Concept: Hashing (Set) Used a set to keep track of visited elements. While iterating through the array, if an element already exists in the set, it means a duplicate is found. This approach avoids nested loops and checks duplicates efficiently. > Time Complexity: O(n) > Space Complexity: O(n) #DSAPrep #Algorithms #Python #Hashing #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Solved the Minimum Window Substring problem using the Sliding Window technique. Goal: Find the smallest substring in s that contains all characters of p (including duplicates). Key Idea • Maintain character frequency • Expand window to include required characters • Shrink window to get the minimum valid substring Time Complexity: O(n) #geekstreak60 #npci #algorithms #datastructures #python #slidingwindow #codingpractice #problemSolving #100DaysOfCode
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