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

-2
votes
0answers
11 views

Is this a reference copy or a shallow copy? [on hold]

What is the difference of a reference copy and a shallow copy? How do you populate a StringBuffer Array? And is this code correct, in respect to creating a reference copy? ...
1
vote
1answer
39 views

Copying one dimensional array bottom to top

I want to convert a one dimensional array to a two dimensional array with the following conditions and have followed the code from this question - ...
0
votes
0answers
8 views

Avoiding duplicate values in jQuery array [on hold]

I have the following code for using with select2. I am using Ajax to get the JSON from Mashape API. I received the object and can retrieve the value into tags. But I am having few values repeating. ...
-2
votes
2answers
56 views
0
votes
0answers
19 views

Am I scanning my contacts right? [on hold]

We are in an iOS app, in Objective-C. I have three types of objects involved here, Contacts, Users & ...
-1
votes
0answers
30 views

dynamic array which contains dynamic array c++ [closed]

I've stuck in a C++ code with Access Violation Error. Let me explain some of my related code. I have two structures related with each other by "item". And second struct has an dynamic array. ...
2
votes
1answer
11 views

Making a selection in a dropdown based on several possible values

I'm making a Chrome extension that lets you choose a size of an item and check out quickly. I have a value called "Large" in sizePref array in my chrome.storage. ...
1
vote
0answers
39 views

Porting Delphi typed arrays to .NET generics

Currently I am porting piece of code from some old Delphi API to C# and smashed into weirdness of type definitions. As its schema fits perfectly with DLL it uses (because it also was made in Delphi ...
4
votes
2answers
116 views

Finding all the subsets in an array of integers that sum to a given target

Problem Statement: Given an Array if ints, Find out all the subsets in the Array that sum to a given target value. Example: If the input array is: ...
1
vote
0answers
28 views

Array slice type in Java - follow-up

See the previous iteration. I have essentially fixed most of the issues mentioned by maaartinus. However, I left the size field as it is. Namely, if the user wants ...
1
vote
1answer
23 views

Reducing a 2D array to its longest unique series that aren't contained within any other

I have an array whose members are arrays containing strings. Each array has 5 elements, some of which may be empty but always at the end of the array. The order of the strings matters because their ...
3
votes
1answer
40 views

Array slice type in Java

Edit See the next iteration at Array slice type in Java - follow-up. I have this "slice" type for managing array subranges. It is kind of the same thing as Pythons slice notation, yet I did not add ...
6
votes
3answers
269 views

For each line in a file, read two integers and output the minimum

I am going through some CodingAbbey problems to learn basic programming tasks, with a focus on taking input from a file, and saving to another. I have just completed this task: Of two numbers, ...
3
votes
1answer
42 views

Generating realistic terrain data - Part 2

I've made a "heightmap" terrain generator similar to my previous one, except this one has some improvements, and some new features. The way this one works is similar to my last one, but slightly ...
6
votes
2answers
42 views

Recursively evaluate neighbors in a two dimensional grid

I'm creating a puzzle mini game where there is a board of gems, varying in color, and chosen at random. This is what my code generates: When you click on a gem the game should traverse the board ...
2
votes
2answers
92 views

Dynamically sized C array

I've been working in C for a while and have decided to implement my own dynamically sized array as an exercise and to actually be used in a project. I have also written Doxygen documentation for the ...
3
votes
2answers
43 views

Counting occurrences of duplicate items in an array

I have to make a simple program that reads N integers from the user and counts the occurrences of duplicate items. I know that the chosen sorting algorithm has poor ...
0
votes
0answers
53 views

Find the most efficient combination that equals target number in ArrayList

I want to implement the following function: Given a target sum, return the combination that equals the target sum and is the most efficiënt combination in the array of an ...
1
vote
2answers
61 views

Looping through an Array of objects to find an ID in a sub array

I have an Array of objects, each which contain their own sub Tags Array, and I need to loop through and find a matching id. ...
3
votes
1answer
84 views

Create a struct to store student data and perform statistical analysis on data

I had to create a program that had a struct that held data inside of it. I had to read an input file and take the contents and read it into an array of structs. Then, I had to solve for some ...
2
votes
3answers
123 views

Remove duplicate values in array with one loop? [closed]

I am writting a program to remove the duplicate values from an array, is any way to optimize code by removing one loop? ...
1
vote
1answer
64 views

Pixel bit-wise LSB extraction to byte array

I wrote the following code below to extract the least significant bit (LSB) of each pixel and store it into a byte[] array. I was wondering if Java has a more ...
4
votes
1answer
70 views

Finding common elements, ignoring duplicates, in two given string arrays

I am going through the CodingBat exercises for Java. Here is the one I have just completed: Start with two arrays of strings, a and ...
3
votes
2answers
62 views

Parsing a URL from a document and matching it from an array

I need help in improving this script that I have written to parse a URL and check it from an array. This is what I have done till now: (fiddle) This is working fine. Was this done correctly? What ...
3
votes
0answers
41 views

Von Neumann extractor to remove bias from pseudorandom array

Von Neumann extraction is a technique to remove bias from a source of entropy. You extract an unbiased array of bits from a biased one by comparing consecutive pairs of bits in the array and returning ...
0
votes
0answers
44 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
31 views

Word Counting from Array onto Output File [closed]

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" ...
1
vote
2answers
67 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
48 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
202 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
239 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
249 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
96 views

Applying limit and offset to an array

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

Duplicating byte array multiple times

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

Calculating the number of winners and losers [closed]

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 ...
14
votes
5answers
528 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
46 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
76 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
vote
1answer
58 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
173 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
275 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
86 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
0answers
93 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
462 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
143 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 ...
3
votes
2answers
71 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
43 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
82 views

Generic dynamic array

Here is the interface of my generic dynamic array; ...
3
votes
1answer
295 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
79 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 ...