🧠 Day 26 Theme: Sorting Algorithms — From Basics to Optimization Concepts Covered Why sorting matters in algorithms Comparison-based vs non-comparison-based sorting Time & space trade-offs in sorting Internal vs external sorting Sorting stability and real-world applications 📚 Learn from These Resources 📘 Sorting Algorithms Overview 👉 https://lnkd.in/gDhbdPfP 👉 https://lnkd.in/gxjbazMr 📗 Java Sorting (Arrays & Collections) 👉 https://lnkd.in/gnbjPpUM 👉 https://lnkd.in/gRF52QDY 📙 Python Sorting 👉 https://lnkd.in/gmR6Hiy8 👉 https://lnkd.in/gt6W_YWy 📒 JavaScript Sorting 👉 https://lnkd.in/gT-dJVdY 👉 https://lnkd.in/g4eU7quU 🧩 Practice Ideas Implement Bubble Sort, Insertion Sort, and Selection Sort manually Compare time complexities using different input sizes Solve LeetCode problems involving sorting-based logic like “Sort Colors” or “Merge Intervals” #75DaysOfKnowledge #Sorting #Algorithms #Java #Python #JavaScript #ProblemSolving #CodingJourney #LeetCode #DataStructures
"Sorting Algorithms: Basics to Optimization"
More Relevant Posts
-
Day 27/50: The Circular Reference That Never Died The Setup:- Cache object holds reference to user, user holds reference back to cache. Memory grows indefinitely. The Problem:- Circular references prevent garbage collection: --- python class Cache: def __init__(self): self.users = {} user = User() cache = Cache() cache.users['user1'] = user user.cache = cache # Circular! --- Both objects stay in memory forever, even after going out of scope. The Investigation:- Memory profiler showed objects stuck in unreachable cycles. Python's garbage collector finds cycles occasionally, but not immediately. The Solution:- Used weak references to break the cycle: --- python import weakref class Cache: def __init__(self): self.users = {} user = User() cache = Cache() cache.users['user1'] = user user.cache = weakref.ref(cache) # Weak reference! # Access: cache_obj = user.cache() # Returns None if cache was garbage collected --- -> Memory stabilized. The Lesson:- Circular references are invisible memory leaks. Use weak references to break cycles in caches and callback chains. `Have you debugged circular references?` #Day27 #50DaysOfDebugging #Python #MemoryLeak #GarbageCollection #Performance #SoftwareEngineering #Debugging
To view or add a comment, sign in
-
🧠 Day 14 Theme: Searching & Sorting Efficiency Meets Logic Every problem eventually comes down to finding something faster or organizing data smarter. Today’s focus was on understanding how searching and sorting improve both speed and structure in programming. 💡 Concepts Covered Linear Search vs Binary Search Time complexity trade-offs (O(n) vs O(log n)) Bubble, Selection, and Insertion Sort Merge Sort and Quick Sort (Divide & Conquer) Built-in sorting functions and custom comparators 📚 Learn from These Resources 📘 Searching Algorithms 👉 https://lnkd.in/gD4zVN6Q 👉 https://lnkd.in/ghmRte4g 📗 Sorting Algorithms (Visual + Code) 👉 https://lnkd.in/gtBBzeaf 👉 https://lnkd.in/gMtAuEcg 📘 Java — Searching & Sorting 👉 https://lnkd.in/gbxKEc4H 👉 https://lnkd.in/gXY8FVjm 📙 Python Sorting & Searching 👉 https://lnkd.in/gDTy5xAc 👉 https://lnkd.in/gq8U8niW 📒 JavaScript Sorting & Searching 👉 https://lnkd.in/gT-dJVdY 👉 https://lnkd.in/gZtJEmsJ 🧩 Practice Ideas Implement Binary Search manually (no built-in functions) Write your own Bubble Sort and track swaps Compare Merge Sort vs Quick Sort on the same dataset Solve LeetCode “Search Insert Position” and “Sort Colors” #75DaysOfKnowledge #SortingAlgorithms #BinarySearch #LeetCode #ProblemSolving #Java #Python #JavaScript #CodingJourney #Efficiency #DSA
To view or add a comment, sign in
-
🤖 Give your preferred LLM as much context as possible in **a text file**! Don't seal it away in the prompt! 🤖 I was using Anthropic's Claude Code today in the terminal and it was *great*. Really accelerated a solution for a client who needed some data transformed from one format to another. (Python to the rescue.) As I was crafting a long prompt about which data elements in the input go to which in the output...I realized: a prompt is a terrible place for this info. So I opened a text file, wrote the context there (using Markdown), saved it to the relevant folder, and told Claude Code to look for it. Now, if I ever need to revise that Python script, the documentation is human-readable and in the same place as the script itself - not locked behind a proprietary app's Web interface or in a forgotten history window. ❓ How do you ensure your workflows are resilient, and don't rely on one specific tool?
To view or add a comment, sign in
-
🚀 DSA Challenge – Day 83 Problem: Minimum Possible Length of Original String from Concatenated Anagrams 🔡✨ This was an elegant string manipulation and frequency-matching problem — a beautiful blend of observation and brute-force validation. 🧠 Problem Summary: You are given a string s, known to be a concatenation of anagrams of some original string t. The task is to determine the minimum possible length of t. ✅ Each substring of length len(t) should contain exactly the same frequency of characters. ✅ The string s can thus be divided into equal-length chunks, all being anagrams of t. ✅ The goal is to find the smallest such length that satisfies this property. ⚙️ My Approach: 1️⃣ Iterate through all divisors i of n = len(s) — potential lengths of t. 2️⃣ For each possible i, check if the string can be divided into equal parts where each part has identical character frequencies. 3️⃣ Use hash maps to store frequency counts and compare each block. 4️⃣ Return the smallest i that satisfies the condition. 📈 Complexity: Time: O(n²) → Checking frequency for each valid divisor. Space: O(k) → For storing character counts per block. ✨ Key Takeaway: When tackling anagram-based problems, frequency comparison is your strongest ally. Instead of guessing patterns, rely on structure and repetition to reveal the hidden base string. 🔍 🔖 #DSA #100DaysOfCode #LeetCode #ProblemSolving #StringManipulation #Anagram #Python #CodingChallenge #InterviewPrep #EfficientCode #HashMap #DataStructures #TechCommunity #CodeEveryday #LearningByBuilding
To view or add a comment, sign in
-
-
𝗣𝘆𝘁𝗵𝗼𝗻 𝗰𝗮𝗻 𝗳𝗶𝗻𝗮𝗹𝗹𝘆 𝘂𝘀𝗲 𝗮𝗹𝗹 𝘆𝗼𝘂𝗿 𝗖𝗣𝗨 𝗰𝗼𝗿𝗲𝘀. For years, the Global Interpreter Lock (𝗚𝗜𝗟) was Python’s biggest limitation for CPU-bound tasks. Even if you had 8 cores, only one thread could truly execute Python code at a time, others just waited for their turn. Now, with 𝗣𝘆𝘁𝗵𝗼𝗻 𝟯.𝟭𝟰, that changes. The new free-threaded (no-GIL) interpreter finally lets multiple threads run Python code simultaneously, even for CPU-heavy workloads. So what actually changed inside 𝗖𝗣𝘆𝘁𝗵𝗼𝗻 to make this possible? Let’s look at the differences. 𝗢𝗯𝗷𝗲𝗰𝘁 𝗹𝗶𝗳𝗲𝘁𝗶𝗺𝗲: • 𝗢𝗹𝗱: One thread at a time, refcounts were safe by default. • 𝗡𝗲𝘄: Refcounts are atomic. Common objects like None and True are immortal, no locking, no slowdown. 𝗟𝗼𝗰𝗸𝗶𝗻𝗴 𝘀𝘁𝗿𝗮𝘁𝗲𝗴𝘆: • 𝗢𝗹𝗱: One giant GIL for everything. • 𝗡𝗲𝘄: Many tiny locks. Each subsystem guards itself like type caches, allocators, GC. Threads finally run side by side. 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗰𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻: • 𝗢𝗹𝗱: Stop the world, clean up, resume. • 𝗡𝗲𝘄: Each generation has its own lock. GC can quietly run while your code keeps executing. 𝗜𝗻𝘁𝗲𝗿𝗽𝗿𝗲𝘁𝗲𝗿 𝘀𝘁𝗮𝘁𝗲: • 𝗢𝗹𝗱: Shared global state like builtins, modules, caches all tangled together. • 𝗡𝗲𝘄: Each interpreter has isolated state. Subinterpreters can run truly in parallel. 𝗖 𝗲𝘅𝘁𝗲𝗻𝘀𝗶𝗼𝗻𝘀: • 𝗢𝗹𝗱: Every extension assumed the GIL existed. • 𝗡𝗲𝘄: A new free-threaded C API + atomic helpers make extensions thread-safe again. 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲: • 𝗢𝗹𝗱: One thread per process, no matter how many cores. • 𝗡𝗲𝘄: Slightly slower single-thread, but real parallel speedups for CPU-bound workloads. Now, Python can finally breathe across all cores. — 𝐏𝐲𝐂𝐨𝐝𝐞𝐓𝐞𝐜𝐡 #Python
To view or add a comment, sign in
-
🧠 Day 29 Theme: Hashing Deep Dive — Maps, Sets & Optimized Lookups Hashing is one of the most powerful tools for constant-time lookups. It boosts performance in searching, counting, grouping, and duplicate detection across almost all coding challenges. 💡 Concepts Covered HashMap / Dictionary basics HashSet for uniqueness Frequency counting patterns Mapping indices and positions Collision handling (conceptual) When to prefer hashing over arrays Time complexity behavior of hash structures 📚 Learn from These Resources 👉 Hashing Basics 🔗 https://lnkd.in/gPASrWm3 🔗 https://lnkd.in/g-iV59NK 👉 Java HashMap & HashSet 🔗 https://lnkd.in/gbzs3x3g 🔗 https://lnkd.in/gXVBRBMx 👉 Python Dictionary & Set 🔗 https://lnkd.in/gM82pHfc 🔗 https://lnkd.in/guzxXwGX 👉 JavaScript Map & Set 🔗 https://lnkd.in/gncwqrJj 🔗 https://lnkd.in/gQtjSXRA 🧩 Practice Ideas Check if two strings are anagrams Find the first non-repeating character Count frequencies of elements in an array Detect duplicates in O(n) time Group words by anagram pattern Longest substring without repeating characters #75DaysOfKnowledge #Hashing #HashMap #HashSet #DataStructures #LeetCode #ProblemSolving #CodingJourney #Java #Python #JavaScript
To view or add a comment, sign in
-
I have built and released a new python library, focus_response, designed to identify in-focus regions within images. This tool utilizes the Ring Difference Filter (RDF) focus measure, as introduced by Surh et al. in CVPR’17, combined with KDE to highlight focus "hotspots" through visually intuitive heatmaps. Features: - Focus maps generated from RDF. - KDE-based density maps and clear visual overlays for easy identification of in-focus areas. - Access to intermediates for subsequent tasks, including fused RDF map, KDE map, threshold values, per-scale maps, and timings. - Convenient batch processing assistance for image folders. - Visualizations. Installation: pip install focus_response Explore further: PyPi: [focus_response on PyPi](https://lnkd.in/eB993pAy) GitHub: [focus_response on GitHub](https://lnkd.in/eu749YER) Note: The example video uses the jet colormap—red indicates higher focus, blue indicates lower focus, and dark blue (the colormap’s lower bound) reflects no focus response due to lack of texture. #ImageProcessing #ComputerVision #MachineLearning
To view or add a comment, sign in
-
Today, I worked on one of those fun string manipulation problems that really test your logic flow Zigzag Conversion 🧩 Problem Summary: Given a string s and an integer numRows, you arrange the characters in a zigzag pattern and then read them row by row. For example: Input: s = "PAYPALISHIRING", numRows = 3 Output: "PAHNAPLSIIGYIR" 💡 My Thought Process: Instead of building a full 2D grid, I realized I could simulate the zigzag movement by tracking the current row and direction. Each character simply “moves” down or up through the rows, and we join all rows at the end. 🧠 Python Solution: class Solution: def convert(self, s: str, numRows: int) -> str: if numRows == 1 or numRows >= len(s): return s rows = [''] * numRows cur_row, going_down = 0, False for c in s: rows[cur_row] += c if cur_row == 0 or cur_row == numRows - 1: going_down = not going_down cur_row += 1 if going_down else -1 return ''.join(rows) ✅ Time Complexity: O(n) ✅ Space Complexity: O(n) This problem reminded me how clean logic can outperform brute force, no fancy data structures needed, just control flow and direction tracking.
To view or add a comment, sign in
-
-
🚀 Day 40 / 100 — #100DaysOfLeetCode 💡 (1625) Lexicographically Smallest String After Applying Operations (Medium) This was a really fun graph + BFS problem disguised as a string manipulation challenge. The trick is realizing that applying the two operations (add & rotate) repeatedly explores a finite set of states, forming an implicit graph, where each node is a string transformation. 🧩 Problem Overview You are given: A numeric string s Two integers a and b You can repeatedly: Add a (mod 10) to all digits at odd indices. Rotate the string right by b positions. Find the lexicographically smallest string possible after any number of operations. ⚙️ Approach — BFS on States Used Breadth-First Search (BFS) to explore all reachable strings: Start from the initial string s. Use a set vis to track visited states. For each string, generate: One by performing addition on odd indices. One by rotating by b. Continue until all unique transformations are explored. Track the smallest lexicographical string seen. 📈 Complexities Time Complexity: O(10 * n) Each state can appear up to 10 times due to modulo operations, and each state has n length. Space Complexity: O(10 * n) For storing visited transformations. ✅ Key Insights The problem is finite because both operations are modular and cyclic. BFS guarantees we explore all possible reachable strings in an optimal manner. Lexicographical comparison after BFS is straightforward — track the smallest string so far. ✨ Takeaway This problem beautifully demonstrates how: “Even string problems can secretly be graph traversal problems.” It’s a neat mix of modular arithmetic, rotation logic, and state-space search. #LeetCode #100DaysOfCode #BFS #GraphTraversal #StringManipulation #ProblemSolving #Python #Algorithms
To view or add a comment, sign in
-
-
Hi data scientists, Today I programmed a FactorMultiple_correlation(F_mc). In a separate python function you can use the following algorithm: With F as factorscore and Z as scaled datamatrix(centered and unity length) the algorithm is(dot is matrixmultiplication, diag is: take the diag and create a diagonal matrix, or take the diag and sum) : w = diag(dot(F.T, F)) # diagonal matrix L = dot(Z.T , F) LwL = dot(dot(L, w), L.T) F_mc = sum(diag(LWL)) / k # the mean - trace of LWL F_mc is the same as the the multiple correlation coefficient from from linear regression, but F_mc measures the fit of the whole factor-model 1. Its very instructive to compare the F score matrix of Pca with Fscores of FA. Fa has clearly a higher F_mc than Pca 2. the w matrix is in case of Pca an identity matrix, but in case of FA not, because in Pca F is orthonormal, in FA orthogonal 3. The F_mc is not the same as the Percentage Explained which is just the sums-of-squares of the L matrix. F_mc can be seen as a measure that validates the use of FA. When too low FA was not a valid option Happy coding!
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