Category "arrays"

Write a recursive method called which takes in an array of integers and returns said array in reversed sorted order

I have a programming exam in a few days so I'm doing some exercises just to practice. However, I've been stuck with this problem and I started to doubt if it's

Expected to return a value in arrow; function array-callback-return. Why?

I'm having some issues understanding why I'm getting a compile warning on this piece of my react code fetch('/users') .then(res => res.json())

Find index of numbers from a string in Javascript

I would like to get the index of numbers ( 1994 and 27 ) in the string bellow i tried to split the string but no idea what to do after that let str = 'year o

The loop over two arrays take LONG

Thanks for your helps, I have two arrays: A (100k row, 10 col) and B (100k row, 12 col) The following code (thanks to BSALV) loop through A and B => It takes

update objects in array with useState (reactJS)

Go to the end of this question for the solution that worked for me! i'm currently making my own chess game and i want to check if a position already occurred 3

Numpy array of tuples to PIL image

I currently have a numpy array or RBG tuples that I want to convert to a PIL image and save. Currently I'm doing the following: final = Image.fromarray(im_arr,

How to add a comma in array.map after every element except last element in React JSX

How can I add a trailing comma after every element of an array for making a list like: INV, INV, INV, INV Note that the last element doesn't have a trailing c

Merge JavaScript objects in array with same key

What is the best way to merge array contents from JavaScript objects sharing a key in common? How can array in the example below be reorganized into output? Her

Merging 4 sorted Arrays into one

I have this method to merge 2 sorted arrays into one sorted array: public void merge(T[] a, int l1, int r1, T[] b, int l2, int r2, T[] c, int l3) {

Inserting array values

How do I write and execute a query which inserts array values using libpqxx? INSERT INTO exampleTable(exampleArray[3]) VALUES('{1, 2, 3}'); This example code

Copying Character array into char array

Hi I want to fast copy array of Characters to array of chars I can write a method that copies Character array into char array, by converting every Charater in a

numpy arange: how to make "precise" array of floats?

In short, the problem I encounter is this: aa = np.arange(-1., 0.001, 0.01) aa[-1] Out[16]: 8.8817841970012523e-16 In reality, this cause a series problem si

Date showing as serial number in formula

I'm currently having an issue with the date format. I have basically extracted the month and year from a standard dd/mm/yyyy date and wish this to be formatted

Javascript twoSum algorithm: Given an array of integers, return indices of the two numbers such that they add up to a specific target

Given an array of integers, return indices of the two numbers such that they add up to a specific target. Example: Given nums = [3, 2, 4], target = 6, Because

Group rows by column and sum another column within groups [duplicate]

I have an array looking like: array(480) { [0]=> array(2) { ["tag_id"]=> string(4) "6291" ["az"]=> int(5) } [

Find the first and last element of a NumPy array larger than a threshold

I need to find the first and the last element of a numpy.ndarray which are above a specified threshold. I found the following solution, which works, but it look

algorithm to merge two arrays into an array of all possible combinations

Example given in JavaScript: Suppose we have two arrays [0,0,0] and [1,1,1]. What's the algorithm to produce all possible ways these two arrays can be combine.

Calculate the sum of values within an array of objects [duplicate]

I am trying to find the total sum for each item sold inside an array, like so: The array looks like this: [ { 'Some Title Item', '22',

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

I'm running a PHP script and continue to receive errors like: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php on line 10 Notice: U

Is there a way to concatenate two arrays in Excel without VBA? [duplicate]

I am trying to create a formula that returns the concatenation of two arrays of different lengths. I need this concatenation for part of anoth