Understanding C# Arrays: One-Dimensional and Rectangular Arrays
Array Definition
An array is a data structure that contains a fixed number of elements of the same type. Each individual item within an array is called an element. The number of dimensions an array has is known as its rank. The size of each dimension is its length, and the total number of elements across all dimensions is the array's length. ...
Posted on Thu, 23 Jul 2026 17:00:52 +0000 by Hodo
Linked List Operations and Array-Based Implementations
Header File Inclusion
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
Data Type Defniition
Using a type alias improves maintainability and simplifies type changes across the codebase:
typedef int ElementDataType;
Node Structure Definition
typedef struct ListNode {
ElementDataType value;
stru ...
Posted on Tue, 21 Jul 2026 16:18:22 +0000 by iskawt
Fundamental Algorithmic Patterns and Code Templates for Competitive Programming
Binary Search Methodologies
Integer binary search typically relies on partitioning a range [left, right] based on a predicate function. Two common partitions are used depending on whether the midpoint belongs to the left or right sub-interval.
// Partition: [left, pivot] | [pivot + 1, right]
int find_first_valid(int left, int right) {
while ...
Posted on Sat, 18 Jul 2026 16:57:35 +0000 by kmutz22
Implementing a Priority Heap in Java
This article focuses on implementing a min-heap, which has the property that every parent node is less than or equal to its children. This ensures the smallest element is always at the root (index 1 in our array).
Heap Operations
A min-heap implementation should support these basic operations:
Insertion (I): Add a new element to the heap while ...
Posted on Fri, 17 Jul 2026 16:48:25 +0000 by Gonwee
AtCoder Beginner Contest 352 Solutions
Problem A - AtCoder Line Straightforward check: determine whether point z lies between x and y on the number line. Simply swap if necessary to ansure x ≤ y, then verify the condition. Click to view code
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int n, p, q, r;
scanf("%d%d%d%d", & ...
Posted on Thu, 16 Jul 2026 17:03:34 +0000 by craigbabe
Redis Internal Storage Architecture and Data Structures
Redis Storage Structure
Value Encoding Types
Redis automatically selects the most efficient encoding format based on the characteristics of stored data:
String
int: String length ≤ 20 and convertible to integer
raw: String length > 44
embstr: String length ≤ 44
List
quicklist: Optimized linked list structure
ziplist: Compressed list for ...
Posted on Thu, 16 Jul 2026 16:59:55 +0000 by jeff2007XP
AtCoder Beginner Contest 014 - Problem Solutions
Problem A
Given a snacks to distribute equally among b people. Snacks cannot be divided. Find the minimum number of additional snacks that need to be purchased.
Solution
Each person requires ceil(a/b) snacks. Therefore, the total snacks needed is ceil(a/b) * b. The additional snacks required is ceil(a/b) * b - a.
int snacks, people;
std::cin &g ...
Posted on Tue, 14 Jul 2026 17:33:54 +0000 by ypkumar
Efficient Counter Implementation with Bit Arrays and Amortized Analysis
To implement a counter supporting both increment and reset operations in O(n) amortized time, we utilize a bit array along with a pointer tracking the position of the most significant set bit.
The data structure maintains:
A binary array bits representing the counter value
An index top_bit pointing to the highest-order 1-bit
For the increment ...
Posted on Tue, 14 Jul 2026 16:43:09 +0000 by stangoe
A Quick Introduction to Python and Jupyter Notebook
Setting Up Jupyter Notebook
Launch Jupyter through a terminal session. Before starting, create and activate a dedicated Conda environment:
conda create -n myenv python=3.10
conda activate myenv
jupyter notebook
Python Syntax Essentials
Multiple statements can be placed on one line by separating them with a semicolon:
print('hello'); print('wor ...
Posted on Sun, 12 Jul 2026 17:06:44 +0000 by CoB-Himself
Essential LeetCode Problems with Optimized Solutions
Two Sum
Use a hash map to store each number’s index. For every element, check if the complement (target - current) exists in the map.
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
seen = {}
for idx, val in enumerate(nums):
complement = target - val
if complement in se ...
Posted on Wed, 08 Jul 2026 17:19:04 +0000 by xeidor