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

3
votes
2answers
6 views

If zero found in Matrix. make entire row & column zero

Problem is - If in an MxN matrix, a zero is encountered, the entire row and entire column should be set to zero. Example - 8 4 2 2 3 7 1 0 1 9 8 4 ...
0
votes
0answers
17 views

Re-Ordering the draw order for my entities in my Isometric game

Introduction I am making a 3D Isometric game. I have a Tower, filled with Block's in a 3D ...
7
votes
3answers
125 views

Simplified Implementation of vector in C++

I implemented a simplified version of a C++ vector/ArrayList learning from this link. From it, I tried to write an ArrayList class rather than a Vector. In my ArrayList implementation, I didn't add ...
1
vote
3answers
320 views

Combine neighboring parts of an array based on a condition

I have written this code which takes a one dimensional array, for example: {"abc","ade","sss","fgw","asd","lka","o"} and turns it into an array of arrays, ...
3
votes
1answer
52 views

3Sum implementation

I have recently started to work through the problems on Leetcode, for the sake of bettering my own skills as well as preparing for interviews. I was faced with the 3Sum problem which is: Given an ...
2
votes
1answer
50 views

Partial ArrayList implementation in C++

I've implemented a C++ version of Java ArrayList. It doesn't contain all the functionalities such as AddAll and iterators and such, but I still would appreciate criticism to my code correctness, style ...
1
vote
1answer
110 views

Function to find a substring within a string [on hold]

I've just completed an exercise in which I had to create a program that searches for a string within another bigger string. If the substring exists then it is outputted to confirm and the starting ...
2
votes
2answers
37 views

Filtering array by list of keys in PHP 5.5

I have an associative array with data (let's say language codes and descriptions) and a second array with allowed keys (lang codes). I want to filter the data array by these allowed keys. The ...
0
votes
0answers
17 views

Queue Implementation Java [on hold]

I have to implement a waiting room management system in an emergency ward of a hospital.This is done using queue.I am entering names of the patients..and an ID will be given to them randomly..lets say ...
0
votes
0answers
29 views

HackerEarth Prateek and his Friends non-contiguous

How to solve this problem for non-contiguous range? Prateek wants to give a party to his N friends on his birthday, where each friend is numbered from 1 to N. His friends are asking for a gift to ...
1
vote
1answer
241 views

Finding a max element in an array in Java

Created the following method: ...
3
votes
4answers
72 views

Unit testing for concatenating two int arrays

Using Java 1.8, I created the following implementation to concat two int arrays: ...
0
votes
1answer
31 views

Code to join filesystem path strings in PHP

Following code has some issues: ...
2
votes
2answers
82 views

Implementing a Sort for an Array

Yesterday, I gave an interview after a long time, and I was asked a question which I couldn't solve on the spot. I had to implement a sort function for a Array of strings in JavaScript, with the ...
10
votes
7answers
1k views

Generate random binary arrays

I am fairly new to C++ programming and I, so far, love it. I just have been trying to make sure what I am doing is fast, unique, readable, and efficient. Is there anyway I can improve this code, or is ...
1
vote
1answer
41 views

Finding unique items in the array

I was reading this code where author claims that its the fastest implementation which I doubt, hence I decided to write my version of the same problem. ...
0
votes
1answer
64 views

Removing a specific character and its neighbors from a string

Assume we have an string that contains the character 'c'. This character can be located anywhere within the string. The exercise ...
2
votes
1answer
62 views

Algorithm for two languages that merges and sorts two arrays without mutating one

This algorithm, which I have included its flowchart as well, takes an array of A[n], which is unsorted and unmutatable and an array of ...
5
votes
3answers
55 views

CopyOf2DArray (Values Only)

Purpose: Given a 2-Dimensional Array, return a copy of the Array. In VBA, if I just Set newArray = oldArray then newArray is ...
6
votes
1answer
131 views

`Piece` class as part of implementation for the Tetris game

Here is my Piece class as part of implementation for the Tetris game. Critics of any kind and levels are very welcomed. If possible, I want my code to face the ...
3
votes
0answers
22 views

Create archive webpage for newsletters based on nested array

I am creating a webpage for my newsletter archives. The archives are divided by year (currently there is only 1, but there could be many), then by topic, before listing each newsletter. There will ...
2
votes
2answers
110 views

Reverse string in JavaScript without using reverse()

I have to reverse a string in JavaScript and cannot use the built in reverse() function. It does not seem efficient to have to create two arrays but is there a ...
4
votes
2answers
96 views

Find maximum value of Point represented by an Array of values for each coordinate

Suppose there is an array A = {3,2,5}, then points for this array correspond to indexes (i,j) where ...
7
votes
2answers
339 views

Validate whether a ransom note can be made from a dictionary of words

For simplicity, it is checking whether the characters in a string (that needs to be created) are present in a larger string (dictionary). Would a character array of the letters make sense here, or ...
2
votes
1answer
32 views

Converting values to Dates in column

I'm not happy about my code, but is the better way that I find, I'm not happy because I see that there are many code repetitions and when any change is easy to make mistakes. Do you think you can do ...
3
votes
1answer
134 views

A small generic array in C

The generic arrays in C I found on the net used either of these methods: The preprocesser with #define and #include (a lot of ...
4
votes
3answers
98 views

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

Input: Array of sorted integers and an element to check the frequency for Output: Frequency of the element ...
1
vote
5answers
92 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 ...
2
votes
2answers
70 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
5answers
280 views

A custom String Builder implementation

Two code files below : the actual logic & the test logic. Core Logic ...
3
votes
3answers
89 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
65 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
765 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
15 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
169 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
58 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
94 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
71 views

Finding consecutive occurrences of a value in an array

Given an array, return True if the array contains consecutive values: ...
0
votes
1answer
25 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
2answers
152 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
137 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 ...
3
votes
1answer
38 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
99 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
117 views

Longest palindrome in an array

I am new to programming, and think this code could be improved upon. Any suggestions? ...
2
votes
2answers
70 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 ...
4
votes
1answer
35 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
59 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
269 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
58 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
52 views

Create new array by filter origin array

I'm getting an array and I needed to find a duplicate ID inside: ...