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

0
votes
0answers
29 views

Building JSON array containing HTML

So, One of my companies developers wrote this. Not me. Alright, it was me. How can improve this puke? ...
0
votes
1answer
19 views

Word Counting from Array onto Output File [on hold]

For this problem, I have to have two text files: one for list of words that need to be found and other containing the document that needs to be search. The results would placed in a output "results" ...
0
votes
0answers
17 views

sortArray implementation [on hold]

I created this program called sortArray, (pretty self evident what it should do). And, I got rid of all the syntactic errors, but, I know there some semantic ...
0
votes
1answer
39 views

Creating an array length n * n, separating it into n groups, and adding numbers to it n times

I am completing the CodingBat exercises for Java. Here is the one I have completed just now: Given n > = 0, create an array length ...
1
vote
2answers
45 views

arrayHistogram implementation

I wrote this code, called arrayHistogram, that would generate a random number within a set range, and print it in an array ...
7
votes
4answers
186 views

Identifying array elements, rearranging them, and replacing them

I am completing the CodingBat exercises for Java, and, having learnt from the answers to the previous one, I completed the one that follows: Return a version of the given array where all the ...
5
votes
3answers
221 views

Rearranging array elements depending on their indexes

I am (still!) going through these CodingBat exercises for Java. Here is the one I have just done: Return an array that contains the exact same numbers as the given array, but rearranged so that ...
2
votes
5answers
211 views

Return true if the elements of an array do not contain one or the other

I am gradually completing the CodingBat exercises for Java. Here is the one I just did: Given an array of ints, return true if it contains no 1's or it contains no 4's. Here is my code: ...
2
votes
2answers
72 views

Applying limit and offset to an array

I'm refactoring an old gateway and came across the following method: ...
2
votes
2answers
31 views

Duplicating byte array multiple times

I have this code that duplicates a byte array 5 times. ...
-3
votes
2answers
34 views

Calculating the number of winners and losers [on hold]

A contestant is said to be a winner if his number is strictly greater than the numbers to his left and his right and a contestant is said to be a loser if his number is strictly less than the numbers ...
-4
votes
0answers
21 views

image to array / array to image, very strange display behaviour [closed]

I am creating a custom Byte[] array from an image, Then i turn back that array into an Image and display it into a PictureBox. ...
12
votes
5answers
472 views

Given a sequence of positive integers A and an integer T, return true if a continuous sequence of A sums up to exactly T

Here is the source of the question, and my solution is below. Did I determine the worst case correctly? If you find any input where it doesn't work, please let me know. ...
5
votes
1answer
43 views

Attempting a fluent API for creating random int arrays

I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with: fluent_arrays.h: ...
3
votes
1answer
60 views

NumPy array filter optimisation

I've got a filter that I'd like to work out how to optimise. The most basic implementation, using loops is like the following: ...
-1
votes
1answer
33 views
1
vote
1answer
55 views

Is this the best way to check sorting (in recursion) without loops?

Please let me know if there is a shorter way to do it again without any kind of loops. Recursion only. ...
2
votes
1answer
78 views

Find the max. difference between two array elements a[j] and a[i] such that j > i

The source of the problem is here. Given an array of integer elements, return the maximum difference of any pair of numbers such that the larger number of the pair occurs at a higher index ...
6
votes
4answers
225 views

Create a 2D array from SQL table

I am a beginner to PHP programming. I wanted to make a 2D array that would store the values of a table into the array. Below is the Frankenstein code I created (every time I wanted to achieve a task ...
5
votes
1answer
58 views

Hacker Rank: Extracting digits from a given number and check for divisibility

The problem in question is a coding challenge from Hackerrank: Problem Statement You are given an integer N. Find the digits in this number that exactly divide N (division that leaves 0 as ...
6
votes
1answer
73 views

Asc and desc array sort methods

I've used the typical INT array sort function found all over the internet for years, but I've also had a need to sort other items in an array, or even to just simple take an ...
6
votes
1answer
388 views

Cutting The Sticks

Problem Statement This is a challenge from HackerRank: You are given N sticks, where each stick has the length of a positive integer. A cut operation is performed on the sticks such that all of ...
3
votes
1answer
137 views

Find minimum element in a rotated array

Here's an implementation of finding the minimum element in a rotated array using binary search (one that is sorted in ascending order, and all elements are distinct). Please let me know of any ...
2
votes
1answer
31 views

Validate input of month/year, otherwise set it to current month/year

Is there a cleaner way of doing this? I'm using filter_input to first check for valid input, then using it again to assign the variable. Also, my condition in ...
3
votes
1answer
39 views

Polyglot function to sum all the numbers in an array in Javascript and PHP

This, again, is a very simple code. This is my 2nd polyglot question and this time I've tried to do something that I miss sometimes in Javascript. PHP has the ...
3
votes
2answers
77 views

Generic dynamic array

Here is the interface of my generic dynamic array; ...
3
votes
1answer
163 views

Sorting thousands of records

I have the following list to sort: A 0.53 B 0.56 C 0.56 D 0.98 E 0.33 Please note that my list may contains thousands of such type of records. I am sorting my ...
4
votes
2answers
71 views

Text files: Copy, Rename, Append/Merge together

I wrote 3 subroutines related to batch data processing, they will be used together. A bit of background, I wrote this for my admin colleagues who do not write code. An application dumps daily ...
3
votes
1answer
53 views

Rectangularize a list-of-lists structure

Considering I have an iterated "lists of lists ..." (up to 4 dimensions), now I wish to make the full list "rectangular" (or well each dimension equal in size). For a 4 dimensional case I've written ...
4
votes
3answers
952 views

Array Sorting in C++

I have this simple implementation for array sorting: ...
1
vote
0answers
47 views

Dynamic Programming with large arrays

Last week we have finished our program which applies a local search. At this moment the program needs more than three hours for the largest instances. The three hours are too long and we try to ...
2
votes
1answer
92 views

Array implementation of unbalanced binary search tree

I'm preparing for an interview. I tried implementing binary search tree in C++. I used array but it seems to be complicated to restructure the array while deleting nodes. Is linked list a better data ...
0
votes
1answer
44 views

Generate all permutations

I have written this Java snippet to generate all permutations of a given array of integers. Can somebody review it and give some pointers as to how to make it more generic? I.e. instead of dealing ...
5
votes
2answers
172 views

Matching words with a scrambled word

I have this code that reads in a "scrambles" and a "words" file. It compares both files using their canonical form and prints out the words from the "words" file that match a particular scrambled ...
2
votes
1answer
85 views

Join two arrays into a single one

I put together a function to sort out values that I am getting from a curl request for different 'devices', it works as is, I am only wondering if there is an easier way to to this. ...
2
votes
2answers
50 views

Find index of an object with a specific value stored in an array

I am using the following code in order to retrieve the index for an object stored in a JavaScript array. Scripts works fine, but I would like your opinion regarding performance. Also would like to ...
0
votes
0answers
37 views

Rendering JSON array as a tree

This code is working fine for me, but I want to simplify it. Function parents is defining parents of the tree and children ...
4
votes
3answers
58 views

Reserving seats in a movie theater

I'm writing a C program to reserve seats in a movie theater. I am validating the selection of seats: ...
1
vote
1answer
71 views

Populating an HTML combo box by looped concatenation

This code takes the results of a database query and uses them to populate the options in a combobox on a form. Would it be better to start with an empty htmlCode ...
1
vote
2answers
75 views

Show first n elements of array, and count elements not shown

This code mimics the "likes" tooltip from Facebook. Given an array with the list of users that liked the content, it shows the first n users and displays a final item with the count of the users not ...
2
votes
2answers
287 views

Filter out duplicates from an array and return only unique value

I have the following script, which filters duplicates and returns only unique values for an array. When passing false or nothing the "original" array is ...
0
votes
1answer
51 views

Remove particular element from an array and return indices of other elements

I'd like to get the indices of elements of an array with particular element. Is it okay or, or how can I make it even better? ...
6
votes
0answers
62 views

Mapping arbitrary Int values to a linear index space

This is part of a growing "primitive" tools collection here on github, and is the initial use-case for the IntArray for review here. Often, when processing data, you encounter unique values that you ...
6
votes
2answers
210 views

Finding pairs of numbers within A that add up to N

I am working on an interview question from Amazon Software Interview: Given an integer N and an array of unsorted integers A find all pairs of numbers within A which add up to N I have a working ...
10
votes
2answers
95 views

Using 2D arrays to make more efficient sequential storage

This code is part of a growing "primitive" tools collection here on github Use Case Consider: ...
1
vote
4answers
53 views

Finding the second largest element of large input sets

I have a problem where I need to find the second maximum element of the user inputs. It's an online practice problem and I can't figure out why the server responds back with a Non-Zero Exit Code error ...
2
votes
1answer
45 views

Reading and Converting XML File to Array

I'm using WordPress ( PHP Based Platform ) and I'm trying to read an external XML File, convert it into a usable array, then compare two arrays - one from the xml file and another from an options ...
3
votes
2answers
46 views

Transform a string into an array based on grouping rules

I've got a simple spec for defining character sets, ranges, or wildcards. I'd like to take the string and appropriately create an array based on these rules. I have a solution but I'm sure there is a ...
3
votes
1answer
57 views

Dynamic array implementation

I would like to use code below for general purpose dynamic array implementation in my future code. How does it look? array.h: ...
10
votes
4answers
166 views

Lottery number generator

...