CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 02:20:42 GMT
content-type: text/html; charset=utf-8
cf-ray: 9658a8b7595c755c-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=df78702d-d70c-4f2d-8fca-ed8aaae3e726; expires=Mon, 27 Jul 2026 02:20:41 GMT; domain=.stackoverflow.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
vary: Accept-Encoding
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
feature-policy: microphone 'none'; speaker 'none'
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: 8a5a8067-95cd-4600-8140-7bdce4423953
x-worker-origin-response-time: 705000000
x-dns-prefetch-control: off
set-cookie: __cflb=02DiuFA7zZL3enAQJD3AX8ZzvyzLcaG7wBwtXmTpb6ynk; SameSite=Lax; path=/; expires=Mon, 28-Jul-25 01:20:42 GMT; HttpOnly
set-cookie: prov=df78702d-d70c-4f2d-8fca-ed8aaae3e726; Path=/; HttpOnly; Domain=stackoverflow.com
set-cookie: __cf_bm=EmeIWazC6YsSJmLRR0sRNLR4NTdBuUZi0Lu4JdtzU1o-1753582842-1.0.1.1-ICMWltGIjzr5f_ZfWIl1QXSsUbeqGpXmQD.PMCyyDf2ag2L.H6VLG3im5FIY81CTY4K6tYZVy0YamrG.Da_zdbZLJGu1oU8cVVxe1EAzrc8; path=/; expires=Sun, 27-Jul-25 02:50:42 GMT; domain=.stackoverflow.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=mBolv2smrK7M4YmCB.beh458JXTznIL9ny1nMJRbBxM-1753582842214-0.0.1.1-604800000; path=/; domain=.stackoverflow.com; HttpOnly; Secure; SameSite=None
server: cloudflare
content-encoding: gzip
Newest 'algorithm' Questions - Stack Overflow
Skip to main content
Stack Overflow
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Advertising Reach devs & technologists worldwide about your product, service or employer brand
- Knowledge Solutions Data licensing offering for businesses to build and improve AI tools and models
- Labs The future of collective knowledge sharing
- About the company Visit the blog
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
121,500 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
1
answer
149
views
Efficient way to check digits in a number
This is an interview question. Given 3 array lists holding non negative integers, pick a number from each list and find the sum, check if the sum holds only digits 5 and 8
Here is my code:
Example:
...
-4
votes
0
answers
140
views
Dijkstra's algorithm with speed boost cells [closed]
Trying to solve problem Ace Race in codeforces
Given a racetrack with N nodes starting from 1 to N
For a normal node, x, it is possible to move to x - 1 or x + 1 in 2 seconds (for x = 1 then only x = ...
-5
votes
0
answers
43
views
What matching algorithm generates attacker–defender pairs in RL game event logs? [closed]
Context
Domain: RL (Reinforcement Learning) tactical multiplayer game, custom protocol
Server/Engine: Proprietary RL tactical event protocol server
Date: July 2025
Protocol Design: For each event, the ...
-3
votes
0
answers
70
views
Python recursion prints all elements repeatedly instead of printing each elements on the new line called by the function [closed]
I'm trying to write a recursive function that prints all the elements from the list but the output is not what I expected. It first prints the numbers infinity (1)... and then crashes.
So what am I ...
1
vote
0
answers
48
views
What are fast GPU algorithms for sequential bin packing? [closed]
I have a sequence of bags in a row, each with a different size up to 256. I would like to pack these bags into bins of size 256.
For example, the bags might be 124, 12, 45, 63, 150, 72, 230. I'd like ...
-2
votes
4
answers
129
views
How can I optimize the time complexity of my brute-force solution for finding all unique triplets with sum zero?
I'm solving the "3Sum" problem where I need to find all unique triplets in an array that sum to zero.
Here’s my brute-force Java code:
public List<List<Integer>> threeSum(int[] ...
-2
votes
3
answers
199
views
LeetCode - 23. Merge k Sorted Lists algo issue
I was trying to solve this LeetCode Problem, and have been failing at it.
The problem
You are given an array of k linked-lists lists, each linked-list is
sorted in ascending order.
Merge all the ...
-3
votes
0
answers
95
views
matching pair with constraint [closed]
I have the following question that I have been asked in my interview. I gave a simple solution (see below) but apparently that was not correct. I have been told that there is a greedy solution for ...
0
votes
2
answers
170
views
How can I optimize a Python loop that counts maximum frequency of elements? [closed]
I'm working on a Python function to find the most frequent element in a list and handle ties in a specific way.
a = [1, 2, 2, 3, 3, 3, 4]
s = 0
count = 1
for i in set(a):
if a.count(i) == s:
...
-2
votes
0
answers
34
views
Puzzle swap system alghorithm [closed]
I make a swap system puzzles. So, I have a gid (n x n). So, lets take 3 x 3. And I need to swap the group of tiles. It's easy if the figures are the same height and width.
But there are cases when ...
1
vote
0
answers
54
views
Median Position in a Min-Heap can be found at any level - need proof [closed]
I need to prove that the median value in a minimum heap with distinct values can be found at any level.
It sounds right intuitively and I can give examples, but not sure how to approach this proof, ...
4
votes
3
answers
161
views
Count how many adjacent elements satisfy a predicate
Given a std::vector named v and a predicate p that takes two elements and returns a bool, what is the idiomatic way to count how many adjacent elements in v satisfy p?
The obvious way is to use a loop:...
0
votes
2
answers
224
views
What is the time complexity of the following algorithm:
int k = 0;
for (int a = n; a >= 1; a /= 2)
for (int b = a; b >= 1; b--)
k++;
cout << k;
I would say that the answer is O(n), but the book where I have found the exercise says that ...
5
votes
2
answers
122
views
C How to generate an arbitrary permutation within range [i,j]?
Does C standard library provide any function that generate a random permutation of consecutive numbers within a range?
How to make a function that efficiently does it? I'm thinking of making a random ...
-1
votes
2
answers
155
views
Is there a faster method to compute these distance-based sums over a nonuniform grid of cells?
I'm attempting to implement an algorithm to compute an array of values. Unfortunately, I've found the literal implementation of that algorithm to be too slow for my use case. I suspect there's an ...
- The Overflow Blog
-
-
- Featured on Meta
-
-
-
-
-
Related Tags
java × 15373
python × 13878
c++ × 12761
data-structures × 9367
arrays × 8215
sorting × 8120
javascript × 6743
math × 6131
c × 5853
c# × 5362
graph × 4952
time-complexity × 4899
recursion × 4386
dynamic-programming × 3352
string × 3291
big-o × 3258
performance × 3121
tree × 2869
optimization × 2860
php × 2250
search × 2237
language-agnostic × 1948
geometry × 1918
graph-theory × 1881
graph-algorithm × 1854
more related tags
Hot Network Questions
- Why does the node Bounding Box suddenly produce a different result in version 4.5?
- Word order for a phrase with a number, adjective and noun
- Has the Silver Surfer's clothing (or lack thereof) ever been addressed in the comics?
- Why exactly do full-flow rocket engine's turbopumps run cooler?
- How to navigate in the Universe's Heat Death
- How do Japanese people understand the reading of a single kanji with multiple readings in their everyday life?
- Forces applied to a car hood while driving
- Not being introduced to the team – should I ask for it?
- What's the difference between an eVisa and ETA travel authorization?
- In Jurassic Park, is the lysine dependency intentionally fake (in-universe)?
- Story that taught cryptography in the form of a manga
- spots / stains on tubeless tire
- Why is 0.0 printed as 0.00001 when rounding upward?
- In Fantastic Four 2025 shouldn't this thing have taken years?
- Why does my laptop's display turn off when I'm away from the keyboard?
- How to put commutative symbol in a commutative diagram?
- Alternative to tedious assert-rewrite for trivial operations?
- Why am I winning always? A coincidence perhaps?
- I am looking for a French mathematician who contributed to complex analysis
- Meaning of 芭蕉 in Tang age
- Automatic drawing of polygon around selected polygons in QGIS
- Does SZNUD3160 really eliminate the need for diode?
- Not your ordinary affix riddle
- Are classified documents subject to a subpoena in discovery?