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
1answer
6 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
43 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
32 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
22 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 ...
5
votes
10answers
386 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 ...
4
votes
1answer
47 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
84 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 ...
4
votes
2answers
72 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
37 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
67 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
80 views
3
votes
2answers
57 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 ...
2
votes
1answer
63 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
53 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
40 views

Concat strings from Object or Array

How would you merge these two functions into a single more generic function? ...
0
votes
0answers
23 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 ...
6
votes
1answer
27 views

When values are pasted into a bigger range, the values should be repeated as needed to fill the range

I am currently working on a project, and I just wrote a piece of it that requires a lot of array manipulation. Given a text input I want to expand it to fill the number of rows and columns I have. I ...
3
votes
1answer
37 views

Slicing a big NumPy array

I have a function that takes a four-dimensional NumPy array M and, for each value i of its second index, takes all of M without the i-th "column", evaluates the product over all other columns, and ...
0
votes
2answers
58 views

Effective Python 2/3 two-dimensional array initialisation

Recently I noticed that the idiomatic python two-dimensional array initialisation is extremely slow. I am wondering, is there a good, proper way of doing this simple task fast? Also, are those two ...
1
vote
1answer
44 views

Expanding pixels in an image

Custom class Image takes a 2-D array of 0's and 1's upon initialization. Method transform returns a modified array by modifying 0's adjacent to a 1, such that ...
1
vote
2answers
31 views

Sorting and slicing array, based on another “weight” array?

I have the following input array: ...
5
votes
4answers
125 views

Finding the longest sequence of positive numbers in integer array

I am preparing for a coding interview and I have the following questions: Find the biggest positive number sequence in the Integer Array. If Input is ...
1
vote
1answer
26 views

Python list “commander” (modify a list with user commands)

I made a program that can modify a list using commands that the user enters. The commands that are supported are (used from actual program): ...
2
votes
1answer
45 views

Find the contiguous subarray within an array (containing at least one number) which has the largest sum

Interview Q: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example: Given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray ...
5
votes
1answer
39 views

Three stacks in a single array

I have implemented three stacks in a single array in Java. Any advice on object oriented design, coding structure, logical part or any sort of advice would be appreciated. ...
3
votes
3answers
147 views

Building prefix tree from dictionary, performance issues

I'm trying to build a prfix tree. So, using the following dictionary 'and','anna','ape','apple', graph should look like this: I've tried 2 approaches: using ...
5
votes
1answer
73 views

Computing the total different between a pixel and its neighborhood

I have C++ code which written for mex in MATLAB. It used to compute the total different between a pixel and its neighborhood (8 neighborhood in my code). The code ran and gave me an expected result. ...
2
votes
1answer
43 views

LeetCode Rotate Array

I have started learning Java and was trying to solve some easy problems from different websites like HackerRank and leetcode.I am relatively new to programming so please don't mind if this is too ...
8
votes
1answer
103 views

Simple Conway's Game of Life implementation in Java

I wrote a simple implementation of Conway's Game of Life in Java using 2 arrays and for loop and used StdDraw library for plotting generations. It turned out that ...
0
votes
1answer
34 views

Change non-diagonal surrounding elements in a 2-D array

I'm a beginner working through an exercise on ruby arrays. Given a two-dimensional array with 0's and/or 1's, it should return an array with the non-diagonal surrounding elements of 1 changed to 1 if ...
0
votes
1answer
83 views

Custom Dynamic Array

Pretty simple class but just want to make sure I've approached it correctly. ...
3
votes
1answer
71 views

Generic variable-size array

As stated in the tags, I'm a beginner to C. This code implements a dynamic array (List in .NET, vector in C++, etc) for any ...
-3
votes
1answer
69 views

Nim Game with Arrays [closed]

I am suppose was to incorporate arrays in my NIM game java code, so that we can allow the user to decide on how many heaps are in play. I am stuck and have no clue how to do so. Heap Class ...
0
votes
2answers
46 views

Create an array with at least a given number of bits

I use this declaration for an array which must contain a bit for every minute in a day: ...
3
votes
0answers
105 views

Google CodeJam 2016 - Ruby - Counting Sheep

https://code.google.com/codejam/contest/6254486/dashboard#s=p0&a=0 I just wrote a small Ruby class to solve the first of the challenges in the G CodeJam. I am not strong at this sort thing so ...
-2
votes
1answer
99 views

3 exams, 20 students: calculating the per-student average score [closed]

I'm a little curious... I have to work on a program in which a student takes 3 exams and the average is taken from the 3 exams that a student takes. It then goes into a form of a table, where one ...
4
votes
3answers
271 views

Find median of two sorted arrays

Problem statement There are two sorted arrays nums1 and nums2 of size m and ...
2
votes
2answers
124 views

Algorithm to rotate array elements in Ruby

I wrote this algorithm to rotate elements in an array. It's not very efficient, but it works. It has another disadvantage that it doesn't rotate right (it would be nice to pass it negative steps, for ...
0
votes
1answer
58 views

Shuffle array without duplicates

I made a function about random backgrounds And those images will unique as possible. (Shuffle again after all gone) My steps is : Setup the array Shuffle it Do function (check if ...
0
votes
1answer
44 views

Merging JSON objects with common values

I am trying to merge JSON objects which have common values. This is the original JSON: ...
1
vote
4answers
103 views

Diff Two Arrays - return the symmetric difference of the two arrays

This is my challenge using JavaScript -> Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric ...
2
votes
1answer
85 views

Quiz program in Java

I have made this small quiz with 10 question and 40 JRadioButtons. One question and 4 JRadionButtons for each panel. So I had to ...
0
votes
0answers
51 views

AVL Tree Array Representation

In a school assignment I'm supposed to create a program simulate insertion, deletion, count nodes, and delete tree algorithm and displays the traversal, level order, and array representation of it. ...
2
votes
2answers
71 views

sum, range and rangeSum functions

Forgive me if this is too simple, but I'm a beginner trying to learn and understand. I came across an exercise to create these three basic functions, and this is what I came up with. Any glaring ...
0
votes
0answers
21 views

Filter option for PFQueryTableViewController in Swift

I have a PFQueryTableViewController, and have create a separate TableViewController that allows me to select a filter option. When the user selects an option to ...
5
votes
1answer
107 views

C# Sorting array without using the bubble sort

I'm a beginner and like to experiment new things so today I tried to implement sorting method for an array without using any Sort and the actual challenge was to do ...
1
vote
1answer
46 views

Nested loop to transform MongoDB results

I have the following structure returned from MongoDB: ...
5
votes
4answers
799 views

Find all instances of element in array

I've created a function to return all the indices where an element is to be found in an array. If it occurs twice or more, all the respective indices will be returned, for now it returns them in ...