Skip to main content

Questions tagged [complexity]

Complexity is the analysis of how the time and space requirements of an algorithm vary according to the size of the input. Use this tag for reviews where the "Big O" is a concern.

2 votes
2 answers
58 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 ...
NicolaM94's user avatar
5 votes
1 answer
369 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 ...
user24714692's user avatar
2 votes
1 answer
184 views

Hackerrank "New Year chaos" solution - permute sequence by swapping adjacent terms

I was doing the Hackerrank "New Year chaos" problem. Here is the description: It is New Year's Day and people are in line for the Wonderland rollercoaster ride. Each person wears a sticker ...
user12138762's user avatar
5 votes
2 answers
556 views

Simplify complexity [closed]

I came across this question which asks to create a function which will return true/false based on the passed array containing all the letters to make up the passed word. Each letter from array can ...
user282070's user avatar
7 votes
1 answer
251 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 ...
FluidMechanics Potential Flows's user avatar
4 votes
1 answer
132 views

Longest spell to cast from pages of spellbook follow-up

This question is from the PCTC 2022 R2 Past Paper and is a follow-up on my previous question. Previous question I have implemented several solutions suggested, such as creating an array with pages ...
helielicopter123's user avatar
6 votes
4 answers
568 views

Longest spell to cast from pages of spellbook

While practicing for a school coding challenge, I came across this problem. My code got the right answers but exceeded the time limited. Any tips for how to reduce the time complexity? https://pctc....
helielicopter123's user avatar
4 votes
3 answers
587 views

Leetcode 3sum problem solution

The problem is: Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] where ...
Oliver's user avatar
  • 41
3 votes
1 answer
128 views

Handwriting progressive drawing

Implementation to progressively draw symbols, when provided with symbol implementations it supports any type of symbols, though for the review purpose just two hand written latin symbols are supported ...
user avatar
-2 votes
2 answers
79 views

complexity reduction (refacto) [closed]

I'm trying to reduce the complexity of this piece of code following a SonarQube error. I have several similar blocks, and even if I try to extract them into private methods, the Sonar error persists. ...
goujon's user avatar
  • 11
3 votes
2 answers
544 views

One Piece Treasure- Find the number of palindromic substrings in a large substring

I'm trying to solve the below question: A string of characters X (all in lowercase) of length n is present. We can ask a query <...
driver's user avatar
  • 232
1 vote
1 answer
106 views

Binary search of 2D matrix

I have written code as below: ...
Szyszka947's user avatar
3 votes
2 answers
114 views

Quickselect algorithm implementation and its time-complexity

I wrote this code to find kth smallest element in the array by renowned algorithm quickselect. Here is the link where you can see the working code. What points are there to be improved? Could you ...
Soner from The Ottoman Empire's user avatar
1 vote
1 answer
341 views

Finding highly correlated variables in a dataframe by evaluating its correlation matrix's values

I read data from Excel into a Pandas DataFrame, so that every column represents a different variable, and every row represents a different sample. I made the function below to identify potential ...
Pimsel's user avatar
  • 25
2 votes
2 answers
95 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 ...
Szyszka947's user avatar

15 30 50 per page
1
2 3 4 5
28