Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

# Questions tagged [fastest-algorithm]

Fastest-algorithm competitions are won by the answer with the smallest asymptotic time complexity. For challenges based on actual runtime, use [fastest-code] instead.

62 questions
Filter by
Sorted by
Tagged with
176 views

### Find run ascending lists faster

In this question I asked you to determine if a run ascending list could be made. It was code-golf so naturally most the answers are very slow. But what if we want it to be fast. In this challenge I ...
• 85.1k
398 views

### NxM List Combination Closest to Target

Given a list of N lists, each containing M positive integers, and a separate list of M positive integers (target values), return a list of N scalars (integers with a value of 0 or more) that ...
• 757
249 views

### Counting overlapping objects

Consider a NxN pixel grid with up to M objects drawn on it, either squares or diamonds: square    diamond The objects may overlap, so recognition is hard. The task is to give the minimal possible ...
175 views

### Print all digits of an integer [duplicate]

Challenge Given a positive integer, find the fastest way to iterate over its digits. Bytecode size doesn't matter as much as speed of execution. Examples For 6875, the program would output ...
579 views

### Edit distance where a substitution only costs the first time

This challenge is about the following variant of edit distance. Say we have a cost of 1 for inserts, deletes and substitutions as usual with one exception. A substitution for a given letter ...
342 views

### Leon's shooting range problem

Leon's story Leon is a professional sling shooter and he comes to a shooting range everyday to practice. A casual target is not a challenge for him anymore so before shooting he first covers the ...
• 740
527 views

### How much weight can you lift?

With all the gyms closed down with the COVID-19 situation, we have to exercise with the weight we have lying around at home. The problem is, we have a small selection of plates at varying weights, and ...
1 vote
122 views

### Minimum Hop Count in Directed Graph based on Conditional Statement [closed]

A directed graph G is given with Vertices V and Edges E, representing train stations and unidirectional train routes respectively. Trains of different train numbers move in between pairs of Vertices ...
• 173
401 views

Problem description Vertices $V$ of directed graph $G=(V,E)$ represent gossipping ladies; edge $(u,v) \in E$ signifies that lady $u$ knows of lady $v$ (which does not imply that lady $v$ ...
• 615
221 views

• 1,214
484 views

### Highest cardinality grouping of contiguous integers with minimum-sum threshold

Challenge Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the ...
246 views

### Compute my Sacred Geometry [closed]

In the tabletop RPG named Pathfinder, there is a feat that characters can take called Sacred Geometry, which allows a character who has it to buff their spells in exchange for doing some math: to use ...
• 211
103 views

### Total time to deteriorate all shielded cells [closed]

Problem: We have a two dimensional matrix of positive integer cells. On each turn any non-zero cell with a neighbor (top/bottom/left/right) of zero decreases by 1. We want count to the number of non-...
• 21
266 views

### Is this number a palindrome? [closed]

Input A single integer in your language's preferred format, e.g int or an array of digits are all acceptable. Output A truthy or falsely value, depending on ...
• 2,289
3k views

Upside-Down Pyramid Addition is the process of taking a list of numbers and consecutively adding them together until you reach one number. When given the numbers ...
• 355
270 views

### Minimum cost of solving the Eni-Puzzle

You're tasked with writing an algorithm to efficiently estimate cost of solving an Eni-Puzzle from a scrambled state as follows: You're given m lists of containing n elements each(representing the ...
332 views

### Buy the most appropriate items

A store is having a big sale. If your price reaches $199 or more, you can reduce it by$100. You can buy each product only once. Here's an example list of products: (in order to simplify, the names of ...
• 173
105 views

### determine if the circle is boxed in [closed]

Pretty simple challenge here. Who can make the fastest algorithm (lowest time complexity) to determine whether or not the circle is "boxed in" given the following setup? Input: Your program receives ...
• 131
457 views

### Meeting splitter

Introduction Large meetings waste working time. Our aim is to split a large meeting into a number of smaller meetings, so the average number topics that a person discusses is minimized but every ...
546 views

### Fastest way to perform the equivalent of an if-statement in x86 assembly

The task is simple: Create an if-statement from scratch in x86 assembly that runs in as few clock-cycles as possible. Must be x86 assembly. Can't use any of the conditional jump/branch instructions (...
• 225
556 views

### Two Dimensional Waterflow problem [closed]

The one dimensional twitter waterflow problem is this: You are given an array that represents a hill in the sense that the ith entry is the height of the ith location of the hill. When it rains, ...
1 vote
190 views

### 3-inverter with two NOT gates [closed]

Introduction I recently came across an oral exam where the candidates were asked to find a logical circuit than can negate 3 inputs A,B,C using only two NOT gates. ...
• 111
360 views

### Find elements in an array computing a given function value

Problem Description Given: a function $f(a, b, c, d, e) = \frac{a \times b}c + \frac de$ an array $x = [x_1, x_2, x_3, x_4, ..., x_n]$ of non-distinct integers a target value $k$ What is the ...
680 views

### Which number is bigger?

Define f(a,b) := a if b=1; a^f(a,b-1) if b>1 (Tetration, where ^ means power) for positive integers ...
• 12.7k
226 views

### Find the longest uninterrupted arc in N dimensions

See similar question for 2D case: Find the longest uninterrupted arc The challenge here is to find the longest uninterruped great circle arc around a unit hypersphere in N dimensions, with a random ...
• 261
492 views

### Find the longest uninterrupted arc

The challenge here is to find the longest uninterruped arc around a unit circle with a random amount of points distributed in random positions around it. Here is a diagram to assist my explanation: ...
• 261
326 views

### Fastest to find the joint

The input is an array (or space-separated string, as you wish), zero-indexed, consisting of one strictly increasing array and one strictly decreasing array (in this order, not other vice versa), each ...
• 4,733
488 views

### Remove entries from array to sort it and maximize sum of elements

This challenge is from an admission test to a closed number cyber security course. Anyway it doesn't have to do with cyber security, it's just to test the students logical and coding skills. Task ...
• 251
931 views

### Approximate floating point number with n-digit precision

We have a floating point number r between 0 and 1, and an integer p. Find the fraction of integers with the smallest ...
• 347
1k views

### remove duplicates from array [closed]

You have given an array from which we need to remove duplicates. Rules: First or immediate duplicates gets removed first. Array contains natural numbers ...
• 131
137 views

### Find the rectangle [closed]

Overview Given a 2 dimensional array of values with a filled in rectangle, find the position and size of the rectangle. Do it in the fewest array accesses as possible. Requirements The ...
• 1,025
577 views

### Total Derangement (Difficulty Level: Hard)

The problem: Write a function which, given a cycle length n and a number of cycles m, where 'm' is within ...
• 1,560
273 views

### Solve a Single Player Tron Game [closed]

Solve a Tron Game Tron is a great game, and if you haven't played it the internet has MANY online versions available. A fun challenge is to try to write an AI that plays Tron, which is normally much ...
• 8,394
1 vote
116 views

### Sequence avoiding near collision [closed]

Task Find a sequence of all numbers between min and max where every number differs from every other number in the sequence by at least "d" digits. Example of sub-sequence For min = 0, max = 1000 ...
126 views

### Quotient in base 31 numeral system [closed]

You're given two numbers a and b in base 31 numeral system and number k with no more than 10000 decimal digits. It is known that b is divisor of a. The task is to find last k 31-based-digits of ...
• 121
2k views

### Digital River (Shortest And Fastest Solution)

This is my first question, so I hope it goes well. Background: It's not the rivers that you might be thinking about. The question revolves around the concept of digital rivers. A digital river is a ...
• 427
3k views

### Find the digit occurring the most in a range of prime numbers

Find the digit which occurs the most in a range of prime numbers. Input: Two numbers, p and q, specifying the range; the range ...
249 views

### Num of pyramids possible with given number of bricks [closed]

I encountered this question in an interview and could not figure it out. I believe it has a dynamic programming solution but it eludes me. Given a number of bricks, output the total number of 2d ...
• 121
707 views

### Hard Puzzle Game Solver [closed]

There is an app called Hard Puzzle which is a game where there is a red circle, and you have to fill all of the surface area with five smaller white circles it may seen easy, but it's harder than it ...
967 views

### Heaviest increasing subsequence

A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. A strictly increasing subsequence is a subsequence ...
• 38.7k
233 views

### Add or subtract numbers to find the smallest non-negative integer [closed]

Given a positive integer, n, along with n non-negative integers, write a program or function that prints or returns the smallest ...
250 views

### Number of unique outputs by substituting variables

Given a set of formulas like this: bacb bcab cbba abbc Give an algorithm that finds the number of unique results you can get when each variable is substituted ...
• 38.7k
205 views

### Determine sets of associatively equivalent permutations of commutative operations

There are many types of binary operations, which can be categorized by their associative properties and their commutative properties. A binary operation () is ...
• 33.7k
2k views

### Fastest way to compute order of magnitude in x86 assembly

The task is simple: write assembly that computes the order of magnitude of an integer using as few clock cycles as possible. Order of magnitude is defined as log10,...
• 225
217 views

### Find the longest recurring substring [duplicate]

Given a string of no more than 255 characters, find a function that returns the longest recurring substring. An example would be: aabbacadeauaaabba where the longest recurring sub-string is aabba. ...
1k views

### Find Anagrams in the Dictionary [closed]

This a code challenge. The winner will be the person to provide the most efficient implementation of the solution in terms of algorithmic complexity. Using the dictionary found in '/usr/share/dict' (...
1k views

### A fastest algorithm optimization challenge

This is my first experiment with an asymptotic complexity challenge although I am happy with answers entirely in code as long as they come with an explanation of their time complexity. I have the ...
5k views

### Determine the move in which a LOGO turtle crosses a point that it has already visited [closed]

Situation: A turtle starts at (0, 0) on a cartesian graph. We have a non-empty zero-indexed "moves" list that contains numbers. Each number represents the distance moved. The first number is the ...
• 177