Category "arrays"

Using lodash push to an array only if value doesn't exist?

I'm trying to make an array that if a value doesn't exist then it is added but however if the value is there I would like to remove that value from the array as

Longest K Sequential Increasing Subsequences

Why I created a duplicate thread I created this thread after reading Longest increasing subsequence with K exceptions allowed. I realised that the person who wa

Count how many iterations of deletion until array is ordered

I'm trying to write a program whose input is an array of integers, and its size. This code has to delete each element which is smaller than the element to the l

How do I average the elements that are above a threshold in an array?

I am trying to average all the elements that are above 150 in an array. I can't figure out how to make it all work out and output the correct numbers. Can anyon

How do I average the elements that are above a threshold in an array?

I am trying to average all the elements that are above 150 in an array. I can't figure out how to make it all work out and output the correct numbers. Can anyon

What is the correct way to access the columns in NumPy?

I cannot figure out the following problem: Elements that were placed at the corners of an 4X3 array are selected. The row indices of the selected items are [0

C# check object type against multiple types

IS there a way to pass an array of types to the "is" operator? I am trying to simplify the syntax of checking an object against multiple types. Something like

Splicing objects from an array Javascript

I am trying to remove an object from an array if a particular value for a key matches a given string: Example data: array = [{_id: "abc", test: "123"},

How to assign value to zero-length array defined by ctypes in Python3

Here I have a class defined like below, whose attribute data is a zero-length array. How to instantiate this class? class Frame(ctypes.Structure): _fields_

plotting data from a list in python

I need to plot the velocities of some objects(cars). Each velocity are being calculated through a routine and written in a file, roughly through this ( I have

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