Category "arrays"

How to add emoji in a spinner in an array with list items

I want to have spinner which contains list of items in a way where every entry have an emoji with it. I have already an array but I don't know how can I add emo

Typescript error (2345) when pushing element to array of elements(React js)

I'm pretty new to Typescript and I was trying to migrate a component I had on Reactjs to typescript. This component is supposed to receive a number from 0-10 as

NumPy 2D array: selecting indices in a circle

For some rectangular we can select all indices in a 2D array very efficiently: arr[y:y+height, x:x+width] ...where (x, y) is the upper-left corner of the rec

Partition negative and positive in an array in java using shift operator

You will be given an array of n integers, both negative and positive. You need to partition the array into positive and negative numbers. Add all the positive i

Algorithm to return all combinations of 3 combinations from a array of length 6 without the number appearing with the same set of numbers

I was trying to write a algorithm in javascript that returns all the possible 3 digit numbers numbers from a given array of length 6 For Example var arr = [1, 2

How to Remove Every Other Element in an Array in Swift?

So say I have an array: var stringArray = ["a","b","c","d","e","f","g","h","i","j"] Now, how do I delete "a", "c", "e", "g", and "i" (all the even number ind

Why does new int() work like an array in C++?

As far as I understand int* p = new int(); Is something like creating an int with a constructor. If so why does the following code work like an array? int* p =

Parse CSV records in to an array of objects in JavaScript

I'm new to JS and not much exp in Regex to play with string manipulation. Here is my CSV file with records in tabular form with the first line as headers and

Sum array values of a column within each column of an array with 3 levels

I'm trying to use array_sum() on columns within columns of a multidimensional array. For eg: I have an array that looks like this: $array = [ [['value' =>

How to reverse SwiftUI ZStack order?

trying to recreate a next/previous item on a stack of cards. I have my cards in a ZStack. The problem I’m having is that by default ZStack are in reverse

Generate array from 0 to N with custom increment in Javascript

Problem Description I am trying to generate an array using keys() and .map() methods, given a preexisting array with length = arrLength, such that only items at

How to remove from a multidimensional array all duplicate elements including the original?

I am using php 7.1. I have seen that to eliminate the duplicate elements it is enough with this array_unique($array, SORT_REGULAR); I've also seen this work ar

How do I set multiple values in a Javascript Map at once?

I have a simple chain of logic here, where bigCities is a Javascript Map. In this example, d represents each object in an array of data read in from a csv file.

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