Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

I'm working on implementing the iterative (non-recursive) version of dfs. I'm confused when to mark a node as visited: at push or at pop. In bfs, we mark visited when pushing it to queue, so it seems ...
jeremy0519's user avatar
Advice
0 votes
4 replies
111 views

I want to learn Data Structures, Algorithms, and Big-O notation from scratch, but there are too many resources online and it’s difficult to determine which ones are trustworthy or widely used by ...
quantumlattice's user avatar
Advice
0 votes
10 replies
96 views

Suppose there is an array of length 16. It contains four letters of four types: 4 a's, 4 b's, 4 c's, and 4 d's. For example, start = ['a', 'c', 'b', 'd', 'a', 'a', 'b', 'b', 'b', 'c', 'd', 'c', 'c', '...
Paul R's user avatar
  • 2,837
-8 votes
0 answers
84 views

I am a student in first year of computer science, and for my semester project I have to create a 2D game with mazes. I have to write an algorithm that creates mazes using the recursive division, and I ...
rojin yaygir's user avatar
Advice
0 votes
6 replies
111 views

While studying binary search, I intuitively connected it to the idea that a normal distribution concentrates probability mass near the center. Binary search always examines the midpoint first, which ...
lucia_x.j.x_alcul's user avatar
Advice
1 vote
5 replies
106 views

I'm into a little weird task in a project I'm making, the project is about a family and one section shows the family tree. this family tree is drawn by hand previously and it lacks too many family ...
Sarout's user avatar
  • 904
0 votes
0 answers
62 views

I have a game with a frame counter which increments at a fixed rate, and my goal is for two instances of the game on different computers to sync this number so that they will have the same number at ...
Henry C's user avatar
  • 59
Advice
0 votes
2 replies
66 views

I have a problem where I need to cut off text based on a max length. But the inputted string could be html a la <p>hello</p>. the html tags do not count towards the max length. for example ...
Jacob Pecile's user avatar
4 votes
1 answer
162 views

I've been working on implementing some compression algorithms in C/C++ and JavaScript, I've started by building out LZSS. So far everything seems good. I check my dictionary buffer for matches, and if ...
Mornig Star's user avatar
Advice
1 vote
8 replies
141 views

Found this code exercise on W3R. Been trying to figure out the relationship between the outer and inner loop (i and j), but can't seem to wrap my head around it. If anyone could walk me through this ...
Stanislav Matveyevich's user avatar
2 votes
1 answer
123 views

I’m trying to solve the following Leetcode problem: You are given a 2D integer array intervals where intervals[i] = > [starti, endi] represents all the integers from starti to endi inclusively. A ...
Utkarsh Mishra's user avatar
0 votes
1 answer
215 views

I'm interesting in possible implementation approaches for a quite special variant of a list, with the following requirements: Efficient inverse lookup ("index of"): "give me an index ...
cubuspl42's user avatar
  • 8,621
Advice
1 vote
4 replies
86 views

I want to implement in python some algorithms from a paper that allow for a pre-trained neural network to be modified (adding or removing neurons or layers) conserving (theoretically) the outputs of ...
Rubén Sales Castellar's user avatar
6 votes
2 answers
363 views

I'm working on a problem where I need to count, for each possible common difference D, the number of contiguous subarrays whose elements can be rearranged to form an arithmetic progression with common ...
YAR's user avatar
  • 63
0 votes
0 answers
84 views

In the code block below is my current Negamax implementation, it is currently barebones. My question is why do Blocks 1 & 2 have to occur for a node that is expected to incur a beta-cutoff (i.e. ...
VHDLover's user avatar
0 votes
2 answers
81 views

I've been trying to teach myself various sort methods just for the sake of being able to use them in the future and right now I've been teaching myself about shell sorts. I understand the way shell ...
Neptunium-Eater's user avatar
0 votes
0 answers
62 views

I am working on a program that is supposed to build a tree using nested lists in Racket. I believe I am very close, but I am stuck on one section of my insertion testing process. The syntax for my ...
JoshLeonthe1st's user avatar
Advice
0 votes
3 replies
72 views

The context is implementing conversion functions between Gregorian calendar dates and Julian dates. Most (nearly all?) such implementations have restrictions on the dates - typically requiring that ...
John's user avatar
  • 1,673
0 votes
2 answers
118 views

I am trying to understand Wallace Trees. The algorithm goes multiply each bit of one number a by each bit of the other (b), which is accomplished as a simple AND gate, where the partial product of ...
yosmo78's user avatar
  • 641
2 votes
1 answer
208 views

The inverse of the gamma function over the reals is multivalued with an infinite number of branches. This self-answered question is about the principal inverse of the gamma function, Γ0-1(x), whose ...
njuffa's user avatar
  • 27.1k
-3 votes
1 answer
191 views

The algorithm I've written for an assignment is closely related to this monotonic stack approach https://www.geeksforgeeks.org/dsa/next-greater-element/ Best case: n pushes → Time complexity: O(n) ...
user29898's user avatar
2 votes
1 answer
162 views

Problem: We are given a list of integers of length n. What is the minimum number of elements whose sign you need to flip such that every prefix sum is non-negative? (A prefix sum is the sum of the ...
Marc Carlsan's user avatar
2 votes
1 answer
146 views

I am trying to implement Quick Sort in GNU COBOL (version 3.2.2) using a recursive subprogram. The sorting logic is standard and works perfectly in other languages (C, Python), but when I run it in ...
TranTrung's user avatar
1 vote
1 answer
322 views

I'm trying to implement the Cooper–Harvey–Kennedy algorithm from this paper in C++. The original is used to find dominators, however in my case I need to find the postdominators. For this, I am aware ...
DeepQuantum's user avatar
9 votes
3 answers
413 views

Consider an array of a permutation P of length n (n > 2), namely some order of the integers 1 through n. Example of P with length n = 7, [6,5,2,3,7,1,4] A "score" of a permutation is ...
user31824378's user avatar
-2 votes
1 answer
189 views

I’m trying to implement an in-place Quick Sort in Python. I have two slightly different versions of my partitioning logic, and I’m confused because both seem correct on small arrays, but the second ...
Lisguen's user avatar
  • 11
6 votes
3 answers
401 views

I've got a list P of 2-dimensional points, 100 ≤ |P| ≤ 100000, and a list C of circle centers, 100 ≤ |C| ≤ 100000. All coordinates (x,y) ∈ P or (x,y) ∈ C are integral, 0 ≤ x,y ≤ 4095. P and C may ...
hidefromkgb's user avatar
  • 6,012
2 votes
1 answer
140 views

I am tasked with a question as follows: We have n players and we want to hold a wrestling tournament with exactly n * (n - 1) / 2 matches. In each day a player can only play at most one match. However,...
Eastern Skill's user avatar
-2 votes
1 answer
101 views

I have a Set of 2D points that I want to create a set of areas from, similar to a Voronoi Diagram. The difference is that I would like these areas to be blended, like in the following image. I wouldn'...
CptHavvock's user avatar
2 votes
1 answer
123 views

I need a really fast vectorized maximal independent set algorithm implemented in pytorch, so I can use it for tasks with thousands of nodes in reasonable time. I cannot use networkx, it is way too ...
Kemsikov's user avatar
  • 640
-2 votes
1 answer
119 views

I’m developing a Qur’an search application that allows users to search for Arabic words and find their occurrences across the Qur’an. To improve accuracy, I added a feature that removes Arabic ...
Salma Ahmed's user avatar
3 votes
3 answers
192 views

The problem: Given an array in which the number of negative elements is equal to the number of positive elements (arranged in arbitrary order). Swap the first negative and the first positive, then ...
user567_9's user avatar
2 votes
2 answers
145 views

Wikipedia and other textbooks reference binary selection sort's asymptotic worst-case time complexity to be O(n^2), usually justifying this with any extra computation caused by swaps. I don't ...
PostalCat's user avatar
6 votes
3 answers
250 views

I have an array x of n >= 4 elements, at indices 0..n-1. I want to swap the elements at indices j and k, where 0 <= k < j < n with the elements at indices 0 and 1 (it doesn't matter ...
The Lost Petrol's user avatar
-3 votes
1 answer
100 views

Analysis of Google Fonts Here is me scrolling through the Greek fonts As you scroll, you'll see it progressively calls the css2 url like: https://fonts.googleapis.com/css2?family=STIX%20Two%20Text%...
Lance Pollard's user avatar
2 votes
1 answer
129 views

I have a room that is a box. There is a single rectangular window on one of the walls of the room. A directional light source is shining into the room through the window. The light source has a ...
nj16's user avatar
  • 133
-3 votes
1 answer
158 views

Please be merciful - I've never asked a question here (I've answered a few) and am a total Python noob. I developed an algorithm in SQL Server to compute the Longest Possible Common Subsequence (LPCS) ...
Alan Burstein's user avatar
5 votes
3 answers
225 views

I implemented a recursive solution in Python to check if two binary trees are identical, which traverses nodes recursively and compares values and structure. The time complexity is O(n), space O(h). ...
Jared McCarthy's user avatar
8 votes
1 answer
243 views

Parallel policy states that order of iterator evaluation is not guaranteed. However, std::find*, std::search and std::mismatch all say that they return first iterator matching condition. How do those ...
Dominik Kaszewski's user avatar
3 votes
2 answers
551 views

Given StartTime and endTime for N employees, an employee can form a team if his working hour overlaps with other employees' (both startTime and endTime inclusive). Find the maximum team size. Example: ...
QA Android Alfa's user avatar
4 votes
1 answer
312 views

I was reading the paper Beam-Stack Search: Integrating Backtracking with Beam Search by Rong Zhou and Eric A. Hansen and I was attempting to implement it in Java (see PathFinding.java repository in ...
coderodde's user avatar
  • 967
0 votes
0 answers
97 views

I have a bunch of data which is indexed by key/value pairs. For example I might have x=1, y=2, z=3 => data="1,2,3" and x=1,y=2 => data="1,2" etc. The operations I need to ...
Mumrah's user avatar
  • 422
0 votes
0 answers
72 views

Recently, I developed a MATLAB-based simulation to evaluate my robot pathfinding algorithm. The robots operate on a network of unidirectional tracks, where each robot computes a single path from its ...
CangWangu's user avatar
  • 181
8 votes
3 answers
303 views

The problem is to find the longest sequence of numbers from 1 to 100 such that each number is either multiple or divisor or the previous, and with no repetition. For example, 50 25 5 35 7 63 21 is a ...
Zorm's user avatar
  • 81
1 vote
3 answers
110 views

I’m writing a chess engine in C++ that communicates via the UCI protocol, and I need an efficient way to check whether the allocated search time has been exceeded without adding too much overhead. The ...
Viliam Holly's user avatar
1 vote
1 answer
112 views

The current problem I'm having is that when the code runs it shows me "None" in the terminal. /usr/local/bin/python3.12/Users/jaredmccarthy/Desktop/2025/ejercicios_leetcode.py None Process ...
Jared McCarthy's user avatar
1 vote
1 answer
81 views

Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). What's the problem with the following implementation? How to fix it?...
peter8015's user avatar
2 votes
0 answers
118 views

I'm researching about maintaining order in a list like JIRA, and I come across Jira Lexorank. I've already understood it's core concept, but there are 2 questions that I struggle to find the in depth ...
nanh's user avatar
  • 51
5 votes
2 answers
253 views

Okay, here's the problem I have. I'd like to do something like this: V(n,k) generates all n-sized permutations in which each permutations contains all digits from 0 to k-1 in lexicographic order. V(2,...
Reptorian's user avatar
-2 votes
2 answers
150 views

I have an application where I have a Rule object that has a list of Filter predicates. I will be comparing many Events to the predicates, and want to know if they all match. Most Events will not match ...
Andrew Rueckert's user avatar

1
2 3 4 5
2430