All Questions
Tagged with algorithm complexity
134 questions
5
votes
4
answers
518
views
Count number of substrings in less time
Given an input string contains letters from 'a' to 'g'
Count how many substrings are there in the input string such that
frequency of any character inside the substring is not more than the
number of ...
13
votes
5
answers
2k
views
solve n*m matrix processing in less time
I want to solve a problem in less time complexity. Here are the details:
Given an n*m matrix, n rows and m columns. Initially, the matrix is empty filled with 0s.
...
7
votes
4
answers
506
views
Traversal Heap Sort (No Extractions)
I developed a heap sort variant that sorts a heap through traversal. Unlike in the standard heap sort, the algorithm does not remove the min element from the heap instead it traverses all the nodes of ...
2
votes
2
answers
78
views
LFU cache in Kotlin
I've been working on the classic LFU (Least Frequently Used) cache running in O(1) time problem lately and, as a student, I kind of struggled with the algorithms I found online. I got most of the idea ...
5
votes
1
answer
380
views
Fast and precise summation of random numbers
I'm trying to first formulate this challenge.
In short, we want to sum up an stream of random numbers with the following objective:
The objective is "simply" to sum up as many sequences as ...
7
votes
1
answer
258
views
Colorful Subgraph Dynamic Programming Solution and a Naive One
Given a graph \$G(V, E)\$ with vertices \$V\$ and edges \$E\$, where each vertex is associated with a single color from a set of colors \$C=\{1, 2, ..., k\}\$, we define the following problem:
Problem ...
2
votes
2
answers
105
views
For two sequences N and M, display counts of elements n from N below each m from M up to the first n above m
A school's task:
There are two sequences n_tab and m_tab.
For every element m in m_tab ...
2
votes
1
answer
3k
views
Assignment function for Intervals container
I found the two related questions but they, however, do not answer my question:
interval map implementation
Where exactly does my code not adhere to the specification of the key and value type?
The ...
1
vote
2
answers
1k
views
Leetcode 55. Jump Game solution
I was working on Jump Game problem on leetcode
Question
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your ...
1
vote
2
answers
459
views
Algorithm for twoSum
This is my PHP algorithm for the twoSum problem in leetCode:
...
0
votes
1
answer
107
views
Time complexity of several methods of reversing a domain name string
Note: I'm aware of this existing post which is similar. However, it does not address all my questions sufficiently.
I have the following three functions, all of which do the same thing: reverse a ...
2
votes
2
answers
299
views
Find the highest product of three numbers in a list (Python)
I wrote the below as a solution to:
Problem
Find the highest product of three numbers in a list
Constraints
Is the input a list of integers?
Yes
Can we get negative inputs?
Yes
Can there be ...
3
votes
1
answer
268
views
Find the largest decrease in a sequence of numbers
I have written a function that takes as input a list of 5 numbers, then the program's goal is to return the largest drop in the list. It is important to understand that [5, 3, ...] is a decrease of 2 ...
1
vote
3
answers
227
views
Finding unique top sums from multiple lists
My question arises from this post on MSE where I have provided an answer to solve the question :
There are multiple lists given. The number of lists is arbitrary.
Each list contains numbers and is ...
3
votes
1
answer
128
views
Substring search in Java
I am trying to make an algorithm that will find the index of a given substring (which I have labeled pattern) in a given String (...