Category "arrays"

Pythonic way to get both diagonals passing through a matrix entry (i,j)

What is the Pythonic way to get a list of diagonal elements in a matrix passing through entry (i,j)? For e.g., given a matrix like: [1 2 3 4 5] [6 7 8

Julia: how to index an 'any' type array

I am new in Julia. I want to replicate the results in Wollmann (2019). However, it always give me this error: LoadError: MethodError: no method matching setinde

int cannot be converted to int []

new to programming here and i keep getting the error message, incompatible types, int cannot be converted to int [], the question is to add R1 & R2 together

Fastest way in numpy to get distance of product of n pairs in array

I have N number of points, for example: A = [2, 3] B = [3, 4] C = [3, 3] . . . And they're in an array like so: arr = np.array([[2, 3], [3, 4], [3, 3]]) I nee

How do I group values to an array for the same field value in jq?

I have json data that looks like [ { "session": "ffe887f3f150", "src_ip": "81.71.87.156" }, { "session": "fff42102e329", "src_ip": "143.19

How can I correctly display all the elements of 2D array that have even neighbors?

I wrote a program that finds and displays all the elements in the 2D array, which have all neighbors(left, top, right, bottom) - even. I tried to put in an if,

Cleanest way to wrap array index?

Say I have an array of 5 Ints. What would be the most efficient way to wrap the index of the array if the index were incremented or decremented (for example) th

PHP Array split string and Integers

Below is an array of strings and numbers. How could the string and number values be split into separate arrays (with strings in one array and numbers in another

I started learning DSA ,while writing code for stack DS in c++ , I came across this error

I started learning DSA ,while writing code for stack DS in c++ , I came across this error. So, while I was trying fixing it , I get to know that when I am using

MATLAB: Subindexing in cell array based on results of strfind

I have a cell array, like so: ID = {'g283', 'sah378', '2938349dgdgf', 'g283'}; I also have some data that corresponds to these IDs. Data = {'data1', 'data2'

Duplicate zero in array by modifying the array in place

There is a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. The elements beyond the length

How to find or count the duplicate in multidimensional array in c# [closed]

I am creating a 2d (3 * 3) array in c# which has to count or find the duplicate value int[,] arr = new int[3, 3] { {1, 2, 6}, {4, 1, 5}

How to use malloc to assign large two-dimensional arrays in C

I know a very large two-dimensional arrays in C needs a long identifier for the variable type when assigning memory to the array to avoid stack overflow errors

How to use malloc to assign large two-dimensional arrays in C

I know a very large two-dimensional arrays in C needs a long identifier for the variable type when assigning memory to the array to avoid stack overflow errors

Declare a 0-Length String Array in VBA - Impossible?

Is it really not possible to declare a 0-length array in VBA? If I try this: Dim lStringArr(-1) As String I get a compile error saying range has no values. I

Largest Triple Products without using sort?

I implemented the Largest Triple Products algorithm, but I use sort which makes my time complexity O(nlogn). Is there a way to implement it without a temporary

Transpose and flatten multiple rows of array data [duplicate]

Is there a native PHP function to zip merge two arrays? Look at the following example: $a = array("a","b","c"); $b = array("d","e","f"); $c

Using reduce() to find min and max values?

I have this code for a class where I'm supposed to use the reduce() method to find the min and max values in an array. However, we are required to use only a si

Understanding the Big O for squaring elements in an array

I was working on a problem where you have to square the numbers in a sorted array on leetcode. Here is the original problem Given an array of integers A sor

Find Nth number of children using JavaScript and want to create Treeview

I have this array of hash and want to recursive this into treeview upto ParentTradeFairResourceId exist. I have tried but not succeeded to create an algorithm.