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

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

I have the following input array: ...
5
votes
4answers
104 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
22 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
42 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
35 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. ...
2
votes
2answers
56 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 ...
-3
votes
0answers
59 views

Speeding up code (beginner) [closed]

So I've written some code that I'm sure can be done quicker and more effectively on my micro, but I just can't my head around it. (using TM4C1294xl in CCS) I have an interrupt which I want to read the ...
0
votes
0answers
13 views

Iterating through JS Array + Array Properties [closed]

I' a bit of a novice I was hoping someone could point out what I am doing wrong. The idea is for searchArray to loop through array values &properties. It takes the arguments (property, value). ...
5
votes
1answer
67 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
37 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 ...
5
votes
0answers
61 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
76 views

Custom Dynamic Array

Pretty simple class but just want to make sure I've approached it correctly. ...
3
votes
1answer
63 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
66 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
84 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
84 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 ...
-1
votes
0answers
31 views

Dynamic boostrap dashboard

I am creating dynamic dashboard, where each column of row will be considered a screen. The system picks various screens as an array that is formatted as follows: ...
4
votes
3answers
236 views

Find median of two sorted arrays

Problem statement There are two sorted arrays nums1 and nums2 of size m and ...
2
votes
2answers
114 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
53 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 ...
-1
votes
1answer
36 views

merging json object

Hi I am trying to merging json objects which has common value. This is original JSON ...
1
vote
4answers
85 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
72 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
42 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
69 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
20 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
98 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
43 views

Nested loop to transform MongoDB results

I have the following structure returned from MongoDB: ...
5
votes
4answers
792 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 ...
1
vote
2answers
95 views

Fixed-length Stack in Java

I implemented a fixed-length stack in Java for use in my fractal generator program, an RPN calculator and my esolang interpreter. This is a generic stack, and goes over and above the call of duty in ...
0
votes
1answer
53 views

A Java subclass of ArrayList that supports rotation in constant time - follow-up

(See the previous (and initial) iteration.) Compared to the previous iteration, I have added more methods that maintain the invariant required for constant time rotations, such as bulk add/remove, ...
6
votes
2answers
109 views

Weaving an array

In preparing this answer, one of the components was an algorithm to rearrange a sorted array in a particular way. To put it succinctly, here's the problem description: Given an array \$A\$ with ...
4
votes
1answer
50 views

Project Euler #127 abc-hits

Problem (Rephrased from here): The radical of \$n\$, \$rad(n)\$, is the product of distinct prime factors of \$n\$. For example, \$504 = 2^3 × 3^2 × 7\$, so \$rad(504) = 2 × 3 × 7 = 42\$. ...
7
votes
3answers
332 views

A Java subclass of ArrayList that supports rotation in constant time

(See the next iteration.) I have subclassed java.util.ArrayList in order to be able to "rotate" it in constant time simply by moving a finger index. See what I ...
0
votes
3answers
67 views

Minimum element in a sorted rotated array

A sorted array [0,1,2,3,4,5] when rotated n times (3 times in this case) becomes [3,4,5,0,1,2], meaning elements in the front move to the end. The code below finds the minimum element in this array, ...
5
votes
5answers
217 views

Removing duplicates in an array

Problem: Remove duplicates from a given array of integers. I want this method to work without using data sets except an array. My code is currently \$O(n^2 + n) = O(n^2)\$. How do I shorten this? My ...
2
votes
1answer
71 views

Object-to-array flattening function

I have written a function that is designed to convert an object into an array of key/pair values ("flattening it") like so: Input ...
5
votes
1answer
362 views

Anagram finder in F#

I've been learning F# for a month or so and I'm wondering how good my "functional" aspect of coding is. When I first started, I did this using an iterative approach with a lot of <- and mutables ...
3
votes
1answer
113 views

Initialize and sum an array in Java using threads

This bit of code initializes an array of any given size where each index corresponds to a thread and a value. That is, index 0 has 0, index 1 has 1, and so on. Then, the values, 0 to n, in the indexes ...
4
votes
2answers
65 views

Counting numbers whose digits all go up or down

I have created a program which takes a value x and uses this value to create a power of ten value like so 10 ** x. This has ...
0
votes
2answers
44 views

Partitioning an array of objects into four arrays by one attribute

I have an array of API objects, below is an example of one object: ...
0
votes
2answers
55 views

PHP alternative syntax confusion

Newbie to PHP. Trying to output the results of an array inside a foreach loop. I have got the following code but I cannot understand what to do with it next. Mainly; Where/how do I start and end ...
2
votes
1answer
20 views

Printing the minuend and subtrahend in a Minimum Difference algorithm

I have a Minimum Difference algorithm, and I wanted to expand on it by printing the actual elements that were subtracted. I'm just wanting to know if this is the best way to do it. ...
1
vote
1answer
98 views

NDArrays in C: slicing/transposing/polynomials

This is the primary module for my APL interpreter. The general idea is motivated by my two Stack Overflow questions, but the details I fear are easy to get wrong and I suspect there are a few corners ...
2
votes
1answer
82 views

Poker app in C#

I am developing a poker application using C#. It is almost done, and I'm looking for improvements. One of the things I wonder is whether I should change my method that checks if the player has a ...
2
votes
2answers
105 views
2
votes
2answers
58 views

Extract higher value of pair from JavaScript array

Say we have these data: ...