Heap Sorting and Comparator Usage
Heap Sorting
Given a unsorted array, heap sort transforms it into a descending sequence:
Convert the array into a max heap using heap insertion or heapify operations
Repeatedly swap the root element with the last position, reduce heap size, and re-adjust
Continue untill heap size reduces to zero
Heap Construction Methods
Forward Traversal wit ...
Posted on Sat, 06 Jun 2026 16:25:05 +0000 by will35010
Singly Linked List Reversal: Iterative and Recursive Solutions for LeetCode 206
Problem Statement
Given the head of a singly linked list, reverse the order of all nodes in the list and return the head of the reversed list.
Sample Input 1:
head = [1,2,3,4,5]
Sample Output 1:
[5,4,3,2,1]
Sample Input 2:
head = [1,2]
Sample Output 2:
[2,1]
Sample Input 3:
head = []
Sample Output 3:
[]
Constraints:
The number of nodes i ...
Posted on Sun, 31 May 2026 19:45:10 +0000 by cowboysdude
Linked List Algorithms from Code Thinking Record
Table of Contents
Introduction
Remove Linked List Elements (LeetCode--203)
Design Linked List (LeetCode--707)
Reverse Linked List (LeetCode--206)
Swap Nodes in Pairs (LeetCode--24)
Remove Nth Node From End of List (LeetCode--19)
Linked List Cycle II (LeetCode--142)
Introduction
Following the Code Thinking Record series, this article explores ...
Posted on Sun, 31 May 2026 19:14:58 +0000 by gingerboy101
Simple Graph Theory and Construction
Simple Graph Theory and Construction
A
Consider vertices with weight 2 as adding one to vertices with weight 1. Thus the problem is split into two parts: constructing the tree and adding one to vertices.
In the first part, constructing the tree as balanced as possible is beneficial, as will be shown in the second step.
Construction:
Process DFS ...
Posted on Sun, 31 May 2026 16:28:06 +0000 by twostars
Dynamic Programming: Solving Multi-State Problems
The Massage Therapist Scheduling Problem
Problem link: https://leetcode.cn/problems/the-masseuse-lcci/
A renowned massage therapist receives a continuous stream of appointment requests. Each appointment can be accepted or declined. Due to the need for rest periods between sessions, she cannot accept consecutive appointments. Given a sequence of ...
Posted on Sat, 30 May 2026 19:39:23 +0000 by stelthius
Implementing a Positional PID Controller in Python
Proportional-Integral-Derivative (PID) controllers are widely used in industrial control systems to maintain a desired output value by adjusting a control input. A PID controller continuously calculates an error value as the difference between a desired setpoint and a measured process variable. It then applies a correction based on proportional ...
Posted on Fri, 29 May 2026 23:46:45 +0000 by scifo
2012 NOIP Popularization Group Finals Walkthrough
Task 1 – Factor Splitting
Given a positive integer n that is the product of two distinct primes, output the larger one.
Input: One integer n (≤ 2·109).
Output: The larger prime factor.
Observation: The first divisor (other than 1) must be the smaller prime, so the answer is n / i once the smallest i > 1 with n % i == 0 is found.
#include < ...
Posted on Thu, 28 May 2026 22:28:35 +0000 by dannyd
Extracting and Summing Monetary Values with Decimal Formatting in C
This problem involves parsing a continuous string to identify and sum numerical values, handling both integers and decimals, then printing the result with proper thousand separators and rounding.
Input Parsing
Since the input contains no spaces, the entire sequence can be read into a character buffer using standard input functions.
char buffer[ ...
Posted on Tue, 26 May 2026 00:01:07 +0000 by mr.rum
AtCoder ABC 069 Solutions
Problem A - 4
Question
With (n) horizontal lines and (m) vertical lines drawn on a plane, how many axis-aligned rectangles are formed that contain no interior lines?
Solution
Consider each dimension independent.
Along any straight line, (n) distinct points partition the line into (n - 1) segments. These segments serve as the edges of our rectan ...
Posted on Fri, 22 May 2026 20:05:22 +0000 by suresh1
Optimizing Team Performance with a Greedy Priority Queue Approach
Problem Definition
The objective is to select a team of at most k engineers from a pool of n candidates to maximize the team's performance metric. This metric is defined as the sum of the selected engineers' speeds multiplied by the minimum efficiency value among them. Given arrays representing the speed and efficiency of each engineer, the ta ...
Posted on Fri, 22 May 2026 17:41:14 +0000 by Rik Peters