All Questions
Tagged with time-limit-exceeded array
31
questions
2
votes
1
answer
185
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 ...
1
vote
1
answer
230
views
Find a secret word given an array of triplets? (codewars problem)
The rules for the puzzle are:
Each triplet has the rules of how the letters are ordered in the secret word (each letter is followed by the next letter inside the triplet array).
all the letters of ...
3
votes
1
answer
251
views
Array rotation in C++
I am completely new to data structures and algorithms.
I tried this problem on hackerank. I got the desired output but my code wasn't efficient enough to execute in the given time limit.
How can I ...
2
votes
2
answers
689
views
Keeping only every nth element in an array in JavaScript
I have two arrays, arr_of_frequencies and float_array, of the same length — around 500-800k values each. I have to get that down ...
3
votes
1
answer
89
views
Java i/o speed less than python i/o while printing an array
Motivation: I was solving an array based i/o problem and encountered Time Limit Errors, it was later found that the code for java ran roughly 10x slower than the ...
2
votes
1
answer
959
views
Count number of previous elements greater than its element at present index
Suppose I have a vector containing n elements. I want to find out the number of previous elements greater than its element at present index i. I want to find ...
4
votes
1
answer
461
views
Finding decreasing sequences in an array of numbers
Ants
Requirement
Given a natural number \$n\$, representing the number of days the study is made, and then a number \$x\$ of \$n\$ natural numbers, representing the number of working ant ...
1
vote
1
answer
130
views
Combine contiguous spreadsheet cell references into larger ranges
For a hobby project, I am using openpyxl to export Excel workbooks as JSON. Part of this involves identifying the formatting applied to cells, and serializing this information (provided the format is ...
1
vote
1
answer
3k
views
MAXSPPROD linear algorithm
I am working on the MAXSPPROD problem on interviewBit
You are given an array A containing N integers. The special product of
each ith integer in this array is defined as the product of the
...
5
votes
4
answers
654
views
Summed absolute difference of two array
Question (SAD Queries on CodeChef)
The Summed Absolute Difference (SAD) of two arrays. Given arrays
(1-indexed) \$P\$ and \$Q\$ of lengths \$p\$ and \$q\$.
Given a collection of \$n\$ arrays ...
1
vote
4
answers
706
views
Find value that occurs in odd number of elements
I am trying to solve the following exercise using Javascript:
A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be ...
7
votes
2
answers
825
views
"Ease the Array" challenge
I'm working on this challenge:
Given an array of integers of size N. Assume ‘0’ as invalid number and all other as valid number. Write a program that modifies the array in such a way that if next ...
3
votes
2
answers
472
views
2D array inquiries
I am trying to solve a problem as described below:
You are given an input of a n*m forest.
You have to answer a group of inquiries. Your task is to return the
number of trees for every ...
12
votes
4
answers
13k
views
Finding the first duplicate in an array
My code returns the correct answer the first duplicate is 3 (represented as int f) . I am struggling finding a more efficient way to find the first duplicate?
My ...
3
votes
4
answers
3k
views
Rearranging an array such that positive and negative elements are at alternate positions
We are given an array in which we have equal number of positive and negative elements.
We have to rearrange this array such that all positive and negative elements are at alternate positions and ...