Skip to main content

Questions tagged [arrays]

An array is an ordered linear data structure consisting of a collection of elements (values, variables, or references), each identified by one or more indexes. When asking about specific variants of arrays, use these related tags instead: [vector], [arraylist], [matrix]. When using this tag, in a question that is specific to a programming language, tag the question with the programming language being used.

Filter by
Sorted by
Tagged with
0 votes
1 answer
15 views

Detect array type in source generator

I'm writing a source generator that processes my model classes and adds some custom serialisation code for them. The model classes can have all sorts of property types. I'm currently interested in the ...
ygoe's user avatar
  • 19.7k
0 votes
0 answers
47 views

Using arrays from different classes in java

I am making a TicTacToe game. The idea is I print a 3x3 grid with numbers from 1-9 and when a player selects a number it changes that element in the grid array with a character like * or o I'm facing ...
Coen Molyneaux's user avatar
0 votes
1 answer
93 views

Smallest element after xor

Starting with array of N positive integers, support Q queries. Each query contains a positive integer i. To answer the query, replace each element of the array with the result of xoring it with i, ...
user25680598's user avatar
0 votes
1 answer
29 views

set array items into separate variables

I am trying to set each item in an array into their own variables. Here is what the array looks like: labels = ["label1", "label2", "label3", "label4", "...
John Beasley's user avatar
  • 2,843
0 votes
1 answer
11 views

i want to create a modal, when i click on button having id a modal should be opened having card

i have created a courses page and create a fullscreen which should be opened when button is clicked modal is also opened but i am having an error in JS. let value = colc[details.target.id] if(details....
faryal sz's user avatar
0 votes
1 answer
27 views

Have my array be split and added on to the new array, instead of completely restarting it each loop

I have a problem with my array. Each loop, the array gets cleared and new values gets added onto it. How could I make it so as the array gets filtered, it gets added to a new array to fill it up with ...
Legois's user avatar
  • 1
1 vote
2 answers
36 views

HTML audio with javascript: playback of playlist is not correct -> index 2 is always skipped

Need someone to help me understand, why index 2 of the playlist array that is passed to the audio element is skipped - no matter what. This is the console output: 0: /track01.mp3 1: /track02.mp3 2: /...
nBar's user avatar
  • 37
0 votes
0 answers
31 views

How to find all points that satisfy the Gas Station (Leetcode) problem?

I want to solve a similar problem to the https://leetcode.com/problems/gas-station/description/ problem: given n gas stations on a circular route, the ith station has g[i] gas. the cost to travel from ...
turtle silver's user avatar
0 votes
1 answer
48 views

Powershell : Compare an Hashtable to multiple System.Object and return only the matching one

I'm trying to compare an hashtable to multiple output from Pipeline, in he shortest way ( one line if possible). Each output will contains at minimum same Property as Key in hashtable, but could have ...
DrakkarD's user avatar
-3 votes
0 answers
32 views

cannot reshape array of size 1000 into shape (100,100) [closed]

>>> cent_rand = np.random.randint(1919, 3946, 1000) >>> len(cent_rand) 1000 >>> two_d_cent = cent_rand.reshape((100,100)) Traceback (most recent call last): File "<...
rosa elena's user avatar
0 votes
0 answers
30 views

Calling methods from array of method pointers not executing [duplicate]

This doesn't execute any suggestions: void (CClient::*pMethod[CNetwork::ClientEvent::E_CE_MAX_EVENTS])(); pMethod[CNetwork::ClientEvent::E_CE_ACCEPTED] = &CClient::Accepted; pMethod[CNetwork::...
developer68's user avatar
0 votes
1 answer
53 views

GoLang - looping through array of structs - can I map?

I'm new to GoLang, coming from Node. A little late to the (definitely not functional) game and need some help understanding approaches, and perhaps just understanding... I want to omit an item from a ...
Harry Lincoln's user avatar
0 votes
1 answer
14 views

How to pass CoreStoreObjects to SwiftUI - potentially using Combine or RxSwift [closed]

I have been implementing CoreStore after previously using SwiftData. I have inserts and predicates working, but I have not succeeded at displaying any data in a view. One complication is that each ...
schwabsauce's user avatar
0 votes
0 answers
35 views

Powershell array of strings into single sql column

I've this array of strings: $qLastSS_T 2024-07-08 11:56:32 2024-08-08 12:56:32 2024-09-08 13:56:32 2024-10-08 13:56:32 2024-11-08 15:56:32 2024-12-08 16:56:32 and a sql table like this: It's ...
ilRobby's user avatar
  • 81
0 votes
0 answers
26 views

Ternary in an array, string PHP [closed]

array ( 'head' => "Birth and Early Years", 'text' => array ( "Jason A. Cloud was on <a href=''>Bellona</a>, Prime Hospital, to <a href='...
Lee Wright's user avatar
0 votes
0 answers
27 views

I cannot run array function in excel (MS 365) to create a migration matrix [closed]

I am trying to implement migration risk calculation based on a moodys rating migration from 30 years. As a first step, I have this matrix as source; Average one-year letter rating migration rates, ...
josesilva's user avatar
0 votes
0 answers
92 views

sizeof() operator in c++ displaying different results in case of arrays [duplicate]

Why is the result of the two array sizes are different? #include <iostream> using namespace std; void fun(int a[]){ cout <<sizeof(a)/sizeof(int)<<" "; cout<<...
Kavya's user avatar
  • 1
0 votes
0 answers
42 views

Return the latest group of records inserted by specifically me into a table along with their ID in the table?

I have a table of Customers, named Customer with the following columns: CustomerID CustomerName ContactNo Address DateCreated 1 Idola Steenson 438614198 Morena 2022-08-14 09:48:00 2 Graham Buckner ...
French Croissant's user avatar
0 votes
2 answers
36 views

Utilizing array items as an entire case in a switch statement

I would like to generate cases in a switch statement from an array. Here is how the array is generated: pointObjects = []; for (var i = 0; i < 2; i++) { // Generate cases. var url; var ...
throwaway2908457's user avatar
-7 votes
0 answers
51 views

How To Access An Item In A Struct Which Is In An Array [closed]

I am making a tower defense game and used structs in an array and want to access an item in the structs. I don't want to use a 2d array as that can't show up in a unity editor. I tried tutorials and ...
Simon Y's user avatar
0 votes
2 answers
57 views

How to process this text?

I have a text file that contains these lines and I'm not exactly sure what's the best way to use Python to load into separate key:value pairs. dummy-test-foo,rsa,4096,[DNS.1:dummy-test,DNS.2:dummy-...
quarksrus's user avatar
-1 votes
1 answer
64 views

Why does this for loop run faster when it runs inside a helper function? [duplicate]

I was doing LC# 1002, I spent an hour to figure out why does runtime is lower from 3 ms to 1ms after I made this change. Their logic looks exactly the same to me. 3ms // Update the count array ...
DDD's user avatar
  • 1
0 votes
0 answers
36 views

Typescript Json get value [duplicate]

I'm getting from api {"bmw":[{"year":2022, "color": "black", "perfs":{"bmw":{"model": "x5", "county": "...
Po'latjon Qurbonov's user avatar
-3 votes
2 answers
41 views

Uncaught ReferenceError: a is not defined on line: 10 [closed]

I am trying to solve this challenge. Question Given are two arrays a and b, both have three elements. Return a new array of length 2 containing both middle (index 1) elements of the arrays). Error ...
terry ikporo's user avatar
-1 votes
0 answers
29 views

Mysql fetch array doesn't show results even if the query is correct [duplicate]

I create the connection, which is right $servername = "localhost"; $username = "myuser"; $password = "mypass"; $db = "dbname" $conn = mysqli_connect($...
Marco Scarpa's user avatar
1 vote
1 answer
22 views

React Native trying to use same array globally

I am trying to learn React Native and am wondering if there is a way to store an array, say in a constant file or something, and reuse it in different components. States will be one, as an example. I ...
toddinator2's user avatar
-1 votes
1 answer
49 views

Go type assertion (any) [duplicate]

This seems likely to be a duplicate but I couldn't find a solution. Please point me in the right direction if it is a duplicate I am relatively new to Go and here I am trying to create a helper ...
Emil's user avatar
  • 378
0 votes
1 answer
60 views

Why does my C program with any input results in segmentation fault?

I've spent hours of racking my brain on why doesn't this work #include <stdio.h> #define MAXLINE 1000 #define TRUE 1 #define FALSE 0 int getLine(char s[], int lim); void copy(char to[], char ...
JERVIS JAMES PEDOTIM's user avatar
-1 votes
0 answers
55 views

How to get an object of value from dropdown menu instead of a string? [closed]

Running the code I have a string but I need an object. Any way to do that? <!-- language: lang-html --> <select name="plates" id="degrees"> <option ...
Igor's user avatar
  • 1
-1 votes
1 answer
32 views

Is there any design pattern or way in Javascript that can be used to display some of the fields in nested JSON array

Below is the nested array of objects that needs to be displayed as a table. Currently, map is used to loop through items to return another array of all the elements required to display. { "...
Rudra's user avatar
  • 729
-1 votes
1 answer
63 views

array_filter() returning the entire array instead of just the key value [duplicate]

I am doing a work around with PHP array_filter() function. I am noticing a strange. Let me explain. This is an array $languageDataArray:- $languageDataArray = array( array( 'id' => 1, ...
Saswat's user avatar
  • 12.6k
1 vote
0 answers
46 views

Copying differently contiguous arrays vs same contiguity arrays

I'm observing different speeds on different machines, but couldn't reason why. Please help me find the reason behind this and how one can handle this difference in performance-critical code - running ...
Vedaant Arya's user avatar
-2 votes
1 answer
55 views

Binding/Pass-By-Reference for Array from Struct to Struct

I have one struct, struct DropletsView: View {} which has the following array: @State private var savedQuotes: [Quote] = [] (Quote is defined elsewhere, as a custom type for my app). I would like to ...
Daggerpov's user avatar
  • 162
1 vote
5 answers
71 views

In C#, I'm trying to iterate strings in single loop, how?

I'm trying to achieve this output: LOWEST LOW MEDIUM HIGH HIGHEST HIGHEST HIGH MEDIUM LOW LOWEST I know there are many ways to do it, but I'm trying it in single loop, is it achievable? My code is ...
Norvz's user avatar
  • 27
-2 votes
1 answer
24 views

Find my value in a range of key-values in an array of objects

I need to find my value in a range of key-values in an array of objects. And then perform some math on the object that matches the criteria. const array-of-objects = [ {w1: 0.1, w2 0.5, Jv1: ...
Igor's user avatar
  • 1
0 votes
1 answer
18 views

Is it possible to limit results from Svelte {#each} loop by a certain amount?

I'm using an {#each} loop to showcase data, but I'm curious if Svelte has a way to limit the results by an integer. For example, if I had the following array and loop: const object = [1, 2, 3, 4, 5]; ...
Sam Sabin's user avatar
  • 707
0 votes
0 answers
28 views

unable to take input of strings from user [duplicate]

I have to make an array of structure for cricketers presenting their name, age etc. and take input of each value from user . I am trying to get value of name from the user but my code editor keeps on ...
Harshit Gupta 's user avatar
2 votes
0 answers
32 views

Completely deleting elements from Matlab R2020b cell array

I have a Matlab R2020b cell array with <missing> values: my_array = 6×1 cell array {'a' } {'b' } {'c' } {'d' } {1×1 missing} {1×1 missing} ...
AmericanJael's user avatar
1 vote
1 answer
43 views

Accessing variable name inside proc in tcl

I am trying to create a proc that lists all elements of an array: Here is the proc: proc array_values {array_input} { upvar $array_input arr foreach name [lsort [array names arr]] {puts "arr($...
J.S's user avatar
  • 47
0 votes
0 answers
18 views

Time Complexity of my Subset Sum Problem's Solution [duplicate]

class Solution { public: vector<vector<int>> subsetsRec(int i,vector<int>& nums) { vector<vector<int>> ans; if(i==0){ vector<int>...
code madeEASY's user avatar
-3 votes
0 answers
27 views

Repeated indexes in list - Python [duplicate]

I have a long list, that is read from .csv file and it goes like this: frequency = [..., 398, 399, 398.8, 400, ...] and so on... I need to find index for each value, but if the frequency value ...
TeshE's user avatar
  • 5
0 votes
1 answer
49 views

Excel data validation list from range specified in calculated cell

I have several columns with time values. With a Data Validation, I display a list that takes the values from a hidden column with a large range of time values. Depending on the value of another field, ...
amavg's user avatar
  • 3
-1 votes
1 answer
39 views

Array Index Out Of Bound Error for Finding an element in an infinite array by Kunal Kushwaha video

My Code public class InfiniteElement{ public static void main(String[] args) { int[] arr = {1, 2, 4, 6, 8, 9, 10 , 13, 16, 19, 20 ,23, 27, 40, 42, 44}; int target = 44; ...
UDAYA KRISHNAN.M's user avatar
0 votes
0 answers
54 views

Push entries into a result array from deepest nested loop, but also push an entry when deepest loop is not reached

I am creating an array for an order to then pass this data to stripe, the array has multiple forEach clauses. The issue I am facing is, if the order item(s) does not have menu_options it is not ...
George Richardson's user avatar
2 votes
3 answers
100 views

Do brackets have effect during array of pointers declaration?

Recently I was reading "The C programming language" text book by Brain and Dennis and encountered that there is a difference between the pointer array definitions shown below: int (*a)[10]; ...
Abenaki's user avatar
  • 25
-5 votes
1 answer
83 views

Union of two sorted arrays- GFG [closed]

vector<int> findUnion(int arr1[], int arr2[], int n, int m) { //Your code here //return vector with correct order of elements vector<int> temp; int i=0; ...
DeeZ's user avatar
  • 17
2 votes
0 answers
52 views

How does a string unexpectedly become an array?

In one of my script I have the following problem: assigning to a string variable the result of a function makes the string an array. Example: ---------- (function edited for clarity) $x="" ...
LuigiV TH's user avatar
0 votes
0 answers
12 views

Mixed bracket types. Is this json or something else?

I am trying to parse data from a URL. I think it looks like json but I'm not sure. The URL also doesn't end in .json (something like https://google.com/file). The format of the data on the page looks ...
Cyoung75's user avatar
-1 votes
1 answer
25 views

Why I receive an unknown variable error in my function?

I'm using AlgoBuild and inside the "input_vet()" function there's a while loop and in its condition I recall the variable N, which I assign a value in the main, and shows a unknown variable ...
giuamato50's user avatar
0 votes
0 answers
36 views

How do I dynamically allocate memory for a multidimentional array in C? [duplicate]

Dynamically allocate memory for a multidimensional array (matrix) with a specified number of rows and columns. How to allocate memory? How to allocate memory for 2D array? How to dynamically allocate ...
Samhitha Harini's user avatar

1
2 3 4 5
8347