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

1
vote
0answers
17 views

JavaScript Python Arrays

Here is an implementation in JavaScript that attempts to resemble Python-like arrays by mimicking slice comprehension for both getters and setters, as well as negative indexing from the end of the ...
-3
votes
0answers
16 views

PHP - Combine two arrays to get an output [on hold]

Currently I want to output a data from a database. I have two separate arrays. May I know is there a way to combine those arrays. The code is as below, ...
-1
votes
1answer
23 views

Case statement with array includes?

What is the best practice to implement case checks using arrays in Ruby? ...
2
votes
2answers
36 views

Group array by sums

I have the following code that takes an array, and groups it by the sums of its elements: ...
-1
votes
0answers
26 views

Method that produces a staircase [on hold]

I was tasked with writing a method that would produce a staircase like so: I managed to do this using a 2D array but was thinking of ways I could improve the runtime of my code and or other ...
-1
votes
0answers
25 views

Split a row into multiple cells and keep the maximum value of second value for each gene [on hold]

I am new to Python and I prepared a script that will modify the following csv file https://drive.google.com/open?id=0B2ynoLlCACXzSElFZ2poNllmVjg accordingly: 1) Each row that contains multiple Gene ...
1
vote
2answers
35 views

From an given array of numbers remove duplicate values

I was asked an question for writing a program where the input will be array of numbers; the output of the program will be array of numbers without duplicates. I coded in javaScript which runs on ...
0
votes
0answers
11 views

Taking input from DB using isel function and assigning them to different var to use them but because there is a pattern so i think,It could be shorten

Here is my code, observe what I'm trying is, to shorten this code, but due to the slight difference in name of the variables, I'm stuck. Though the pattern is same. Please help me out. ...
4
votes
3answers
121 views

My Binary Search Implementation

I have implemented binary search in JavaScript. I run it on node. I pass an comma separated string of numbers in ascending order as first argument and the number to be searched in the second ...
-1
votes
0answers
47 views

Reading file contents into an array [closed]

The purpose of the program is to store values in array from a file salesData.txt which contains the values as shown below. The program should stop at the sentinel ...
2
votes
2answers
49 views

TapeEquilibrium Java Implementation

A non-empty zero-indexed array A consisting of N integers is given. Array A represents ...
-1
votes
0answers
16 views

Find pairs in an array such that a%b = k , where k is a given integer [closed]

I have gone through an almost similar topic in Stackoverflow and after having tried to understand the solution (Find pairs in an array such that a%b = k , where k is a given integer). I have tried my ...
5
votes
1answer
50 views

Counting the number of unique fractions read from a text file

I will begin this question with the disclaimer that it is homework but my code is written and working, I just want to know if there any ways in which I can improve what I already have. I want my ...
0
votes
0answers
34 views

Smallest difference of pair in String-array

Let's say I have the following array of Strings: String[] rows = new String[]{ "", "A", "B C C", "", "B D E", "E F G H" }; As well as the following ...
4
votes
0answers
68 views

Find the number of ways to partition the array

Find the number of ways to partition the array I want number of ways to divide an array of positive integers such that maximum value of left part of array is greater than or equal to the maximum ...
0
votes
1answer
36 views

Foreach vs Iterator [closed]

I have implemented a trim method which removes objects having empty properties. This list has average size of 3 or so. Probably, the max length is 7 or 8. I ...
4
votes
1answer
88 views

Abelian sandpile

I am trying to programm the Abelian sandpile model in VisualBasic. Also, here is a youtube video made by Numberphile about the very same topic. Here is a picture (\$2^{20}\$ grains of sand) I made ...
1
vote
1answer
48 views

Iterating 2D array in Swift

I have a situation where I needed to convert NSNumber 2D array to Float 2D array, so I did it like this: ...
3
votes
4answers
224 views

Merge two sorted arrays in NASM

I have the following function which I wrote in NASM to merge two sorted arrays. Its not a standalone, but its supposed to be compiled into a .o file and then linked ...
4
votes
1answer
53 views

Repeated comparison of sorted subarrays

This question is from a recently concluded competition on Codechef. You are given an array A of size n, and there are ...
1
vote
1answer
47 views

PHP subset of 2 arrays containing objects - compared only by 1 attribute

I'm looking for a fast way to get the subset of 2 arrays containing the same kind of objects using PHP functions. I'm looking for the red part: ...
1
vote
1answer
30 views

Extract list of selected contractors by matching serialized array in Rails

I'm working on an application where I have a Company model setup as follows: ...
2
votes
2answers
45 views

Multiply a 2D array by 1D array to get a third (2D) array

I've working with three dynamic arrays (all are datatype Double) - they are OriningalArray This will be assigned from a range that the end user will see and ...
2
votes
1answer
41 views

Create two arrays duplicate code

I wrote two functions that creates two 2 dimensional arrays, but there is a lot of duplicate code and I don't know how to split it in one function. Is it even possible? I know the rule don't repeat ...
3
votes
2answers
73 views

Segregate an array of 0s and 1s

I think that my code contains a lot of if and else statements that are probably not required.I suppose that this code could be condensed to a shorter form where the logic applied would look clearer ...
5
votes
1answer
66 views

Find balanced array

An array is called balanced if its even numbered elements (a[0], a[2], etc.) are even and its odd numbered elements (a[1], a[3], etc.) are odd. Write a function named isBalanced that accepts an ...
1
vote
2answers
63 views

Java Left Rotate Array upto n times

Java problem to left rotate an array upto n times. It would be nice if anyone can review this code. Task: A left rotation operation on an array of size shifts each of the array's elements unit to ...
6
votes
1answer
39 views

Average of three biggest parameters out of five without using sorting algorithm or vector/array

I'm trying to create a function with has 5 input parameters and returns the average of the 3 biggest. However I'm not supposed to use a sorting algorithm, vector/arrays or function libraries and still ...
2
votes
2answers
61 views

Move one element before another in an associated array

I have this task where I have an associated array in PHP and I want to manipulate the order of entries. Basically I want to be able to move entry Y before entry X. So basically if I have the ...
3
votes
3answers
67 views

java 2d Array HourGlass Problem from hackerrank

This is a java solution to one of hackerrank problem given in below link. https://www.hackerrank.com/challenges/2d-array I know it's not optimized, can anyone help me to refactor and optimize? ...
10
votes
3answers
925 views

Program that asks the user to modify their contacts list names and encapsulation

I coded a simple program that asks the user to add/delete/modify/print/etc. their contact list names. Now, I had learned a little about encapsulation. However, I still could not figure out which ...
3
votes
3answers
117 views

Sorting integers in descending order

So, I coded a program which asks you the number of integers and the integers the user wants to sort in descending order. The program works but I feel like it is very inefficient. If I were to receive ...
3
votes
1answer
44 views

How to sort array by divisor sum faster?

I am sorting an array by divisor sum in ascending order. If two or more numbers have the same sum of divisors they have to be sorted in ascending order. The problem I have is that my version is not ...
11
votes
2answers
1k views

Bit array implementation

I have made a bit array implementation that can be seen below: ...
0
votes
2answers
63 views

Linked List Stack

I have no trouble with my code on working part but I still have some worries if there is something missing so I want a review for my code. Also, I wonder if the exceptions are true type for these ...
3
votes
1answer
88 views

C++ sum and averaging functions for arrays and argument sets

Here are two sets of variadic C++ functions to do fast summing and averaging of arrays (plain & std::array) or argument sets, (re)written as part of my generic ...
1
vote
1answer
42 views

Asynchronous task on every element of an array

Here is some synchronous code: ...
3
votes
2answers
121 views

A Concise Quick Sort

This is an implementation of Quick Sort in JS. Can this implantation of Quick Sort be more concise and efficient while still remaining expressive? ...
5
votes
1answer
46 views

Merging List Arrays

Some utility functions I re-wrote today: Purpose: Given an arbitrary list of 1-D arrays (possibly empty variables), return a 1-D array containing unique values from all lists. Ex: Given (1,...
9
votes
2answers
589 views

C++ Bit shift whole array (left)

For an embedded project I want to shift a (byte) array left by a certain amount of bits. I've built this template function to do so: ...
4
votes
1answer
160 views

Bidimensional array trimming extensions

After stumbling upon this question on StackOverflow, I started playing with some extension methods to trim null objects from a bi-dimensional array. This is what I'...
2
votes
2answers
84 views

Calculating the perimeter of certain points in a 2D array

I had to write code for a competition which calculates sum of the perimeter of two non-overlapping rectangles in a 2D space. My code is working fine and resulting in expected outputs. But it is taking ...
1
vote
2answers
76 views

Finding the predominant number in an array

My program has to read an array and say whether there is a predominant number or not in the array. A predominant number is the one with frequency bigger than number of elements of the array divided by ...
-2
votes
2answers
70 views

An array adding numbers to a specified sequence

I have to make a program that modifies an array like this: it takes a sequence in an array and sums up a number to each element in the sequence and repeats this many times. The array's elements are <...
0
votes
1answer
78 views

Query an array at intervals and getting the highest number of values

I feel like I am doing a lot of unnecessary operations and some places I feel like I am being redundant in some places. I am focused on performance and optimization. I am trying to find the five ...
-1
votes
1answer
67 views

Detecting arrays with enough entries in common [closed]

I have made a function called testing. This function tests whether five numbers from each sub-array of $source are included in <...
1
vote
0answers
33 views

VLookup simulation: copying data from one sheet to another

I tried to write a VLOOKUP in my macro but for some unknown reasons it didn't work (see my post on StackOverFlow for more info. So I decided to do a macro which achieves the same result, but it takes ...
7
votes
2answers
94 views

Append blank value(s) to missing fields in a CSV line

I have a small app that takes in CSV files. It reads the CSV file and before it inserts a line into the DB it checks certain conditions on the line. Now, let's say the length of the line should be 5. ...
4
votes
1answer
88 views

Finding the middle permutation

This method finds all permutations of a string and stores them in a sorted array. It then returns the element in the middle of the array. ...
0
votes
2answers
49 views

Filter array elements using variable number of filters

This is a question generated from a coding challenge, and I solved it, but I'm just not sure it's a great solution, nor am I sure why the first way I was trying didn't work. Challenge: Implement a ...