Skip to main content

All Questions

Tagged with
1 vote
2 answers
98 views

How to get maximum average of subarray?

I have been working this leet code questions https://leetcode.com/problems/maximum-average-subarray-i/description/ I have been able to create a solution after understanding the sliding window ...
Zubair Amjad's user avatar
0 votes
1 answer
91 views

How to optimize this code: Leetcode input was unexpectedly ( Memory Limit Exceeded )

Leetcode question: Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. Leetcode entered a very long input of to the function and its IDE ...
TheWalrus's user avatar
-5 votes
1 answer
162 views

how this tricky problem could be solved in python for creating subarray

write a program to create subset of given array the value inside the array should be target value and length of array should be k program that i have tried arr = [1, 2, 8, 6, 4, 9, 5] k = 3 target = ...
6004 Abdul Rahman Harris's user avatar
1 vote
3 answers
99 views

How do I stack arrays horizontally?

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
68 views

How do I change values in my subarrays into the avarage of those values?

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
3 answers
644 views

How to get the arrays not contained in another array?

I have two Python arrays with arrays inside: first = [[0,10],[0,11],[0,12],[0,13]] second = [[0,10],[0,11]] and I want to get as a result the array that is in the first one, but not in the other: ...
BSDash's user avatar
  • 13
0 votes
1 answer
338 views

SubArray selection in swift

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
1 vote
1 answer
486 views

Check if item exists in same position in each nested list - Python

I'm writing a Connect Four script. The script takes a list of moves as input ("A_Red, "B_Yellow", "G_Red", etc), which I'm sorting into a matrix. Each nested list represents a ...
CunnyFunt's user avatar
  • 105
0 votes
1 answer
945 views

Cut a sequence of length N into subsequences such that the sum of each subarray is less than M and the cut minimizes the sum of max of each part

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
1 answer
76 views

Divide Array in subarrays by local peaks

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
0 votes
0 answers
114 views

Numpy subarray given by center and radius

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,235
0 votes
0 answers
121 views

Automating for loop between multiple subarrays in Python

I have multiple dbf files in a directory that I am trying to loop through and convert into excel files. However, because the loop times out after running for a while I divided the array list into ten ...
Jay Antonio Oliver's user avatar
1 vote
2 answers
1k views

how to get elements in sub-array of a numpy array in python

I'm getting in trouble with reading the entries of a sub-array of a numpy array, in python. I've got something like this: a = np.array([ [453,254,[1,2,3,4,5]], [743,251,[10,20,30,40,50]], [127,393,[11,...
urgeo's user avatar
  • 641
0 votes
0 answers
25 views

Sub-arrays can't be changed individually when created at the same time [duplicate]

I created an array with two sub-arrays containing zeros: a=[[0]*3]*2 This looks like so: [[0, 0, 0], [0, 0, 0]] I try to modify the first value of the first sub-array like this: a[0][0] = 1 Then ...
LukasFun's user avatar
  • 229
0 votes
1 answer
186 views

Minimum removal of subarrays to make array equal to target

Lets say we have an array [5, 4, -2, 4, -3] and we want all elements to equal to 0. Subarrays can be used to add or subtract by 1. For example, I can add 1's from index 0 to 3, and then the list is [5 ...
user avatar

15 30 50 per page