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
-1 votes
0 answers
32 views

Can I create an array of arraylists of arrays in Java?

What I want to create is a 10-element array that consist of arraylists. Also the arraylists should consist of 3-element(string) arrays. (Something like metroMap[10][?][3]) I learned that arraylist of ...
  • 9
-1 votes
1 answer
13 views

How to Paginate More Than 1 Array? PHP

I have Three Arrays.. I want to make this 3 Arrays to have 20 result per page, each of it.. Array 1 $Array1 = Array ( [0] => 86456 [1] => 86456 [2] => 86456 [3] => 86456 ...
0 votes
1 answer
16 views

Struggling to map through nested object.. React

Trying to map through instagrams api return but struggling to get the syntax right and its driving me crazy. <img src={feeds.data[0].media_url} /> {feeds.map((feed) => ( &...
-2 votes
1 answer
33 views

Why is the output missing the first letter when I use strcat() in c++? [closed]

Here I want to merge two char arrays and put them into the first char array But when I cout the second one, it is missing the first letter. why? #include <bits/stdc++.h> using namespace std; int ...
0 votes
2 answers
27 views

Filter returns an empty array when trying to check the length of numbers

I should create a function that given an array of numbers and a specific value, returns another array filled with those numbers in which the number of digits matches the specified value. function ...
  • 1
0 votes
1 answer
15 views

Use three prompt boxes to ask the user for three different words and then place them in an array. Use an alert box to display the array

So, I'm new to JS and currently taking courses. My instructor listed one solution, and the solution I came up with in my opinion is more ideal...I used push() method which I'd think is better. And I ...
-3 votes
0 answers
16 views

i want to create an object StudentLab that has an array of students of size N , and in this array i want to put the objects of the class Student [closed]

I have 5 class one UserInput which works fine , these 2 and a Student and a TestStudent and these work fine too. StudentLab has an array of objects of type Student and i want to store in the ...
-1 votes
1 answer
23 views

I can not pass the certain test in js case on codesignal.com? am I wrong or something wrong with this website?

So I am doing some exercises with JavaScript in codesignal.com. This is my Code. This is a Task: The next step is to support the operation for finding the nearest integer in the container greater ...
-1 votes
0 answers
10 views

take string input from user and print whether vowel or consonant calling another method in the main method [duplicate]

I'm trying to take lowercase user input and print whether it is a vowel or consonant. An array is declared in a method outside the main method. My code is as follows. package user_input; import java....
  • 1
1 vote
1 answer
33 views

Html filtering for two tables, and letters array

I am using the following JavaScript to filter table contents (all columns), but I am facing a few issues: 1- I want to add an array for letters so it shows some words that has same letter, but ...
  • 1,947
0 votes
3 answers
31 views

Convert a complex dictionary into a set of arrays in Javascript

I have an flat object in javascript as { top1: { obj1: {} obj2: {} } top2: { obj3: {} obj4: {} } top3: { obj5: {} obj6: {} } } ...
  • 263
0 votes
3 answers
30 views

(Javascript) Why declare CONST ARRAY in LOOP doesn't cause error [duplicate]

As far as I know, it is not possible to redeclare a const array. However when I declare arr inside the loop, it seems that arr is redeclare for each iteration. I don't understand this situation, does ...
  • 1
0 votes
1 answer
17 views

html table filter, array and ignore html

I am using the following JavaScript to filter table contents (all columns), but I am facing a few issues: 1- I want to add an array for letters so it shows some words with "French accent marks&...
  • 1,947
2 votes
1 answer
26 views

how to render a nested object inside of an object in react js

I want to render an nested object inside of an object.I'm not sure if I'm saying it right but see it for yourself first. I want to show the minimum_system_requirements objects.I mean graphics,os,...
0 votes
1 answer
32 views

Only Keep Specific words in a string

So i have a string which will be a location such as: 'Lawrence Street, York, YO10 3EU, United Kingdom' 'York, YO10 3EU, United Kingdom' 'Hertford, Hertfordshire, England, United Kingdom' Etc However, ...
0 votes
2 answers
44 views

Combine elements within the array

Is there a way to combine individual elements and their subtrees within a PHP array? For instance, to convert this: $test=array("EW"=>array(313, 1788), "SC"=>array(670, 860),...
  • 221
-3 votes
1 answer
31 views

How to log array or object without some elements

I have the object {"ID":2, "Name": "dfdfdfd", "type":"Point", "type2":"Point", "geoData":{"coordinates":[37....
0 votes
4 answers
44 views

For example an array like this one [mango, banana, apple, orange, pineapple] will produce an array like this [m, a, p, n, a]

Please I need an assistance, please how to loop through an array indexes and increment the output by 1 I mean like to loop through an array indexes and for the first output of the index 0 will logout ...
-4 votes
2 answers
48 views

php sql select, maybe array? [duplicate]

How can I display this data with a sql select statement? Do I need to put it in an array? I can get it formated like this $ Y Y Y Y Y Y Y N $ Y Y Y Y Y Y Y or $ Y Y Y etc.. I want 179359: $ Y Y Y Y Y ...
0 votes
0 answers
26 views

ArrayLists won't invoke due to the ArrayClass having an error? 'Cannot invoke "java.util.Collection.toArray()" because "c" is null' [duplicate]

I can't seem to use an ArrayList, or LinkedList, for some reason. I am able to use them in the method below the 'calculateLegalMoves' method but for some reason only that method seems to have a ...
  • 1
-1 votes
0 answers
13 views

removing similar integer of arraylist if it is same as its neighbour element and tell size of arraylist in java [closed]

Chef recorded a video explaining his favorIte recipe. However, the size of the video is too large to upload on the internet. He wants to compress the video so that it has the minimum size possible. ...
0 votes
1 answer
31 views

Which has more space and time complexity : Logical vs update statement [closed]

Please see the given 2 codes that updates element of a matrix to 0: for(int i = 0; i < rows; i++){ for(int j = 0; j < cols; j++){ if(matrix[i][j] != 0) matrix[i][j] = 0; } } 2nd one:...
0 votes
2 answers
33 views

How can I deduct the user's quantity to the store's stocks if this code is like this?

Here is the sample code, let user = { fullName: "Guest User" cart: [ { subTotal: 300, product: [ ...
  • 11
1 vote
2 answers
45 views

Input Validation on Array

I am attempting to input validate a user's value. Criteria: The value inputted cannot be a negative number, in my case the error is encountered when a user enters the wrong value, but instead if ...
  • 41
0 votes
2 answers
45 views

Flat-list initializer for an array in C

An exemplary 2D array initialization goes like this: int arr[3][5] = { {0,1,2,3,4}, {5,6,7,8,9}, {10,11,12,13,14} }; We are taught that this is the "correct way" of initializing an array. ...
  • 2,226
-1 votes
0 answers
17 views

How to convert a string into a array in JavaScript? [duplicate]

I'm trying to convert this string let arrString = "[2, 4, 5, 7]" into an array like this arr = [2, 4, 5, 7]
-1 votes
0 answers
14 views

How do I select a car make and then select model according to make [closed]

good day i want to make spear part app it will be like this make->model->sub->year->then around 10 spear part belong to the spifisc car what a best approach way to it class or arry ? thank ...
0 votes
1 answer
44 views

Add Key/Pair value to an object dynamically

This is how my data looks: [{ "key": 111, "Students_Info": [{ "recordId": 111 }], "Adress_Info": { "position": 1,-- -- -- &...
  • 15k
0 votes
2 answers
20 views

How do I assign my array of int numbers with their proper String in my simple slot machine program?

I am having one of the most frustrating moments in my life (second semester coding challenge). I am utilizing two lists to obtain three random numbers, and then I want those three random numbers to be ...
-1 votes
3 answers
46 views

Sort array of objects based on position [closed]

I have this array of objects and would like to sort them based on their position. [ { "key": 333, "Students_Info": [ { "recordId": 333, &...
  • 15k
-3 votes
0 answers
15 views

C Programming Code for Matrix add,sub, multiplication, transpose (values given by user) [closed]

Values should be give by the user for the matrix I am not able to do it by using c Language
0 votes
1 answer
25 views

Getting Top 5 objects in array with highest value

I need help to make the following possible, I have an array of objects and I want to extract the TOP 5 objects with the best value of return and in order from best to worst. How could I do it? Heres ...
  • 159
1 vote
1 answer
31 views

What is the difference between grid[index] VS grid[index, :] in python

In this https://colab.research.google.com/drive/1gS2aJo711XJodqqPIVIbzgX1ktZzS8d8?usp=sharing , they used np.max(qtable[new_state, :]) But I did an experiment and I don't understand the need of : . My ...
  • 15.8k
0 votes
0 answers
16 views

What is the concept of suffix array? Where to use it?

I'm not getting the concept of suffix array I have tried to understand the concept of suffix array but not getting it
0 votes
1 answer
37 views

The default value of array is 0 in java, why is it not getting printed in my code? when I am taking size of the array from the user

I have the below code wherein I am taking "n" as the size of the array from the user, for testing purpose, I am only providing few inputs, i.e n-1 inputs to the program. My understanding is ...
  • 11
0 votes
1 answer
18 views

My max value wont display, but i cant see or figure out why

I am trying to find the maximum value a user has entered from a 1D array, but the function i have set up wont display a value. I usually use visual basic and have done limited java, so I'm new. public ...
-1 votes
1 answer
45 views

Understanding enum arrays in C++

I'm following along a book on teaching yourself C++, and there's a question about creating the layout of a chess board using enums and arrays. Looking at their solution, they call an enum to declare ...
0 votes
0 answers
22 views

I need to find peaks in the data of the y-Gforce difference

I need a python script that finds the peaks of each period in a csv file wih the following format: time gFx gFy gFz 0 0,0039 0,0005 0,0008 ... ... ... ... 8 0,0052 0,0015 -0,0002 the values ...
0 votes
1 answer
48 views

How do I know whether to use a std::array or std::vector for data parsed from a file, and how can I improve allocation performance?

I have an input file, and it has 3D vector data line by line. I want to read this vector data and store it in the program. I thought I have two options: I can count the number of lines, and I can ...
  • 45
2 votes
2 answers
35 views

Sort array according values from another array

I have two arrays .First array (points) is arrayOf(22, 8, 17, 13, 20) and second is an empty array. How can I set the rating to second array, according points in the first array. E.g. largest value is ...
1 vote
2 answers
30 views

How to group items in list in python if the value change? [duplicate]

Suppose I have a list msg_type =["sent-message", "received-message", "received-message", "sent-message", "received-message", "sent-message", ...
0 votes
1 answer
24 views

How to get Array as input in React?

I'm trying to get array as input from DOM in react I tried to do it like this const [arr, setArr] = useState([]); <input value={arr} onChange={(e) => setArr(e.target.value)} /> How can I ...
-1 votes
0 answers
29 views

Format String on a String that receives a HTML text

I have a String and i need to format to get the seccond result. Forgot that's an html on that String. Im using Java <div class="container-fluid backimg d-flex flex-column align-items-center ...
0 votes
1 answer
10 views

Android app crashes No virtual method readAllBytes()

We have reported some crashes from Android 9 and 10 devices when they try to read pdf file with this method: fun getPdfImageFromUri(uri: Uri?, applicationContext: Context): String? { var ...
0 votes
1 answer
36 views

update the state of an object who's values are an array

I'm looking for a way to update a single index of an object's values that are an array while saving the state of the other values. I tried using a spread operator, but I'm getting an error. const [...
  • 74
-4 votes
1 answer
58 views

C langauge, char filename[] = scanf("%s", filename); Causing error [closed]

I am wondering why Vscode is throwing an error at the line: char filename[] = scanf("%s", filename); The error says:
0 votes
1 answer
26 views

Filter multidimensional array if specific key value is not empty or greater then 0 with PHP [duplicate]

i'm not a professional developer but doing some stuff around home automation in conjunction with Sonos and PHP. I'm struggeling around how to filter an array and have no clue how to it best approach. ...
-1 votes
0 answers
24 views

Index Error: With Multi Dimentional Array

The bellow lines of Code Return the following Responce from the console shown bellow the Strikeline. I can't see a reason why it would be unable to access the Data area [0][i][1] Given the Debug ...
1 vote
3 answers
26 views

Transferring elements from one array to another array

I'm trying to create an array of values that are greater than a certain threshold entered by the user, so I'm transferring one array of total seconds and keeping the values that are greater than the ...
-3 votes
0 answers
27 views

Uncaught mysqli_sql_exception: Unknown column when trying to send a form that includes an array of diffrent selects for the same column [duplicate]

I am trying to submit a form to my database that contains several selects that I want to submit as an array. All the data is sent correctly except the selects. This is the error I get: DATA INSERTED ...

1
2 3 4 5
8237