## How to find the maximum consecutive, negative sum in an array?

What is the most efficient way to calculate the most negative sum for any set of consecutive indexes in an array? You can take any consecutive group of positive and negative integers in an array to …

## Get the last character of string inside array

The question required me to get the first char from the first word in array with the last char from the second word in an array I can just get the first char but my problem is with the second one like:…

## How can I optimize my code from O(n^2) to nlog(n)

Given an array of numbers, arrange them in a way that yields the largest value. For example, if the given numbers are {54, 546, 548, 60}, the arrangement 6054854654 gives the largest value. And if the …

## How to sort array of objects based on object property (which is Array) Javascript

I’ve got this groupsArray which I want to sort based on the days which are closest to 1 and the times start and the end should be the earliest ones… I’ve tried a lot of stuff but I was unable to …

## modified version of selection sort in C

I’m trying to modify selection sort in such a way that it puts the biggest element at the end of the array and then repeats selection sort for n – 1 items until n is 0. My code compiles but the output …

## PHP: Find one or more enclosed area in a two-dimensional array

There is (10×10) two-dimensional array (matrix) of zeros and ones. Need algorithm (the implementation) that determines whether in this array closed path of ones, that surround the zeros. The output is …

## Maximize the sum of absolute difference between max and min elements of all non overlapping sub-arrays that can be formed from an array?

for example : A = [2, 3, 0, 1, 5] Now A can be divided into multiple sub-arrays One way to do so is : A ~ [2], [3, 0], [1, 5] Now the sum of absolute difference between max and min elements of all non …

## Find first non zero numbers in an array (zeroes can be anywhere)

Suppose we have an array: x = [10,0,30,40]. I would like to extract the first non zero element and store it in a different variable, say y. In this example, y = 10. We can also have many zeros, x = […

## How would you solve this problem using a hash map instead of a set?

def pair_sum(array,r_sum): if len(array)<2: return found = set() output= set() for num in array: k = r_sum - num if k not in found: found.add(num) else: output....

## Prefixes using array in java [closed]

I’m coding a method that takes as input an array of integers and returns another array of strings, each of which denotes a non-empty prefix of the input array. For example, if the input array is: <…