# 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.

388 questions
Filter by
Sorted by
Tagged with
131 views

### Transpose 2D Matrix in Java - Time & Space Complexity?

Here's my algorithm / approach for transposing a 2D Matrix on the main diagonal. Before: a L M d b G c N H K e F I J O P After: ...
185 views

### Java Palindrome - Time & Space Complexity

Which of these three methods is the most efficient? Also, what is the time & space complexity of each? ...
780 views

### How to do these extraction/computations efficiently?

I have a set of products(e.g. P0006, P0009, etc.) and a set of production lines (eg. L1H175, L2H175). A product can be produced on a subset of the lines set (and not necessarily all of them). If we ...
59 views

### My C# code to evaluate order of algorithm is returning logN or N^3 instead of N for simple loop [closed]

As a learning exercise, I am writing a library to evaluate the complexity of an algorithm. I do this by seeing how long the alorgorithm takes for given inputs N, and then do a polynomial regression ...
57 views

### Find the maximum GCD of a number with respect to all the values in an array for competitive programming

Here is the Question. Find the largest GCD of the input variable with the values of an array. Inputs are as follows:- First-line contains two integers, N and Q. Second-line contains N integers which ...
7k views

### PermCheck Codility with time complexity of O(N)

I have this solution for Codility's PermCheck problem. In summary, the task is to check whether array A contains each number in $1 \ldots N$ exactly once. I got ...
92 views

### Searching an element in a 2D sorted array

I had to write a code (as an exercise) that receives a 2D row wise and col wise sorted array and an element, and return true is the element exists in the array. The first thing that came to mind when ...
6k views

### URLify a string using Python

I have been working my way through the exercises in the book Cracking the Coding Interview. I wanted to get feedback for the following exercise. Write a method to replace all spaces in a string ...
21 views

### Intersection of Two Arrays - Space Time And Complexity [closed]

The problem is as follows: Given two arrays, write a function to compute their intersection. The below code is my solution.I'm just curious as to what the space time and complexity of below algorithm ...
81 views

### Permutation 1…N. Answer queries “How many numbers between [X,Y] position are in the interval [L,K]”?

So I am solving this task: We have an permutation of the numbers 1..n. I need to answer m queries: -How many numbers between X-th and Y-th position are in the interval [L,K] (<=k and >= L)? So my ...
64 views

### Choosing between 2 Fibonacci alternatives [closed]

Task: Return the fibonacci value at a given index. e.g: input: 6, return: 8. Algorithm 1: ...
244 views

### Algorithm to find the Array Balance Point

Task: Find the balance point of an array; return the index that if you break the array into left and right at that point will ...