Skip to main content

All 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 ...
user12138762's user avatar
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 ...
Jonas's user avatar
  • 131
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 ...
Samir's user avatar
  • 143
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 ...
Luke's user avatar
  • 123
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 ...
the_illuminated2003's user avatar
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 ...
sukesh's user avatar
  • 21
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 ...
antoniu200's user avatar
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 ...
tehhowch's user avatar
  • 131
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 ...
UmNyobe's user avatar
  • 219
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 ...
Vishal_007's user avatar
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 ...
Anirban Bera's user avatar
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 ...
Srivarun Neelakantan's user avatar
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 ...
Kurns's user avatar
  • 175
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 ...
Andrew Mattick's user avatar
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 ...
sahil mehta's user avatar

15 30 50 per page