An array is an ordered data structure consisting of a collection of elements (values or variables), each identified by one (single dimensional array, or vector) or multiple indexes.

learn more… | top users | synonyms

4
votes
3answers
249 views

Sum of subset of 5 numbers equals 0

I have a task to print all zero subsets of 5 numbers, input from the console. I have succeeded in implementing a working code, but it seems it is quite complex (it is like inception) and if the count ...
4
votes
2answers
76 views

Keeping track of byte count in a binary protocol handler

I am putting together a fairly simple server that listens for a connection then creates this thread - textbook Java code - then accepts data on that connection. I am following a protocol that the ...
4
votes
5answers
109 views

Find the value nearest to k in the sorted array

Given a sorted array returns the 'closest' element to the input 'x'. Note, I do understand merits of unit testing in separate files. But deliberately added it to main method for personal convenience, ...
4
votes
2answers
42 views

Multicriteria sort array javascript

I have an array of objects that I must sort based on two criteria. I've come up with a solution but I'd like to know if there is a better way to do it. Assume a list of devices: ...
0
votes
0answers
22 views

json list dropdown selector for car shop [on hold]

I'm trying to do a listdown selector for choose a car model by the user of my shop. but not I access the models of the second trademark. Specifically do not work from the Audi A3 model. I don't know ...
3
votes
2answers
64 views

Given an integer array of size n, find any three numbers

Return any three descending numbers that appear sequentially in the input such that A[i] > A[j] > A[k] and i < j < k. Since problem description contains 'any', I could not unit test using JUnit. ...
2
votes
2answers
62 views

Select evenly spaced subset from array [closed]

Say I have an array with 60 Elements, and I want to select 40 elements from this array. The subset should consist of elements with evenly spaced indices. In theory I would need to select every 1.5th ...
2
votes
2answers
44 views

Assigning array keys based on the values of another array

An optimisation question: Currently I have entities stored in text files in the following format: ...
3
votes
2answers
32 views

Search/Match algorithm between 2 vectors

I have 2 vectors of Facebook like pages which are represented by an ID from 2 different users. I want to verify how many liked pages are the same between these 2 users. This is my algorithm that I am ...
6
votes
3answers
315 views

Stack implementation using an array

I am trying a stack implementation using an array. I want to know if this approach is OK or if there is a logical problem. This program is working fine. ...
1
vote
1answer
32 views

Optimize jQuery code includes autocomplete function for different input box with different autocomplete content

I have this code below for autocomplete feature of several inputTextbox. The input box also share same class".wikiInput". When user typed something in either of them, a relevant autocomplete dropdown ...
1
vote
2answers
82 views

Adding very large arrays

I am writing a stochastic simulation for a Yule process: If you start with a certain number of bins each containing a random number of balls, you add another ball to an existing bin with a ...
6
votes
2answers
144 views

Inversion of an array that contains indices

I have an array of length n that contains numbers from 0 to n-1 in random order. I now want to "inverse" this array to one that where index i corresponds to the location of i in the source array. ...
9
votes
1answer
141 views

Bubble Sort in C: Array vs Linked List

A few weeks ago I posted a code review of a linked list so I decided to implement bubble sort on my journey of learning C. Here is the referenced linked list library, though this isn't really what's ...
10
votes
4answers
427 views

Find byte[] in byte[] with Java

I made a search method because I want to use binary data like PNG files. The point of this is to be able to find strings like IEND in a PNG file. I think it works ...
4
votes
1answer
33 views

Ranking a variant array with variable dimensions

I'm doing VBA macros and need to use Arrays of values extensively. After the below help from @TonyDallimore in StackOverflow, I've decided to use nested variant arrays. VBA chrashes when trying to ...
5
votes
1answer
36 views

Loading car photo's

I have been developing a small application for a client which combines two arrays together and then creates a URL and then loads the images on the same page from the given URL. I'd like you to look ...
14
votes
6answers
1k views

Array whose values are the product of every other integer

I was asked the following interview question over the phone: Given an array of integers, produce an array whose values are the product of every other integer excluding the current index. ...
3
votes
0answers
37 views

Sorting a PHP array in a discontinuous manner

I start with an array containing some 'ids' and some 'values'. What I need is to organize the 'ids' in a new array to be, if possible, apart when the 'values' they are associated with are alike. So ...
7
votes
2answers
74 views

Merge some child values back into the parent multidimensional array

This is a wonky PHP function I came up with to merge some select values from child arrays into the original. It could really use some help simplifying / making it more elegant. Is there a built-in ...
2
votes
1answer
54 views

Two script completing the same task, which is the best way?

I have the following two methods of completing the same task, however I'd like to know which is the preferred method and WHY? Or if there are any suggestions to complete the task in an even better, ...
5
votes
1answer
58 views

Working with list in Java

This code has a method that I call for in main. I am given a list with temperatures. What I need to do is to write out the biggest absolute difference of 2 ...
2
votes
1answer
152 views

Turning 1D array to 2D array in TicTacToe

To check a win in my TicTacToe game, I have created a 2D array that contains all the combination that a game can be won in, like so: ...
8
votes
4answers
182 views

Dynamic array of structs in C

Based on some code on internet, I implemented a dynamic array of structures in C. I am really interested in some feedback on this. Maybe there are some places where it can cause memory leaks or ...
9
votes
1answer
60 views

Pascal Triangle program in C

I've created a program to calculate Pascal's triangle: ...
5
votes
3answers
70 views

More efficient (or correct) way to make image grouping work?

It might be easier to read the explanation of what I was trying to do, and implement it a completely different way, rather than go through the code. But the code does what I want it to do, just ...
5
votes
1answer
84 views

Simple sparse array

Today, I tried to create a really simple sparse_array container adapter. I did not provide all the STL-like functions, only the elementary ones as a proof of ...
2
votes
1answer
42 views

Create object-properties from an array

I'm writing a simple table-oriented storage for objects. The schema of a table is stored in the columns-array and the data in the ...
4
votes
1answer
38 views

Multidimentional array initialization

I am initializing a PHP array as follows $newArray = array(); $newArray['2014-13-03']['SMD']['IMPR'] = 5; $newArray['2014-13-03']['SMD']['CLICK'] = 10; I just ...
10
votes
3answers
344 views

Writing a function to add or modify an existing object inside an array

I have an array of objects. Each object has two properties, id and quantity. I wrote a function to add an object to the array. ...
5
votes
1answer
84 views

Optimize Cython code with np.ndarray contained

Can someone help me further optimize the following Cython code snippets? Specifically, a and b are ...
7
votes
2answers
120 views

Generate permutations with symbols

Goal: Create a combination of emails based from inputted first name, last name, middle name, and a domain. Add in common separators. Then I'll check which one is correct with the rapportive API. This ...
0
votes
0answers
30 views

Checking login from associative array vulnerabilities

For a very simple databaseless website, I'm using an associative array to store logins like this: ...
3
votes
2answers
109 views

How to get the Split value from collection?

I have the following key value pair in an array, and am trying to extract and load them into a collection. The below code is working but it can be optimized using Linq: ...
2
votes
2answers
59 views

Is there a better way to combine these arrays?

Is there a better way to do this kind of array combination with a PHP native function like array_combine? I'm trying to improve my skills, and at certain points I ...
11
votes
3answers
1k views

Reverse a String in Java

Here is the code for the CString class that I created. ...
2
votes
1answer
68 views

Computing sum and counting matches in an array

The problem was pretty straightforward and used two simple algorithms from our examples; the one for computing the sum, and the one for counting matches. The array for the problem wasn't provided, but ...
1
vote
2answers
70 views

Same function but use different array data

I have these two carousels that randomly pick up pictures. [fiddle] Each of them picks up pictures and links from their own different inner array. It works fine as it is, but I was just wondering if ...
6
votes
2answers
82 views

Return index of array where sum first passes n

I have an array of integers and a number n. I want to sum the elements of the array and return the index where the sum passes ...
3
votes
1answer
56 views

Display PHP Menu Stored in an Array and Looped

I'm creating a PHP website for a non-profit. They have some restrictions (no MySQL or pre-installed CMS) so I'm creating a CSS menu displayed by an unordered list where all of the elements are stored ...
0
votes
2answers
37 views

Trying to convert an extended Array.prototype to a function

I got a random image rotator working by using the following script (demo). But I was told that it is a bad practice to extend Array.prototype. And it does. It ...
3
votes
2answers
56 views

Returning all the LIS of given array of int

I have this assignment where I'm supposed to code an algorithm for finding the quantity of Longest Increasing Subsequences from an array of (different) integers and print them all. I developed one ...
10
votes
2answers
105 views

Improve performance of math function applied to arrays

This block of code is already somewhat optimized thanks to some answers given over at Stack Overflow. In the last question I made (Improve performance of function without parallelization) the code was ...
10
votes
1answer
125 views

Faster way to find maximum deviation?

So, it was a part of my coding challenge and the last one, but I failed because it failed to yield a result in two seconds for some of sample inputs (out of six samples, three passed but three failed ...
4
votes
1answer
55 views

Writting day_of_month and month_day with pointers instead of array indexing

Rewrite the routines day_of_year and month_day with pointers instead of indexing. The exercise is quite simple, this is the ...
1
vote
2answers
183 views

Print the elements of an array into a table

I am trying to print the elements of an array into a table, but I'm having trouble formatting the array elements itself. Perhaps there is a better solution than what I'm currently using? ...
6
votes
1answer
65 views

Optimize YUV channel splitting function

The input pointer *data contains the data that needs to be split into different arrays and put in yuvInput. Each pixel is 32 ...
6
votes
2answers
2k views

Read an input text file and store the tokens in 2 different arrays

I am very new to Java so please ignore if there are obvious mistakes. If my question seems redundant then please guide me towards the correct link. However, I have surfed enough in order to find the ...
10
votes
3answers
130 views

Displaying random quotes from an array

Is there anything that I could have done better in this code? ...
1
vote
1answer
58 views

Problem comparing list to an array [closed]

I am attempting to compare an array to a list. The list contains 4 items that should be repeated in the array and in the same order. Previously all I had to do is make sure that each of the array ...