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

8
votes
1answer
48 views

Calculating and displaying score statistics using C# 6.0 features

I'm studying C# and trying to work on efficiency and making the best use of C# 6.0 features. I have created the following program based on an exercise challenge in a book, and have used Resharper to ...
2
votes
1answer
30 views

Looping through nested arrays with creating new array from nested items

I have written this function but I am not so proud on it. I could use some help refactoring it. Would recursion improve my code? Data sample. ...
2
votes
1answer
20 views

Menu driven program to represent polynomials as a data structure using arrays

Write a menu-driven program to represent Polynomials as a data structure using arrays and write functions to add, subtract and multiply two polynomials; multiply a polynomial with a constant, ...
5
votes
2answers
283 views

C++ Array with iterators

I wrote an Array class with iterators: ...
2
votes
1answer
22 views

Create an array of categories from comma-seperated text input

This code works just fine, but could obviously be more elegantly written. The basic idea is to create an array of categories from a text input. The code splits up the text input by commas to create ...
3
votes
1answer
40 views

Transforming an array of arrays into an array with joins

I'm transforming this: ...
0
votes
0answers
41 views

Adding multiple elements to list in dictionary [on hold]

So I made this method to set parameters from a text file: ...
5
votes
2answers
173 views

String to Array formatting

Trying to convert, from this formatted string $filtersStr = "id:1||name:alex"; to: ['id' => 1,'name' => 'alex'] My ...
4
votes
2answers
74 views

Palin Pairs (Pallindrome Counting) Code

In an array of strings 'a' having 'n' strings i have to select the Palin Pairs from the given strings .for ex for input 3 bba abb abb Output=2 I am getting correct output but want to reduce time ...
-1
votes
0answers
7 views

Swift Type vs explicitly unwrapped Type [migrated]

I just wanted to use the .map closure in Swift and stumbled upon this: ...
7
votes
1answer
58 views

Print array of sentences vertically

Suppose I have an array of sentences: [ "How To Format", "put returns between paragraphs", "for linebreak add 2 spaces at end" ] I want to print it like this: ...
1
vote
2answers
86 views

Finding number of number pairs with given difference [closed]

pairs() is a function which returns the total number of combinations whose difference is k. ...
8
votes
1answer
77 views

Multithreading readied Median Filtering

So I've been confronted with a rather simple problem in the Java chat on Stack Overflow. It's about doing a median filter with a sliding reference window. For the purpose of the task we can assume ...
1
vote
3answers
97 views

Count specific array values

I want to count specific strings from array values $array = array("report=D","report=D","report=D","report=I","report=I"); I am going to count the number of ...
2
votes
2answers
86 views

Load text file into an array in Swift

I'm drowning in Swift optionals and error handling syntax. I'm just converting a text file into an array of Strings. One would think that this could be a simple two or three liner but by the time I ...
3
votes
1answer
40 views

Implement selection from array by 'random' or 'if/elif conditionals'

I'm working on some code examples in 'Automate the boring stuff in python...' to prepare for my first year of CS. I want to know if its better to use an array with random selection below or rather ...
2
votes
2answers
87 views

IntArray implementation [closed]

I need to write an IntArray implementation for college. I'm wondering if my code could be better and if it is efficient. In the header file are the methods listed ...
6
votes
1answer
87 views

Finding the count of negative sub-arrays for a given array

I want to improve my implementation for the following problem: You are given an array of n integers. A sub-array is "Negative" if sum of all the integers in ...
4
votes
3answers
36 views

Max contiguous slice in Ruby

I need to compute the max contiguous slice in an array. I wrote this function, but I am not sure if it is correct or I am missing edge cases. I ran several cases. ...
1
vote
2answers
45 views

Comparing two almost exact arrays

I have two arrays: $row $rowTwo The only difference between these two arrays are the first two keys have slightly different ...
5
votes
3answers
624 views

Function that adds two integer strings

I wrote this method that adds two integers in the form of strings together. This way I can add large integers without overflowing. How efficient is the code that I wrote? I am by no means a great ...
1
vote
2answers
47 views

Library class Project

I am creating a class project which involves two classes: Library and Book. I would like a general review on the code. ...
2
votes
1answer
31 views

Kadane's Algorithm Variant (Start Index and End Index with Sub Array returned even for all negative numbers)

Here is an attempt to extend the Kadane's Algorithm to return the sub array itself instead of the sum of maximum sub array. This must work irrespective of the original array having all positive or ...
0
votes
1answer
92 views

Refactor C# unsafe method [closed]

I have the following two unsafe methods that I would like to refactor: ...
3
votes
1answer
26 views

Container supporting PeekMax, PeekMin, Sum, and PeekNextToMax v2.0

This is another part of the update to this question. The interfaces are in this question. To summarize, the class is a generic container similar to MaxHeap, but only needs to support the following ...
4
votes
4answers
156 views

Find the locally biggest or equal values including corners in an array

I am looking for a function, that will find in array of n integers highest or equal locally values including corners. My code is probably wrong, and I somehow think solution is in some library like ...
2
votes
1answer
56 views

Array of complex numbers

A class Array which contains two data members: a pointer on array of complex numbers and the length of the array. Implement a function for reading the array. The ...
2
votes
1answer
38 views

Multiple Google Maps using V3 API

I have several Google Maps on one page and each has its own set of Lat/Lng co-ordinates. As a result I have added in the JavaScript options for each one individually as follows: ...
4
votes
3answers
182 views

Free Code Camp - Pairwise

I'm working through the Free Code Camp syllabus and I'm on to Intermediate JavaScript Algorithms. This Pairwise problem was the last challenge in that section. The section came just after "Object ...
4
votes
1answer
48 views

Java 8 find array of countup sums

I have an array of some arbitrary int values; I want to find the array containing the sum of the past elements in the current index. Example: ...
7
votes
3answers
70 views

Checking whether an array contains all distinct values

This method returns true if any arrays element is equal to another element value, returns False otherwise. ...
3
votes
1answer
25 views

Adjusting Angular.js model based on browser width

I have an Array of 5 objects, some key values need to be changed based on the browser width. ie: 5 cols, 4 cols, 3 cols or 2. vs.streams is an Array which is tied to a AngularJS model. When the ...
1
vote
1answer
73 views

Populating an array from a database

I have a query that populates an array from the database. In some cases, this query returns a great amount of data, (let's say for purpose of an example, 100.000 records). Each row of the database has ...
2
votes
2answers
72 views

Heap's algorithm - integer permutation

Integer permutation using Heap's algorithm: ...
3
votes
3answers
195 views

Finding number of palindrome pairs in an array

I am trying to find the number of string pairs in an array that are palindromes. ...
2
votes
3answers
45 views

Transforming data from an array of objects to a nested array of objects

I have an array of objects where each object has a datetime key/value pair: ...
3
votes
3answers
111 views

Creating an array of objects for dictionaries

I wrote a piece of code that creates an array of objects based on the array of dictionaries. The problem is that my solution uses multiple loops imperatively. Let's consider the following case. There ...
5
votes
1answer
78 views

Generic multi dimension grid / array class in C++

I am writing a generic C++14 multi dimensional array for computational science purpose. The "features" so far for the class tries to: store multi-dimensional grid values into a flatten array ...
5
votes
3answers
104 views

Find first unique number from array

I was asked to create a function that return first UNIQUE integer from given array of integers. In a case of success the function return the unique number in a case of failure return -1. The ...
2
votes
1answer
51 views

Sorting an associative array alphabetically

I am using a foreach loop to sort an associative array alphabetically. I would like to know if there is a more proper and/or efficient way of doing it. The array: ...
2
votes
2answers
40 views

Saving array values for a secondary foreach loop

Although used within the WordPress platform, this is PHP focussed question. I have an array of child posts, some have content, some don't. My client wishes to display the posts in alphabetical order, ...
10
votes
5answers
423 views

Mode Calculator

I was doing a puzzle on Coderbyte, and here is what the puzzle stated: Have the function SimpleMode(arr) take the array of numbers stored in arr and return the ...
1
vote
2answers
122 views

Array with enumerated elements

Java program uses the following construction: (provided mainly for context) ...
1
vote
1answer
39 views

Scroll related inline image resizing

I have been working the some project and I'm struggling to find the answer. Right now I'm coding with Angular and there some code that makes me write twice. There only two arrays now but if I have ...
8
votes
5answers
242 views

RingQueue implementation using std::array

I've recently finished implementing a ring queue based on std::array in C++11. I tried to write the code as if I were going to submit it to the C++ Standard ...
11
votes
6answers
409 views

Find common elements in a list of arrays

I need to find the common elements present in all the given arrays. All the arrays are present in another array. I have come up with this solution and it's working. I tried to remove the usage of ...
0
votes
0answers
31 views

Slideshow by array using slice method

I made a slide show using array values, it works, but I strongly believe that the way I did is too long. There should be an easier or more compact way to achieve this. ...
6
votes
3answers
240 views

Sum pairs of numbers in array

This code takes a list of ints and sums their pairs, storing the summed pairs in an array sumPairs, then returning that array. If the supplied array ...
5
votes
2answers
89 views

Splitting string by words to new strings

Function: ...
10
votes
2answers
345 views

Removing duplicates from an unsorted Array

I have written this program to remove the duplicates from an unsorted array. Please review and give me your input on how I can improve it a little more. ...