A sub-array is a subset of an array.
Questions tagged [sub-array]
434 questions
1
vote
1 answer
Creating Boggle game - linking coordinates to letters
There is a 4x4 board with a total of 16 letters. In this array [2,1] represents the letter in the third row, second column.
const coordPairs = [
[ [2, 1], [4, 1] ]
[ [4, 0], [4, 1], [4, 2], [4, 3] ]
[ [0, 0], [0, 1], [0, 2] ],
[ [1, 0], [3,…

kalecrush
- 71
- 3
- 8
1
vote
2 answers
PHP usort array based on subarray elements not working right - buggy?
Here's my current code, using php 7.1.20-1+ubuntu18.04.1+deb.sury.org+1:
(Four columns to sort by, 5th column just a subarray reference number.)
$dud = [[2,3,"2018-07-19","08:23",1],
[2,3,"2018-07-19","08:30",2],
…

Everett Staley
- 31
- 6
1
vote
2 answers
php if array has another array
Seems weird matter. Is there any way to detect array that contains sub-array in php, such parent-child concept in css, jquery. I want to insert data only if array has subarray
Dynamic Menu

Dipak
- 931
- 14
- 33
1
vote
1 answer
MPI - Difference between mpi_type_get_extent and mpi_type_get_true_extent
I have some problem in understanding the difference between mpi_type_get_extent and mpi_type_get_true_extent. In practice, I was using the former, expecting the results I then obtained with the latter, so I checked the MPI 3.1 Standard, where I…

Enlico
- 23,259
- 6
- 48
- 102
1
vote
2 answers
what's the difference between np.array[:,0] and np.array[:,[0]]?
I have a numpy array cols2:
print(type(cols2))
print(cols2.shape)
(97, 2)
I was trying to get the first column of this 2d numpy array using the first code below, then i got a vector instead of my ideal one column of data.…

Pumpkin C
- 1,452
- 6
- 21
- 27
1
vote
0 answers
Maximum submatrix (2D) by ignoring at most one element
I know the algorithm to find the maximum 2D submatrix is O(m^2*n) with the use of Kadane's algorithm, where m is the columns and n is the rows. But is there an algorithm for finding the maximum 2D submatrix if we have to ignore exactly 1 element in…

Alex Borgue
- 123
- 1
- 10
1
vote
3 answers
How to insert array elements as sub array like first element is the parent of second,second is the parent of third and so on?
I need to convert an array that is like
$data = array('Image','Thumbnail','size') to
$data= array('Image'=>array('Thumbnail'=>array('size'=>'test'))); format.
How it will be possible?.
I had tried something like below.
$count=…

Sujith Johnson
- 33
- 1
- 6
1
vote
1 answer
Possibly simpler O(n) solution to find the Sub-array of length K (or more) with the maximum average
I saw this question on a coding competition site.
Suppose you are given an array of n integers and an integer k (n<= 10^5, 1<=k<=n). How to find the sub-array(contiguous) with maximum average whose length is more than k.
There's an O(n) solution…

user1968919
- 153
- 3
- 13
1
vote
1 answer
Find maximum non contiguous subarray that respect a specific rule
Given these two arrays:
[5, 3, 4, 1, 2]
[1, 3, 2, 4, 5]
Find the maximum subsequence in both arrays that the index of the elements are in a crescent order:
Example: [3, 4] it's an answer because the indexes are in a crescent way in both arrays.…

Emanuel Huber
- 131
- 2
- 12
1
vote
1 answer
C - Debugging a particular sub array of 2D arrays
I am writing a C program in VS 2013 and I want to debug a particular sub-array from full 2D matrix of ints. For example, using debugger watch window, I can print like,
Mat // this shows the full NxM Mat matrix values
Mat[i][j] // this shows…

Sazzad Hissain Khan
- 37,929
- 33
- 189
- 256
1
vote
1 answer
Many Subarray Sum Queries
Subarray problem: Given integer array A (only positive numbers), is there a continuous subarray of any length with sum S? Sliding window solution to this is O(N).
Now if we have many such queries S on static array, we can do preprocessing. We can…

Filip Nguyen
- 1,029
- 1
- 7
- 20
1
vote
1 answer
Split array by list of sub-array indices
Suppose I have an array X and a list of indices k_ar, the maximum of which is K - 1.
What I want to do is basically split X in such a way that X[i] goes into sub-array k_ar[i]. The O(n) way to do this would be the following:
X = [5, 1, 3, 2, 2,…

Hameer Abbasi
- 1,292
- 1
- 12
- 34
1
vote
2 answers
Subarrays not working in Swift 3
In Swift 3 I have two variables declared like this:
let patternArray = [true,true,false,true,true,false,true,true]
var resultArray = [Bool]()
Later in my code I have this, to get part of the array:
resultArray = patternArray [0..<4]
Whe compliling…

Michel
- 10,303
- 17
- 82
- 179
1
vote
1 answer
Algorithm that finds the start and the finish of many sub-arrays?
so I have this question in C:
Given an array that only contains 0's and 1's (Example: [1,1,0,0,0,0,1,0,1,0,1,1]).
I need to find the start of a "ring interval" and the finish of the same "ring interval" (there could be many rings like that, we'll…

Buk Lau
- 81
- 1
- 7
1
vote
0 answers
How to create sub-array in array in mongodb using C code?
I'm working on project where i have to prepopulate array. I need to update this function so that arrays 'time' and 'values' become arrays with sub-arrays full of '0' but i can't figute it out how am i suppose to do this.
I'll be grateful for any…

Xander
- 11
- 1