Array and Linked List Fundamentals for Coding Interviews

Time Complexity Basics Common time complexities sorted from fastest to slowest: O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(n³) < O(2ⁿ) < O(n!) < O(nⁿ) LeetCode Training Chinese site: https://leetcode-cn.com/problemset/all/ English site: https://leetcode.com/ Arrays Time Complexity Arrays occupy contiguous memory blo ...

Posted on Fri, 24 Jul 2026 16:11:34 +0000 by TheLoveableMonty

Balancing Code Style and Performance in JavaScript

When writing JavaScript code, what should be our primary concern? Programs are meant to be read by humans, only occasionally executed by computers. — Donald Ervin Knuth Should we prioritize coding style or efficiency? In most scenarios where extreme performance isn't required, we should focus on code style and readability to improve maintaina ...

Posted on Wed, 22 Jul 2026 17:07:26 +0000 by rachel2004

Determining Graph Connectivity using DFS and BFS

Algorithmic Approach When handling graph problems, especially those involving large datasets, an adjacency list is often preferred over an adjacency matrix to optimize memory usage, particularly when the vertex count may exceed standard limits. To determine if an undirected graph is connected, one can traverse the structure using either Depth-F ...

Posted on Sun, 19 Jul 2026 16:48:56 +0000 by Jay87

Modifying Sequence Elements in C++ with Fill, Generate, and Iota Algorithms

std::fill The std::fill algorithm assigns a specific value to every element within a defined range. It requires two iterators defining the range's bounds and the value to be assigned. This is particularly useful for re-initializing buffers or resetting data structures. #include <iostream> #include <vector> #include <algorithm> ...

Posted on Sat, 18 Jul 2026 17:13:29 +0000 by melvincr

Binary Tree Algorithms: Traversals, Pathfinding, and Search Tree Validation

Recursive Strategies: Traversal vs. Divide and ConquerRecursive solutions for binary trees typically fall into two categories:Traversal (Top-Down): The result is passed as a parameter during the recursive calls. The logic processes the node and propagates data downwards.Divide and Conquer (Bottom-Up): The result is returned by the function. The ...

Posted on Sat, 18 Jul 2026 16:59:58 +0000 by Lonepig

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

Longest Increasing Subsequence Algorithms

Longest Increasing Subsequence (LIS) The Longest Increasing Subsequence problem involves findinng the maximum length of a strictly increasing subsequence from a given sequence of length n. The subsequence elements need not be contiguous in the original sequence. Dynamic Programming Approach (O(n²)) State Representation DP array: Stores the len ...

Posted on Sat, 18 Jul 2026 16:18:30 +0000 by Rebel7284

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

Linked List Operations and Implementation Patterns in C

This document covers fundamental linked list operations including element removal, list reversal, node swapping, and intersection detection. Removing Elements with Specific Value Approach Without Dummy Node This implementation handles edge cases by checking the head node separately before processing the rest of the list. struct ListNode* remov ...

Posted on Thu, 16 Jul 2026 16:41:13 +0000 by foobar

Efficient Array Processing: Binary Search and Two-Pointer Techniques

Working with arrays is a cornerstone of algorithm development. This article delves into several effective strategies for managing and manipulating array data, including binary search for rapid element lookup and various two-pointer methodologies for in-place modifications and optimized transformations. Binary Search Binary search is an essen ...

Posted on Thu, 16 Jul 2026 16:23:40 +0000 by jumphopper