Skip to main content
Filter by
Sorted by
Tagged with
3 votes
2 answers
195 views

The method is working as intended, but while I was trying multiple cases, I got this weird issue, so hopefully someone can understand why and explain it to me, since 6 > 5 looks logically sound to ...
chtasmino's user avatar
1 vote
2 answers
136 views

I'm trying to write a Ruby program which will parse the following TSV file and loop over each record, adding each shop name (last column) as the key in a hash and the associated price (second column) ...
green_ruby's user avatar
1 vote
0 answers
67 views

I'm trying to make a code that counts Shell and Merge comparisons and swaps, making a sum between the sum of the comps and swaps. The vectors are a subArray, such that, given: 4 (line break here) 3 6 ...
Poueeerr's user avatar
0 votes
0 answers
19 views

For a given array we need to find the maximum number of subarrays possible. Conditions: 1.The sum of each subarray should be >= minSum 2.The length of the subarray should be >= minLen We need to ...
Ashish Lakhmani's user avatar
1 vote
3 answers
169 views

I am trying to make an algorithm that calculates the sum of each maximum element in a subarray not including the first and last elements. The naive approach is obvious but I do not want that. Here is ...
user avatar
20 votes
3 answers
2k views

I have a 1-indexed array of positive integers, and I want to make several queries to it, all in the form, 'what is the sum of the largest x integers in the subarray 1 to y inclusive?' This array is ...
Redz's user avatar
  • 784
0 votes
0 answers
89 views

This is a snippet from this code to finding sums of all subarrays of a given array, but this doesn't work as intended as the problem seems to be lying with pre-incrementing value of i in the equation. ...
Pradyuman Sharma's user avatar
-4 votes
1 answer
62 views

Given an integer array, I want to print out all the distinct pairs of halves of the array. [2,1] [3,2] and [3,2] [2,1] can be considered distinct. I'm sure there's a brute force way, but I want ...
Eggy's user avatar
  • 1
1 vote
3 answers
103 views

I have an array: > a array([[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], [[17, 18, 19, 20], [21, 22, 23, 24], [25, 26, 27, 28], ...
Jun's user avatar
  • 55
1 vote
3 answers
69 views

I have an array: > a array([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) I want to change those values to the avarage of those values, so the output will be: > a array([[2, 2, 2], [3, 3, 3], [4, 4, 4]]) ...
Jun's user avatar
  • 55
1 vote
0 answers
369 views

How can I find the number of subarrays where bitwise XOR of the element of the subarray has odd number of set bits. Basically I need to find the solution in linear time. I could solve in O(N^2). What ...
Snehasish Bhakat's user avatar
0 votes
1 answer
384 views

I want to do a sub-array selection Python-like (ArraySlice) in Swift. This is working for me, but I know it's not nice. To make it work I used .suffix embedded to .prefix method. I'm wondering if ...
ccmsd18's user avatar
  • 58
0 votes
1 answer
285 views

I am trying to create a continuous subArray from a given array which is equal to the given sum and return the first and last index as an ArrayList. This is the solution i could think of which actually ...
Sourav Borah's user avatar
1 vote
1 answer
161 views

I need to find a performant and smart way to redesign the formula or the tables on which it depends (COSTO_DUMMY and GG_TARGET). Can you help me, please? I can add new support tables if needed ...
Franco's user avatar
  • 87
-3 votes
2 answers
555 views

how to get all the subarrays in O(nlog(n)) time complexity using javaScript I try with a nested loop but the time complexity is in O(n*n). I heard about some prefix solutions but have no information
Ujjwal's user avatar
  • 1
0 votes
2 answers
92 views

public class maxsubarraysum { public static void main(String[] args) { int numbers[] = { 1, -2, 6, -1, 3 }; printmsasum(numbers); } public static void printmsasum(int ...
Sarthak Parmar's user avatar
0 votes
1 answer
692 views

Can someone help me with this. My code is working fine but consider a case of [-2,-1]. Since my maxSum is set to 0. My output is coming 0 instead of-1. How should I modify my code? Sample i/o: Input: ...
Shreyansh's user avatar
0 votes
1 answer
989 views

Given an integer array sequence a_n of length N, cut the sequence into several parts such that every one of which is a consequtive subsequence of the original sequence. Every part must satisfy the ...
Sharhad's user avatar
  • 83
0 votes
0 answers
115 views

This is my code and it does well for positive numbers given in the array but when one of the input numbers is negative it doesn't work #include <stdio.h> int main() { int n; scanf(&...
ArianMohseni's user avatar
0 votes
1 answer
79 views

Hey there i have an numpy array y with over 4000 values. data=pd.read_csv('samplesdata.csv',sep=";", decimal=",",encoding='latin-1') sensor_data=data[['Euklidische Norm']] ...
Papadopolous's user avatar
-3 votes
1 answer
190 views

I would like to find if a sorted subarray v' with size 'k' is contained in another sorted array with size 'n'. We know that k <= n. However, it would be so easy with a double for loop or something ...
j.j.3's user avatar
  • 35
0 votes
0 answers
115 views

Is there a function or more concise notation to get b or bb in the code snippet below? import numpy as np a = np.arange(12).reshape(3, 4) c = (1, 2) r = 1 b = a[c[0]-r:c[0]+r, c[1]-r:c[1]+r] bb = a[c[...
Paul Jurczak's user avatar
  • 8,630
0 votes
1 answer
444 views

Let's say you have given an array of size N, which can have a positive and a negative number. we need to return the length of the largest subarray of sum equal to k. I tried to use the sliding window ...
Anurag Tripathi's user avatar
-1 votes
1 answer
57 views

This is my current code for a program to find the maximum subarray. I am getting the out of bounds error for 3 lines: I'm getting the error ArrayIndexOutOfBoundsException: index -25 out of bonds for ...
Tiffany 's user avatar
0 votes
1 answer
616 views

question given an array of elements 0, 1, 2 with find the total number of subarrays with the ratio of 0's and 1's equal to x:y. input 5 1 1 0 1 2 0 1 output 6 \\5 is the size of array 0 1 2 0 1 ...
Abhinav's user avatar

1
2 3 4 5
11