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
14 views

A small generic array in C [on hold]

The generic arrays in C I found on the net used either of these methods: the preprocesser with #define and #include (a lot of ...
1
vote
2answers
34 views

Finding the frequency of an element in a sorted list of integers

1> Input: Array of sorted integers and an element to check the frequency for. 2> Output: Frequency of the element ...
1
vote
6answers
57 views

Ruby array search, returning either a result with a good score or the last result

I have an array of hashes, each of which has two attributes: "title" and "Zscore". I want to return either the result of ...
1
vote
2answers
35 views

Create a calendar application to check the scheduling conflicts of meetings

The purpose here is to find if there is a conflict in the given set of start and end times of the meeting time slots listed. Input: Start and end times of meetings Output: True / False for conflicts <...
6
votes
4answers
230 views

A custom String Builder implementation

Two code files below : the actual logic & the test logic. Core Logic ...
3
votes
3answers
76 views

Checking if numbers in array are sorted or reverse sorted

I would like to determine is an array of numbers, is always increasing (for all x, x+1 >= x) or always decreasing (for all x, x+1 =< x). If so return true. Another way to state the problem is, ...
4
votes
1answer
60 views

Max difference between two array elements

Can I get feedback on below code? Problem statement is Maximum difference between two elements such that larger element appears after the smaller number Would this solution be still considered O(n) ...
11
votes
5answers
739 views

Removing n elements from array starting from index

This method removes n elements starting from a given index, from an array of a given type. If n is positive it removes elements forwards, if it is negative it removes them backwards (e.g. for an array ...
0
votes
0answers
13 views

Add and merge 2D array items so no nested duplicates on the outer array

this.collisions is a 2D array containing a list of collisions that, when bodies collide, they should be added to it. Here's an example: ...
3
votes
3answers
134 views

“Prev” / “Next” buttons for a circular list

I have an array of strings and on click of the "NEXT" button it displays the next array item in a <p> tag while on click of the "PREV" button it displays the ...
3
votes
1answer
52 views

Merging multiple sorted arrays into one sorted array

I would like to merge multiple arrays that are already sorted, into one sorted array. My arrays look like this : ...
3
votes
1answer
77 views

Enum string parse and get custom attribute assign to array

I wrote a code which: - parse string to my enum - get description from enum - assign to string[] array ...
-1
votes
2answers
63 views

Finding consecutive occurrences of a value in an array

Given an array, return True if the array contains consecutive values: ...
0
votes
0answers
11 views

Iterate through a 2D array. Kotlin extension method

Simple extension method for Kotlin. Should perform an action on every element in a 2d array. i.e. An array of arrays. I have made the assumption that because the receiver type is defined as an array ...
1
vote
1answer
133 views

Random iteration over an array using divide and conquer

I have created a utility class which allows random iteration over an array. The idea is pretty much a divide and conquer approach. ...
5
votes
3answers
117 views

Bubble Sort in Objective-C

Following is Objective-C method implementation I did for one of the most simplest sorting algorithms, Bubble Sort to sort an array of integers. Note:- I have defined it as a static method in the ...
0
votes
0answers
8 views

Selection Sort trouble with indexes [migrated]

Actually I'm dealing with CodeAbbey problem, so I don't want answer as code, but explenation about that, what I am doing wrong. http://www.codeabbey.com/index/task_view/selection-sort My Selection ...
3
votes
1answer
33 views

Access an associative array value given an array of keys in PHP

I have an object which stores an app configuration in an associative array, as this: ...
6
votes
2answers
91 views

Find number of plus in a 2d array

Problem CharGrid The CharGrid class encapsulates a 2-d char array with a couple operations. int countPlus() Look for a '+' pattern in the grid ...
6
votes
2answers
114 views

Longest palindrome in an array

I am new to programming, and think this code could be improved upon. Any suggestions? ...
2
votes
2answers
65 views

Multidimensional dynamic array class using a continuous block of memory

The following code is designed to be a multidimensional array that works off of a continuous block of memory. It is designed to be able to be resized at runtime, but only when a resize is explicitly ...
3
votes
1answer
30 views

Loading text into an array when fields are in random order

This script reads records from a CSV file of customer names and addresses. The first record of the file is the header (field names); the fields could be in any order, and sometimes have different ...
2
votes
2answers
52 views

Importing data into Excel

Is there an easier way of importing data into an Excel array or other data structure? I've tried researching collections but I have found the documentation hard to comprehend. MSDN The code I have ...
7
votes
3answers
243 views

Let's play Rock, Paper, Scissors

I have written my first rock, paper, scissors project recently. I had to use a lot of if statements and System.out.println(); commands in the program. I am wondering what ways I could optimize my ...
3
votes
2answers
53 views

Queue resizing array implementation

After learning about linked list implementations of a queue I was asked to try a resizing array implementation. I'm looking for constructive criticism. ...
1
vote
1answer
51 views

Create new array by filter origin array

I'm getting an array and I needed to find a duplicate ID inside: ...
1
vote
2answers
96 views

Merge array of hashes, keeping duplicate values as arrays

I am working on a Ruby gem to pull data from the Wikidata API. The data is deeply nested, as it contains a lot of repetition. I have written a piece of Ruby (sans Rails) code that enables an array ...
1
vote
0answers
25 views

Directory listing in Node.JS

This solution works, and I like having all the logic after the return. The main purpose of this function was for use with other functions to return a file list: ...
3
votes
3answers
99 views

Find majority element in an array given constant external space

Given constant external space (yes no HashMap), how would you improve the following code (code-wise or complexity-wise with stress on the latter) to find the ...
0
votes
0answers
16 views

Converting from a madlib program using hashmaps to using 3 different arrays to hold the noun, verb, and adjectives

Using erb and Sinatra, I need to make an array of each variable that can be added in, [noun], [verb] and [adjective], allowing me to return the number of each there are and create the appropriate ...
3
votes
2answers
67 views

Duplicates in array elements and sorting

I've been given this little test exercise for an interview as php developer, and I'd like to hear from you if my solution is good (enough) or if the problem could have been solved in a better way. ...
9
votes
2answers
109 views

Min sub array size with a given sum

How can the time complexity of the following code be improved (assuming it's \$O(N^2)\$)? What about style and patterns? This code is trying to find the minimum subarray size that adds up to given sum ...
4
votes
1answer
57 views

Allocating a contiguous block of memory for an array

I try to work with a contiguous block of memory, to create an array (2D) whose SIZE is not known at compile time (before c99) so no variable-length arrays are involved here. I came up with the ...
1
vote
1answer
11 views

JavaScript 2D Grid Wrapper

I have written a simple wrapper for a 2D grid in JavaScript that allows me to resize the grid dynamically and I'd like to know if there's any way I can improve on my code. Here is the code itself: <...
5
votes
2answers
51 views

Processing a sequence of additions and deletions

I am working on a program which manages a list, and must be able to insert new items, and delete ranges of items. I want the user to be able to specify the insertions and deletions in terms of the ...
3
votes
1answer
42 views

Serialize and deserialize n dimensional int array

I've made two symmetric methods which serialize an int array of any number of dimensions into an OutputStream, and read such an array from an InputStream. I was wondering if there is ways this code ...
0
votes
1answer
32 views

Condense JSON for bandwidth efficiency

JSON is quickly becoming the formatting standard of choice for quick, convenient, and reliable machine to machine communications. It is flexible and widely supported but it has some drawbacks when it ...
9
votes
11answers
573 views

Rotate an array to the right by a given number of steps

Recently, I encountered this coding exercise on codility and the idea is A zero-indexed array A consisting of N integers is given. Rotation of the array means that each element is shifted right by ...
5
votes
1answer
66 views

Replacing multiple substrings in a string

Here are 2 functions defined that do the exactly same thing: take input a template (in which one wants to replace some substrings) and array of strings values (key value pair to replace, such as [...
2
votes
2answers
103 views

Simple TicTacToe game in C++

I just started learning C++, and this is one of my projects. It's just a simple 2-player (No AI) TicTacToe game that runs from the console. The project was to familiarize myself with arrays, so review ...
5
votes
2answers
84 views

Alternately taking elements from an array

Given the task of having to return an array that alternately takes elements from two arrays, what would be most Ruby way of completing the task? As of now, I have this code, but it doesn't feel very ...
0
votes
2answers
43 views

Finding the length of the longest streak of ones in any array

I need help reviewing my code snippet copied below. The below code counts the number of continuous ones in a given array of Size 11. ...
6
votes
2answers
88 views

Populating an array with times with half hour interval between them

So for example, getTimes("12:00", "15:30"); should return: ["12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30"] The input parameters are always ...
4
votes
1answer
109 views
3
votes
2answers
73 views

Using Array to store calculations in VBA

I have the following VBA code, which works perfectly well to calculate "q" However, the code is very slow and that is due to the large number of q's being calculated (roughly 7.2m q's are being ...
3
votes
1answer
81 views

Dynamic multidimensional arrays

My application needs Field objects, which encapsulate 1D, 2D or 3D gridded data. The number of dimensions and their size are known only at run time. Furthermore, I ...
0
votes
1answer
33 views

Counting distinct lists in a list

I'm trying to remove the duplicate from the list and count the list after removing the duplicates ...
3
votes
2answers
62 views

Assigning entire column of data to specific column of an array in VBA

The below code I have written is to allow me to Sum the results data for every year from 1 to 1000 over a range of 5000 locations. although a 1000 years seems extreme, for the application I am using ...
1
vote
1answer
41 views

Concat strings from Object or Array

How would you merge these two functions into a single more generic function? ...
0
votes
0answers
25 views

Prefetch in ARMv7

I have to implement Khatri Rao product between 2 matrices in C. Mathematically this is a column major access of data and I can not change that. But if I use preload ( PLD instruction in ARMv7 ) to ...