LeetCode Weekly Contest 169 Solutions
Problem 1: Find N Unique Integers Sum up to Zero
Given an integer n, any array of n unique integers that sum to 0 can be returned.
Example 1:
Input: n = 5
Output: [-7,-1,1,3,4]
Explanation: These arrays are also correct [-5,-1,1,2,3], [-3,-1,2,-2,4].
Example 2:
Input: n = 3
Output: [-1,0,1]
Example 3:
Input: n = 1
Output: [0]
Constraints:
1 &l ...
Posted on Tue, 03 Nov 2026 16:11:59 +0000 by Zoud
LeetCode Algorithm Problems: Bulb Switcher III, Employee Notification Time, and Frog Position
Bulb Switcher III
There are n bulbs arranged in a line, numbered from 1 to n from left to right. Initially, all bulb are turned off.
At time k (where k ranges from 0 to n-1), we turn on the bulb at position light[k].
A bulb turns blue when both conditions are met:
The bulb is currently on
All bulbs to its left are also on
Return the number of ...
Posted on Sun, 01 Nov 2026 16:31:11 +0000 by ceanth
Checking Symmetry in Binary Trees: Recursive and Iterative Approaches
LeetCode Problem Link
Problem Description:
Given the root of a binary tree, check whether it is symmetric around its center. A binary tree is symmetric if the left subtree is a mirror reflection of the right subtree.
Example 1:
root = [1,2,2,3,4,4,3]
Output: true
Example 2:
root = [1,2,2,null,3,null,3]
Output: false
Approach Analysis
To determi ...
Posted on Tue, 27 Oct 2026 16:44:12 +0000 by Assorro
Essential Binary Tree Operations: Finding Bottom Left Value, Path Sum Variations, and Inorder-Postorder Construction
Finding the Bottom Left Tree ValueLocating the leftmost value in the last row of a binary tree can be efficiently achieved using Breadth-First Search (BFS). By processing the tree level by level, the first node encountered at each depth represents the leftmost node for that specific row. Upon completing the traversal, the value recorded for the ...
Posted on Sun, 18 Oct 2026 16:30:55 +0000 by batman
Essential Binary-Tree Algorithms and Their Implementations
In-Order Traversal
Recursive
List<Integer> inorder(TreeNode node) {
List<Integer> out = new ArrayList<>();
walk(node, out);
return out;
}
void walk(TreeNode cur, List<Integer> acc) {
if (cur == null) return;
walk(cur.left, acc);
acc.add(cur.val);
walk(cur.right, acc);
}
Iterative (Single Sta ...
Posted on Mon, 21 Sep 2026 16:25:53 +0000 by otterbield
Connected Components, Team Formation, and Zero-Sum Subarray Algorithms
Identify isolated groups of zeros in a grid that do not border grid edges. Traverse connected components using BFS while tracking boundary collisions.
#include <vector>
#include <queue>
#include <iostream>
int main() {
int rows, cols;
std::cin >> cols >> rows;
std::vector grid(rows, std::vector< ...
Posted on Fri, 11 Sep 2026 16:10:40 +0000 by mcdsoftware
CSP-S 2022 Solutions
The problems in this set require careful handling of edge cases and efficient algorithms. Below are the solutions for all four tasks.
T1: Holiday Plan
Given constraints n ≤ 2.5 × 103, an O(n2) approach is feasible.
We enumerate the middle two vertices B and C. For a valid pair (B, C), we pre‑compute the set of possible A (from B) and possible D ...
Posted on Thu, 10 Sep 2026 16:44:49 +0000 by dscapuano
Solving the Pushing Boxes Problem with Single Priority Queue BFS
The UVA589 problem requires finding the optimal path to push a box to a target location. The optimization criteria have two levels: primarily minimizing the number of pushes, and secondarily minimizing the total number of moves when push counts are equal.
Key Problem Constraints
The primary objective is to minimize push operations, not walki ...
Posted on Mon, 24 Aug 2026 16:45:15 +0000 by seodevhead
Floyd Algorithm for Graph Shortest Path and BFS with A* for Knight Moves
Floyd Algorithm for All-Pairs Shortest Path
Implement Floyd's algorithm to compute shortest paths between all pairs of vertices in an undirected weighted graph. The graph is defined by vertices labeled from 1 to n and m edges with positive weights. For multiple queries, output the shotrest distance betwean two vertices or -1 if no path exists.
...
Posted on Sun, 23 Aug 2026 16:52:46 +0000 by Warmach
Competitive Programming Problem Solutions: BFS, String Manipulation, and Mathematical Logic
This problem involves a BFS simulation on an ice floor grid. The movement mechanics require sliding in a chosen direction until hitting an obstacle. The algorithm explores four directions from each position, continuing to slide until a wall is encountered, at which point the stopping position becomes a new node in the traversal.
Key implementat ...
Posted on Thu, 20 Aug 2026 16:34:01 +0000 by jj33