Questions tagged [arrays]

An array is an ordered 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 which is specific to a programming language, tag the question with the programming language being used.

0
votes
0answers
8 views

What should be the better approach to find the minimum number of swaps required to sort the array in ascending order?

I am using below algorithm to solve this problem but it fails in major of the test cases. Please help me to find where i am making the mistake. def minimumSwaps(arr): l=sorted(arr) count=0 ...
0
votes
0answers
6 views

Array concat of the Uint8Array, output of the Chip And Pin Device

I'm getting a output data from a device as series of array. This array comes 5 times each time carrying a 64 item in it while swiping a card into the device. I want to concat these array. Below is ...
0
votes
0answers
6 views

How i can query in mongoose to get the “answers” array where 'objective' inside the 'answers' array is “Awareness”

this is my mongoDb strucure I'm trying to get the list of 'answers' from "Response" mongoDB using mongoose in nodeJS where the 'objectives' array contain 'Awareness' and specific 'projectId' also. But ...
0
votes
1answer
41 views

How to pass array elements in constructor?

I got an assignment in which i have a constructor having Name and an result array contains the marks for 5 subjects. I created a constructor an passed Name and Array using for loop. But when i created ...
-2
votes
0answers
20 views

How to solve Array to string conversion in C:\… inside an array in PHP? [duplicate]

This is my array: $aArrayRand = array( "<tr><td>$aSettings[settingOne]</td></tr>", "<tr><td><input type ='text' name='txtAnswer[$aNumbers]'</td></...
1
vote
3answers
23 views

Array won't assign more than 8 characters in python [duplicate]

Array is acting weirdly, I have this code: a=np.array(['dfdfdfdf', 'gulf', 'egypt', 'hijazi a', 'gulf', 'egypt']) And I did this: a[0]="hello there my friend" Result was: array(['hello th', 'gulf'...
1
vote
2answers
27 views

What alternative of code that work in PHP7 in PHP5

I have a PHP code which runs on PHP7 but not in PHP 5, which PHP version in my server, that is my code: Array ( [0] => stdClass Object ( [userId] => 15 [name] => name0 ...
0
votes
0answers
11 views

How to recieve a buffer of ints and strings from a client , and store them right? (cpp server , python client)

I have a simple cpp server which receives a char * buffer from a python client and unpacks it in order to use the data. the python client sends a buffer which includes 2 "different" data types - ...
2
votes
1answer
36 views

How to continue providing method on array until it's become equal to other array

I have int1[k] array with values equal to it's indexes {0,1,2,3...}. I also have a method1 that takes that array and returns another int2[k] with values shuffled in such manner: initial deck: ...
3
votes
4answers
38 views

How to generate number with 3 digit from list of number by c++?

I'm a new programmer, and want to generate array of number with 3-digits from number list (2,5,8). I have created a code, but the output is not my expected result. This is my simple code: int main() {...
0
votes
1answer
28 views

PHP array_push() is pushing object incorrectly into another array before pushing

I'm looping over some data and dynamically creating an object which I want to push into an array. $messageObj = new stdClass(); $recipientsObj = new stdClass(); $messageObj->message_recipients = ...
-4
votes
0answers
35 views

why the toString method on arrays in java? [duplicate]

Wy do we have to convert an array declared as string to string (use toString() method) for it to output it correctly else it displays some numbers?
0
votes
0answers
14 views

How to compute the final result from Json Array using “and” operation is applied on it

I have a json file containing array , AND operation is applied on array . I need to compute the final result from a array based upon the operation . Json Array { "op": "and", "tok": [ ...
0
votes
0answers
9 views

How to compare file names in a directory and return matching names in excel VBA

I'm trying to write a VBA code for a macro that merges a .pptx file and an .xlsx file in a specific way. I already worked out how to code the merging part. However I have a directory with hundreds of ...
2
votes
2answers
41 views

How to put objects in an array into new array sorting by date?

I want to use SectionList in React Native. Datas that SectionList needs to render looks like this: sections=[ { date: 'May 24 2019', data: [ { id:1, msg: 'msg1', ...
0
votes
5answers
44 views

How to filter data with lodash

I have code as follows: data = [ {id: "15130", state: "INITIAL"}, {id: "15129", state: "LOCKED"}, {id: "10314", state: "APPROVED"}, {id: "51", state: "APPROVED"}, {id: "10313", state: "...
0
votes
0answers
18 views

Hi, using Java how can i return a 2D character array from a method that is taking in a String? [duplicate]

I am attempting to print out a 2D array in a main class by passing a string through the isValidTicTacToeBoardString(String str) that shows a board of X's and O's (tic tac toe) by using a string. Any ...
-1
votes
0answers
12 views

replacing the age groups with an indicator array

Age_group Population_size 15-24 172675 25-34 123065 35-44 96216 45-54 92051 55-64 72159 65-74 54722 75-84 32185 what command ...
-1
votes
0answers
35 views

How to Expand JSONObject Size?

I am working with web services in Android. This web services return JSON data and I am parsing them. But, I have a problem. Now, I had 4810 object in JSON. When I am parsing this JSON, i just take 211 ...
0
votes
0answers
17 views

Matrix is represented as a single array in memory and Problem with matrix multiplication

I tried to make the Matrix header file. I also gave it a go at representing the matrix with a single array. Every method I wrote worked just fine. On the contrary, I couldn't figure out the problem ...
0
votes
1answer
47 views

Merge two arrays by index value by different value in the array [duplicate]

I have two arrays and I want to merge the values of the two arrays into a single array, but both arrays have different values. Example: var arr1 = [ { data1: 1 ,data2: "value1"}, ...
0
votes
1answer
29 views

How do I get retrieve a specific value inside an array? [duplicate]

I have the following array from a json response: { "countList": [{ "count": 6, "paramToGroup": [{ "name": "severity", "value": "HIGH" }] }, { "count": 1, "...
0
votes
1answer
40 views

SQL in operator with string arrays [duplicate]

Unable to append string arrays with SQL in operator dynamically. If more values are passed to the array dynamically, how to append it within operator in Oracle SQL query? String[] rsIdArr = dObj....
0
votes
3answers
19 views

Get only unique value in array by case sensative

I want unique array from an array by comparing all values to lower case or upper case so i can get perfect array.suppose you have two values in array like 'php developer' and 'Php Developer', both are ...
-4
votes
3answers
41 views

Removing uneeded KEy from Javascript object?

I have said array full of objects: [{ ID: 1, Subject: { edge : [ {node: {ID : 1, Title: "English"}} ] }, ID: 2, Subject: { edge: [ ...
0
votes
1answer
31 views

C# Permutate a set of strings given n and given the maximum array length

How can you permutate the set of strings based on the set length, I have lets say 50 values in an array and only want to combine 24 values that is comma delimited Examples: (string1,string2,string3) ...
1
vote
4answers
34 views

Array.map : get the index of each element to use in the return function

I'm looking for a command that returns the index of an element so I can use it in map functions. Here's an example : function myFunction() { var a = [4,7,9]; //Looking for a way to return ["...
-2
votes
2answers
33 views

object index sorting in javascript

I would like to sort the object indexing like array.sort Input is "a":{"label":"0",isEnabled":false,"status":1}, "1":{"label":"1",isEnabled":false,"status":1}, "$":{"label":"2",isEnabled":false,"...
0
votes
1answer
28 views

How can I add index as a parameter to useEffect hook?

Well, I am trying to figure out how to play with an array within useEffect hook. Basically, I want to know how to pass index as a parameter so I don't have to grab the indexes manually. I am fetching ...
-1
votes
0answers
26 views

How to show the 5 most repeated records in an Array?

I have two text files that have customer records and cards So far I have, A record for each time a client is registered in the card file in the vector Now I need to know, the 5 most repeated clients ...
0
votes
3answers
38 views

Count the occurence of each words in a string and put it in an object

I need to get the total count of each word in a string . I wanted to achieve it using reducer since i am a beginner in the reduce method i could not solve it . getWordOccurence = (str1) => { ...
0
votes
1answer
39 views

Irritating object keys and there values from 1 line of an object with es6?

I have a object with one line of keys and there values. I am trying to map these keys and display the values. productObj = {id:0, name:"toy", price:10, description:null, inventory:7 } ...
0
votes
1answer
28 views

Array based Binary Search out of bounds

The problem is I have an array based Binary search tree that needs to take in nearly 2000 lines of information from a text file read from a file IO. However, I continuously get java.lang....
1
vote
2answers
58 views

In what order should memory be deallocated in c++?

I'm having a little difficulty understanding the correct sequence of events that should happen when using the delete operator in C++. I've internalized that the proper way to use this is when a ...
1
vote
1answer
35 views

I want to change a order for reading array in python, do I have to use reshape?

I read a tif image(3D stack), and its original size is 100 X 120 X 150(example). But, when I imported this, this size was 150 X 120 X 100. I tried to reshape this by using matrix.reshape, but I ...
0
votes
4answers
43 views

How do I get values from an array without counting its duplicates?

I know the title is really bad but I spent like 10 minutes thinking of a way to describe my problem in a concise way and couldn't. This program is supposed to create a numUnique() static method that ...
-1
votes
1answer
29 views

Dynamic array of abstract class [duplicate]

I have an abstract base class called CBase and two other classes CDerived1 and CDerived2 that are derived from CBase. How would I now create a dynamic array (i.e. add and delete elements at runtime) ...
2
votes
2answers
26 views

Get every fourth of array and check between

I have array like this: let arr = [ { x: 31, y: 8 }, // get 1 { x: 32, y: 8, monster: { is: true, id: '19216' } }, // get special { x: 32, y: 9 }, { x: 32, y: 10 }, { x: 32, y: 11 }, // ...
0
votes
0answers
28 views

How can I apply multiple conditions to decide what values are written from an array to a target destination?

In an effort to streamline my efforts for a data transfer macro, I have moved to arrays. I have limited experience with them, let alone vba. But I was able to build it, and have it write. The last ...
0
votes
0answers
12 views

i want to access contact_id in a json decode data [duplicate]

please someone should help me on json and php i want to access contact_id in a json decode when you run the above code it show CONTACT REGISTERED - OK - REGISTERED .. { "result": "CONTACT ...
0
votes
3answers
37 views

How to get lowest integer from objects in an array?

Basically what I'm trying to achieve, is the lowest integer from an object thats in an array with other objects. r.Collection is an array that holds 3 objects, so it looks something like this: [{...
0
votes
0answers
15 views

Save a pandas dataframe with a column with 2d arrays as a parquet file in python

I'm trying to save a pandas dataframe to a parquet file using pd.to_parquet(df).df is a dataframe with multiple columns and one of the columns is filled with 2d arrays in each row. As I do this, I ...
0
votes
1answer
29 views

Most efficient way of getting large std::vector into Swift?

I have an Objective-C class that populates a std:vector with millions of points. The structure of the vector is: typedef std::vector<CGPoint> CGContour; typedef std::vector<CGContour> ...
1
vote
2answers
27 views

How to remove empty arrays from an array of arrays?

I have an array of arrays which includes some empty arrays. Exp. [ [Name1],[Name2],[Name3],[],[] ] I tried using shift and splice (example code given) function RemoveEmptyArrays(){ var NameArray =...
1
vote
1answer
24 views

Find index corresponding between two different sized array lists with same total elements

How can corresponding array indices be found within two differently shaped arrays of arrays that are the same size? For example, an array x of size 36 is split into 11 arrays. Another array y of ...
0
votes
0answers
14 views

VBScript (.vbs) Produces Errors When Executed From A 2nd .vbs

We have a vendor who sends us csv index files to be used with our OnBase document import software. If the csv file was generated using one of our institutional forms, OnBase ingests them w/o error as ...
1
vote
0answers
24 views

How correctly reassign pointer to array Matlab Coder?

I have the following code: add.h: #ifndef ADD_H #define ADD_H void add(double **a, double **b); #endif add.c: #include "add.h" #include <stdlib.h> #include <stdio.h> void add(double ...
0
votes
1answer
11 views

php file returning error converting to JSON for android GET request

I've successfully setup retrofit 2 in android studio. The app displays the following error when doing a GET request to the mysql database via the php file. expected begin_array but was string at line ...
0
votes
2answers
43 views

How to sort strings alphebetically

I have run into a problem of sorting strings from an Array. I was able to sort integers, but I don't really know how to sort the Strings from shortest to longest. I have tried converting the ...
0
votes
1answer
21 views

How to push values to array in one function and read it in another function?

Here is my code: var myObject = []; function something() { myObject.push("thing"); } function other() { console.log(myObject); } How can I let other see the items pushed into myObject by ...

http://mssss.yulina-kosm.ru