LeetCode Weekly Contest 392 Solutions
Problem Set Overview
Longest Strictly Increasing or Decreasing Subarray
Lexicographically Smallest String with Distance Constraint
Minimum Operations to Make Median Equal to K
Minimum Cost Path in Weighted Graph
Longest Strictly Monotonic Subarray
The solution involves simulating the problem requirements. Two approaches are pr ...
Posted on Sun, 25 Oct 2026 16:33:14 +0000 by Diego17
Ice Car Problem: Topological Sort Solution
We are given an n x m grid representing a parking lot. Each cell contains either a car or an empty space. Car are represented by a direction they are facing: 'N' (North), 'E' (East), 'S' (South), or 'W' (West). Empty spaces are denoted by '.'. A car can be moved if and only if the path direct in front of it is clear, meaning there are no other ...
Posted on Sat, 24 Oct 2026 16:41:07 +0000 by asmon
Solutions for AtCoder Beginner Contest 369 Problems
The sample cases cover all possible scenarios for this problem.
int main() {
int x, y;
cin >> x >> y;
int result = 0;
if(x > y) swap(x, y);
if(x == y) result = 1;
else if((y - x) % 2) result = 2;
else result = 3;
cout << result << endl;
return 0;
}
</details>### Problem B - Piano Keys
Track positions for le ...
Posted on Wed, 21 Oct 2026 16:54:36 +0000 by peyups
Computing Ancestors with Coprime Values in a Tree Using DFS
Given an undirceted tree consisting of n nodes numbered from 0 to n - 1, each node has an associated value. The task is to compute for each node the nearest ancestor whose value is coprime with the current node's value.
Two numbers are coprime if their greatest common divisor (GCD) is 1.
The solution uses depth-first search (DFS) traversal stat ...
Posted on Wed, 21 Oct 2026 16:24:41 +0000 by raydona
Solving AtCoder Beginner Contest 061: A-D Problem Solutions
Problem A
Given three integers A, B, and C, determine whether C falls within the range [A, B], i.e., check if A ≤ C ≤ B.
Solution
#include <bits/stdc++.h>
using namespace std;
int main() {
int first, last, target;
cin >> first >> last >> target;
if (first <= target && target <= last)
...
Posted on Mon, 12 Oct 2026 16:53:11 +0000 by jaybones
Graph Connectivity Analysis Using Tarjan's Algorithm
Analyzing Graph Connectiivty Through Node Removal
When removing a node from a graph, we need to calculate the impact on connectivity. Each removal can create multiple connected components, requiring careful tracking of these new components.
Key Concepts
Articulation Points: Nodes whose removal increases the number of connected components
Compo ...
Posted on Thu, 01 Oct 2026 16:26:30 +0000 by Tekron-X
Tree and Graph Structures in C++ with Implementation Examples
Nonlinear Data Structures
Tree Structures
Trees represent hierarchical data relationships. Binary trees contain nodes with up to two children, while multi-way trees can have more. The topmost node is called the root.
A binary tree node typically contains:
struct BinaryNode {
int data;
BinaryNode* leftChild;
BinaryNode* rightChild;
...
Posted on Wed, 30 Sep 2026 16:35:25 +0000 by dodgeqwe
Strongly Connected Components in Directed Graphs
Graph Connectivity Concepts
A connected component in an undirected graph is a maximal subgraph where every pair of vertices is connected via a path. For directed graphs, a strongly connected component (SCC) is a maximal subgraph where every pair of vertices is mutually reachable via directed paths. SCCs are unique to directed graphs.
In DFS tre ...
Posted on Wed, 23 Sep 2026 16:54:45 +0000 by TapeGun007
Graph Theory and Union-Find Data Structure Applications in Island Problems
Maximum Island Area Problem
Given a matrix of 1's (land) and 0's (water), calculate the maximum island area. Islands consist of adjacent land cells connected horizontally or vertically.
Input:
4 5
1 1 0 0 0
1 1 0 0 0
0 0 1 0 0
0 0 0 1 1
Output: 4
The solution uses DFS or BFS to traverse each island component and count its area.
Python Impleme ...
Posted on Sat, 19 Sep 2026 16:43:05 +0000 by nitram
AtCoder Beginner Contest 012 - Problem Solutions
A - Swapping Two Integers Read two integers, swap their values, and output them on separate lines.
B - Time Conversion Given N seconds where 0 ≤ N < 86400, convert it to 24-hour time format hh:mm:ss.
The conversion formula using modular arithmetic: [N \equiv a_0 \times 3600 + a_1 \times 60 + a_2 \times 1 \pmod{86400}]
Calculate hours, minute ...
Posted on Sat, 19 Sep 2026 16:13:54 +0000 by Ryokotsusai