Questions tagged [array]

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.

Filter by
Sorted by
Tagged with
2 votes
2 answers
41 views

Calculating the sum of all k-sized sub-arrays in an array using sliding window algorithm

I need to calculate the sum of all k-sized sub-arrays in an array using sliding window algorithm. Is that a valid sliding window algorithm? If not, why? ...
Alekam's user avatar
  • 21
0 votes
0 answers
52 views

How can I further optimize this code regarding array operations? [closed]

In the following code I am performing XOR operation on two arrays result and DB, result is accessed after an offset called rotate1 in following. As you can see I am already doing AVX2 and loop ...
CryptoKitty's user avatar
2 votes
2 answers
117 views

Counting duplicate elements in two sorted arrays

I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with: ...
Bryan C's user avatar
  • 21
2 votes
0 answers
34 views

Reusable storage for array of objects V4

Here is a thirdfollow up on Reusable storage for array of objects, Reusable storage for array of objects V2 and Reusable storage for array of objects V3, taking into account the provided answers. The ...
Oersted's user avatar
  • 299
1 vote
1 answer
45 views

Reusable storage for array of objects V3

Here is a second follow up on Reusable storage for array of objects and Reusable storage for array of objects V2, taking into account the provided answers. The following code should be compliant at ...
Oersted's user avatar
  • 299
3 votes
1 answer
48 views

Reusable storage for array of objects V2

Here is a follow up on Reusable storage for array of objects, taking into account the provided answers. The following code should be compliant at least with gcc, <...
Oersted's user avatar
  • 299
0 votes
0 answers
36 views

Finding the pivot point in a rotated array which has been shifted from kth element

I'm trying to solve the following problem: Joker has a deck of n cards, each with a value written on it. The cards are arranged in ascending order from top to bottom. Joker's master performs a hidden ...
driver's user avatar
  • 212
4 votes
2 answers
331 views

Reusable storage for array of objects

My goal is to have a memory pool non-template class that is used to store arrays of objects. The same memory pool object must be reusable for a different array (difference size, different type and/or ...
Oersted's user avatar
  • 299
1 vote
0 answers
43 views

Javascript basic search engine recipes

I have made a search engine for recipes. Requirements for this JS Project are as follow: Create a function called searchRecipes that takes all recipes and an ...
Yass's user avatar
  • 11
3 votes
3 answers
996 views

Small code exercise with 3D arrays in C

I wrote a small program that initializes a 3D array in C based on command-line arguments and prints it. I did my best to avoid undefined behavior and memory errors. I wrote comments as if I had an ...
schuelermine's user avatar
3 votes
2 answers
88 views

Quickselect algorithm implementation and its time-complexity

I wrote this code to find kth smallest element in the array by renowned algorithm quickselect. Here is the link where you can see the working code. What points are there to be improved? Could you ...
Soner from The Ottoman Empire's user avatar
1 vote
0 answers
68 views

Performant 2D Grid Cluster Finder Algorithm

I would like to vastly improve the speed of the second part of this algorithm to find clusters of points on a 2D grid. Each point is represented by a Region on the ...
ProgrammingTenants's user avatar
5 votes
4 answers
2k views

Automate the boring stuff with python - Character picture grid

Character Picture Grid Say you have a list of lists where each value in the inner lists is a one-character string, like this: ...
Jarne Vercruysse's user avatar
-2 votes
2 answers
176 views

Count the number of mismatches between two arrays [closed]

This function may compute the amount of unequal elements of two char-arrays of the length n: ...
HeapUnderStop's user avatar
2 votes
1 answer
86 views

Recursive Factorial Calculation in JavaScript

...
TAHER El Mehdi's user avatar
3 votes
1 answer
65 views

Dyalog APL dyadic operator deriving ambivalent function to pair two function results

I'm writing a small utility operator which applies two functions to an argument pair and strands the results. The pair can either be given as two arguments or as a single argument with two elements. ...
Adám's user avatar
  • 656
0 votes
1 answer
54 views

The Matrix Winds In

The Problem: Given an N by M Matrix, Create an Anti-Clockwise Traversal Path that winds in all the way into the Matrix Example: The Matrix is 9 by 5 Output: ...
Amal Krishnan's user avatar
3 votes
0 answers
41 views

extracting values from an array of nested objects without duplicates

I have my solution for the below usecase but I would like to know whether is any other effective solution for the same. My Data: ...
SM1312's user avatar
  • 131
4 votes
3 answers
425 views

Determine whether two arrays have the same elements with the same multiplicities

I have written a Python function called comp that checks whether two given arrays have the same elements, with the same multiplicities. The multiplicity of a member ...
TAHER El Mehdi's user avatar
0 votes
1 answer
43 views

Optimizing the Dig Pow function

I have written a Python function to solve the Dig Pow problem, where the goal is to find a number k such that the sum of each digit of n raised to a specific and ...
TAHER El Mehdi's user avatar
2 votes
2 answers
60 views

Given a sorted list of integers, find the highest count of elements between an indeterminate but fixed size range

I'm trying to optimize a function that takes a sorted list of integers and tells me what is the maximum number of elements in the list between any definite size range. To be clear, the range itself ...
Tyler Schuster's user avatar
5 votes
3 answers
753 views

Merge Sorted Array in Rust

I was solving this task https://leetcode.com/explore/learn/card/fun-with-arrays/525/inserting-items-into-an-array/3253/ The main idea is to merge two sorted arrays (more details in the site) Example: <...
mascai's user avatar
  • 375
1 vote
1 answer
119 views

swap two different length group of variable in array

The code below swaps two different-length groups of variables of the same array in the same array. Is there any other method to achieve this that is less heavy or less redundant? ...
Ill Magnus's user avatar
5 votes
2 answers
119 views

concatenate values and delete the remaining rows using arrays

the below code used to: Concatenate the values on a specific column "N" depend on the value of column "A" then delete the remaining rows. It works, but with range of 30k rows the ...
Leedo's user avatar
  • 275
0 votes
1 answer
28 views

Mangle words to bytearray of lo/hibytes

I would like to refactor the following code snippet adapted from a project I'm involved. It is part of a code to control power outlets via network. The code snippet was written by myself based on the ...
Looser User's user avatar
4 votes
3 answers
2k views

Custom array class in C++

I wrote a custom array class in C++ to suit my personal use case. The main important rule in this project is that no unassigned element is allowed between 2 assigned elements; please review for ...
machine_1's user avatar
  • 519
1 vote
2 answers
45 views

Extend native `Array` instances

I need/want to extend created array instance, to add extra methods that i see as useful. class.labels.js ...
Marc's user avatar
  • 133
5 votes
2 answers
268 views

PHP Fisher-Yates shuffle with random_int

The PHP manual states that the regular shuffle() function isn't cryptographically secure, but that random_int() is. I thought, ...
James G.'s user avatar
5 votes
1 answer
396 views

Dynamic array type using void pointers C

I made my own dynamic array type using void pointers. I'd like to know what you think of my implementation. void pointers are nice but I fear they may be inefficient. The compiler cannot tell what ...
Lead Vaxeral's user avatar
8 votes
4 answers
259 views

Array List C implementation

I want to show you my implementation of the array list in C. Is there something I can improve or fix? Header ...
lester's user avatar
  • 301
6 votes
2 answers
128 views

First attempt at making a sobel edge detection filter in c

I made a borders filter in C. It works properly, but I think it could be optimized and better designed; the formatting is abysmal. It uses too many lines for the border cases and has too many ...
GBA's user avatar
  • 63
0 votes
0 answers
63 views

Bruteforce proof of an arithmetic expansion scheme expression in array lists (Java)

Given a list of, say, integers, one way to implement such a list is to rely on an array under the hood. When we are adding elements to the array list, we might need to make the internal array larger. ...
coderodde's user avatar
  • 27k
2 votes
2 answers
168 views

Quick Sort Program

Quick sort is a sorting algorithm in which we select any random element as pivot from the array and we do the partition of the array around that pivot. Basically we place all the elements smaller than ...
Strange Alchemist's user avatar
5 votes
4 answers
434 views

RGB Image Utility Class

I am writing a utility class to store RGB images and do a few utility functions as a way to learn C++. ...
jigglypuff256's user avatar
3 votes
1 answer
91 views

Iteratively paste values from spreadsheet tabs into empty spreadsheet

Basically below code is taking first 7 tabs from my current sheet and pasting them as values in a blank excel sheet with same tab names and saving them in a specific folder by filename I specified. ...
Sorab's user avatar
  • 31
1 vote
1 answer
55 views

Transform an array into object and set index for an unique key in javascript

I have a method that merges keys and indexes from an array into an object. I'm stuck with ways to compress this method, and I don't know what I can do to make it simpler. Goal get an array of objects ...
wittgenstein's user avatar
0 votes
1 answer
91 views

Printing Permutations

Following is a leetcode problem: Given an array nums of distinct integers, return all the possible permutations. You can return all the possible permutations. You can return the answer in any order. ...
Strange Alchemist's user avatar
2 votes
1 answer
51 views

Helper functions to get, set and remove from Firefox browser storage. Also, to get, push and remove from lists stored in the database

I am making a plugin for Firefox, this is (more or less) my first time working with JavaScript. Is this a reasonable design for working with both values and lists in a database? ...
Emil Holmsten's user avatar
2 votes
1 answer
94 views

C generic typesafe dynamic array (vector) try 2

The previous generic dynamic array I asked a review for here was written using only the preprocessor and so while the array itself was type-safe, all the manipulating macros where not. In this try I ...
Itai Nelken's user avatar
2 votes
1 answer
72 views

An implementation of Givens method for diagonalising symmetric matrices

So I tried to create a code which aims to diagonalise symmetric matrices via Givens algorithm. The program only works for symmetric matrices, for we know a symmetric matrix is always diagonalisable, ...
Henry's user avatar
  • 121
2 votes
2 answers
78 views

Follow-up about computing lp norm with MPI

As pointed out in the answer by Victor Eijkhout to this question, the fact I am broadcasting the same vector to each process is against the MPI principles and, most importantly, will be a bottleneck ...
bobinthebox's user avatar
2 votes
1 answer
339 views

Compute lp-norm of a vector in parallel with MPI

I'm trying to solve the following exercise: Compute in parallel with MPI the lp norm of a vector of a predefined size N ...
bobinthebox's user avatar
3 votes
1 answer
132 views

Swift - efficient array searching

I am trying to find a way to search an Int array (all numbers are > 0) and identify sequences where the sum of each element is a specific number. One element can ...
koen's user avatar
  • 179
10 votes
5 answers
2k views

Implementation of a two-dimensional array in C

I implemented a two-dimensional array in C and would like to know if the implementation is sound in terms of Memory management Potential bugs and other side effects that I missed Code style (...
Gilfoyle's user avatar
  • 1,125
3 votes
1 answer
114 views

How can I condense my code in node.js for sorting unique values within an array?

Kattis problem - ("I've been everywhere") I would highly recommend looking at the problem through the link, however I will summarize it a bit here and explain the functionality of each part ...
doroshm's user avatar
  • 33
4 votes
2 answers
218 views

Robust input for lottery tickets

I've made a method that provides a robust way for a user to fill out a lottery ticket. During this process I found out that Java also provides syntax for labels. That was very astounding for me. But I ...
Dexter Thorn's user avatar
  • 2,154
1 vote
1 answer
145 views

C# Get All Diagonals Jagged Array

How can I improve this? The idea is to store every left to right diagonals in a list Not looking for a more efficient algorithm instead something readable, LINQ perhaps? input: 3, 1 2, 5, 7 1, 5, 8, 3,...
Laycoonz's user avatar
  • 103
2 votes
1 answer
88 views

Multidimensional array in Java

I have this multidimensional array that generalizes vectors and matrices: com.github.coderodde.util.MultidimensionalArray.java: ...
coderodde's user avatar
  • 27k
4 votes
3 answers
357 views

Removing repeating rows and columns from 2d array

This is a real problem I had to fix recently. Imagine having generic array where you can have duplicate columns and rows. You want to remove those duplicates as long as they are next to each other. <...
K.H.'s user avatar
  • 2,568
1 vote
1 answer
116 views

Array Implementation In JavaScript

Review I have written my own implementation of Array in JavaScript with the basic functionalities. Can anyone please review this code and point out the mistakes/how to make the implementation better? ...
enigma6174's user avatar

1
2 3 4 5
43