Skip to main content

All Questions

3 votes
1 answer
91 views

Merge discrete integer intervals

What it does The code starts with a set of integer intervals, and can add new intervals (possibly by updating existing intervals). Essentially, it is a bit array whose index starts at ...
FromTheStackAndBack's user avatar
3 votes
2 answers
406 views

Calculate sum of largest sequence of decreasing odd ints

I wrote a method that finds the maximum sum of consecutive decreasing sequence of odd integers. For example: if sequence is 13 9 7 12 13 15 13, then sum is 29 (13 + 9 + 7). I don't think it's as good ...
infelixPuer's user avatar
1 vote
1 answer
233 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
1 vote
0 answers
158 views

Smallest interval whose sum exceeds a threshold

In a non-negative 1D array x, we wish to find the shortest slice such that x[start:end] > threshold, with constraint that <...
OverLordGoldDragon's user avatar
2 votes
0 answers
56 views

Non-allocating k-nearest-neighbours between two matrices in Julia

I played around with some optimizations when answering this SO question. Sought is a function which given matrices x of size (m, l) and ...
phipsgabler's user avatar
5 votes
4 answers
571 views

Fastest function to find cumulative largest perfect squares of a single number?

I'm attempting to write an algorithm that will find the largest perfect squares of a given integer, subtracting their values from the total each time, as fast as possible. It's somewhat hard to ...
Will Berner's user avatar
1 vote
3 answers
186 views

Count how many iterations of deletion until array is ordered

I'm trying to write a program whose input is an array of integers, and its size. This code has to delete each element which is smaller than the element to the left. We want to find number of times ...
user250707's user avatar
0 votes
3 answers
1k views

Calculate square of (sum of even-indexed) - (sum of odd-indexed) subarrays from an array

Find all subarrays from a given array in the least possible time complexity. Requirement: calculate the square of (sum of even-indexed elements) - (the sum of odd-indexed elements) of al the subarrays....
Adil's user avatar
  • 101
1 vote
3 answers
77 views

Javascript: Reducing redundancy of notation nested value

Hello I have this function that looks for nested value 3 levels deep currently ...
Mateen Kazia's user avatar
2 votes
2 answers
112 views

Print Binary coded decimal Numbering of a given input number

Example 1 input:3 output:0011 Example 2 input : 15 output: 1111 in the below example code 15 is input. I have taken 8 4 2 1 as array for Binary coded decimal numbering this code is working as ...
Ramakrishna's user avatar
3 votes
3 answers
1k views

Printing rotations of an array 7 times

Loop through a given array 7 times and print the following output: int[] arr = { 9, 2, 7, 4, 6, 1, 3 }; ...
Ramakrishna's user avatar
7 votes
1 answer
1k views

Polynomial multiplication using Karatsuba method

I am trying to solve a problem, which requires me to output the xor of all coefficients in the product of 2 input polynomials. Having seen that the normal O(n^2) ...
Đào Minh Dũng's user avatar
2 votes
1 answer
260 views

Algorithm to find bucket and item indices from power of two bins?

So this is building off of Algorithm for dividing a number into largest "power of two" buckets?. Here is a slight modification of the answer from there: ...
Lance Pollard's user avatar
2 votes
0 answers
35 views

Rotational Symmetry Indexing in a 1D “Square” Array

I managed to find a way to rotate a slice in-place (previous question on SO). The slice is linear, but represents a 2d square of elements. Is this approach efficient? Please check the previous ...
Orphevs's user avatar
  • 231
4 votes
1 answer
1k views

Find minimum count of items where sum of them is X from an array

I recently faced an interview question where you have to find minimum needed items from an array that can added together to generate X value. For example giving: <...
Mojtaba Hosseini's user avatar

15 30 50 per page