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
-1
votes
0answers
26 views

Brute force sum numbers of an array in python [closed]

id like to know how to code in python something that sums all the possible combinations of numbers inside an array, for example with an input like this ...
2
votes
2answers
74 views

JavaScript: Better way to sort an array by setting custom index

I'm trying to create a sorted array based on the below input data: Input: [{"title": "100_baz"}, {"title": "01_foo"}, {"title": "05_bar"}] ...
6
votes
3answers
932 views

Supermarket Product Inventory Management with Polymorphic Product Types

The following method is used to add objects to a polymorphic ArrayList from a file. It reads lines from the file, and based on a specific line which denotes the ...
2
votes
4answers
78 views

User Specified Array Read and Modify

How may this code be improved upon, the user inputs array of specified length and replaces each element that is smaller than the mean of the first and last element with the mean. Is there a better ...
0
votes
2answers
87 views

Array indexing with copy constructor, assignment operator and index operator overload

The code below is a custom array class that handles indexing, copying, printing, etc. explicitly. Is there a better approach for specification (declaration and definition) of the assignment operator (...
2
votes
1answer
44 views

Rewrite of Array.join

While rewriting Array so I can practice my javascript, I looked at my implementation of .join(). It seems a little clunky to me. ...
5
votes
1answer
126 views

Car Showroom Database: Taking user inputs and manipulating arrays

I've been learning C# for around 2 weeks and I'm feeling a bit more confident. I wrote this for general practice and am quite proud but hoping to make it faster and more efficient as I progress and ...
-1
votes
1answer
43 views

Trying to get every 6th set of 4 bytes from a python array [closed]

I have an array of bytes 6144 bytes long. I want to extract a set of 4 bytes every 6th set of 4 bytes . So every 24 bytes I want to extract 4 of those bytes and join them in a new array. So ...
5
votes
3answers
122 views

How can I Implement a better version of my function find the closest number to zero?

I recently had to do a test for a job interview, and the prompt was to code a function that returns the closest number to 0 given an array of negative and positive numbers. My function works ...
2
votes
2answers
32 views

Asynchronous array methods chaining

I am trying to check that a list of files are all images using functional programming. Some actions I go through are asynchronous, so I have to wait for them to completely finish before passing to a ...
4
votes
3answers
671 views

Best way to pass a 2d array to functions which size is unknown at compile time in pure C

I've been wondering for some time what the best way to pass a 2d array to functions is. I know that arrays, passed to functions, decay into pointers, so int arr[25] ...
4
votes
2answers
55 views
3
votes
2answers
166 views

Array of objects to array

What would be the "correct" way of transforming an array of objects into an object that contains an array? Suppose I have this array that contains objects: ...
3
votes
1answer
84 views

Find minimum count of items where sum of them is X from an array

I recently faced an interview question where you have to find minimum needed items from an array that can added together to generate X value. For example giving: <...
0
votes
2answers
244 views

Find the maximum value of | Ai - Aj | + | i - j |: [closed]

hackerearth.com practice problem Can you solve it?: Given an array 'A' consisting of 'n' integers, find the maximum value of the following expression: \$\lvert A_i - A_j\rvert + \lvert i - j\...
4
votes
2answers
59 views

converting bits binary to bcd

I wrote a code that requests user input and then converts binary to bcd then back to binary using bitwise operations. While I think my code is good I want to know if there is a better way to write the ...
0
votes
0answers
42 views

Array of varied dimensions

I wrote a UltraCube class whose purpose is to provide an array of custom number of dimensions. This was created because I needed to make number of dimensions for ...
4
votes
1answer
62 views

Outputting flavor text depending on inputted strings

I have this program that takes two strings from the user, stores them in mixArray, then "mixes" them with mixItUp() and outputs ...
8
votes
2answers
129 views

Printing a 2-D array diagonally

The case scenario: A 2-D array is given: 1 3 6 10 15 2 5 9 14 19 4 8 13 18 22 7 12 17 21 24 11 16 20 23 25 and its size ...
4
votes
2answers
57 views

Map associative array to another array php

I have an associative array of the states of some country, and the states names are the keys: ...
5
votes
2answers
1k views

Generic dynamic array implementation in C

I'm working on my own generic-type dynamic array in C99 and I would like to hear your input, suggestions, ideas, anything! What I most care about is: 1) correctness and 2) performance. So far, I've ...
4
votes
4answers
112 views

Check non-continuous range for equal values

Background I'm trying to check equality between cells in an irregular, non-continuous range of cells. For this purpose I would like to know if all cells are equal to the first ...
3
votes
1answer
87 views

Searching an element in a 2D sorted array

I had to write a code (as an exercise) that receives a 2D row wise and col wise sorted array and an element, and return true is the element exists in the array. The first thing that came to mind when ...
0
votes
0answers
75 views

Simple React JavaScript Markdown Parser

I needed a simple Markdown parser for my purposes, such that I could turn a small subset of it (just bold, italics, code, links, and a custom poke you can click on) into React components (without ...
5
votes
3answers
631 views

Searching an element in an alternately sorted array

I had to write some code that receives a number 'x' and an alternately sorted array (an array with all even indexes sorted upwards and all odd indexes sorted downwards) and checks if 'x' exists in the ...
1
vote
0answers
20 views

Intersection of Two Arrays - Space Time And Complexity [closed]

The problem is as follows: Given two arrays, write a function to compute their intersection. The below code is my solution.I'm just curious as to what the space time and complexity of below algorithm ...
3
votes
2answers
139 views

Dynamic Array Implementation in C++

I've finished implementing a dynamic array in C++. I'm a beginner in C++ and also in algorithms and data structures, so any constructive feedback about improving the implementation would be greatly ...
2
votes
1answer
53 views

Sum of array of strings to bytes

I'm trying to generate the sum of a collection of strings by calcuating each character's byte value into a sum: ...
1
vote
0answers
28 views

How to get cordinates of selected numbers which are from array?

You are given to paint a floor area of size A. There will be 12 paint buckets from 4 primary colors with each having 3 shades (i.e. total 12 buckets). The bucket size, or more specifically, the amount ...
0
votes
0answers
35 views

Inserting Elements Into a Sorted Array

Very new to JS (wrote my "Hello World" around 3 days ago), but not to programming in general. My documentation is inspired by the approach I followed for Python (since I haven't learned JS ...
1
vote
2answers
69 views

Semi sorted binary search

Say you have an array that is "semi-sorted", e.g. something like this: [7,8,9,10,1,2,3,4,5,6] Where a part of the end of the sorted array was transferred to the beginning. Is there a way to still ...
2
votes
1answer
50 views

Codewars: Pick peaks

Pick peaks Wrote my "hello world" on Thursday, so definitely a beginner. I know some Python, so not a novice to programming in general. Question For example, the array ...
-1
votes
1answer
27 views

To search a json string value in a list [closed]

I am trying to search a json string(events) from a given list (eventSubscriptions).Here is what I have tried. ...
0
votes
3answers
76 views

Convert an array of doubles to a concatenated Hex string

I'm working on a tool that converts data between two systems. System 1 presents me with arrays of latitudes and longitudes as doubles. System 2 requires an input of that array as a single Hex string. ...
3
votes
0answers
40 views

Fixed size 2d array of objects

My Objective is to create a fixed column array object of size 4 columns so that I can form a 2d array in the following format which I can use to print to a pdf later. The solution is working fine. But ...
3
votes
1answer
70 views

Compare and Process Common and Uncommon files separately

I have the following files: STUDENT_D19001.T103412_HU.txt STUDENT_D19001.T103412_KU.txt STUDENT_D19002.T113030_HU.txt STUDENT_D19002.T115055_KU.txt STUDENT_D19003.T115055_KU.txt STUDENT_D19004....
0
votes
0answers
27 views

Little Multilanguage site with modifiable words in a table.( Code improvement )

I have written a code for my little little website to make it multilanguage. It is a simple "developer" page where you can select from four different languages. Hungarian, English, Deutch and Roman. ...
0
votes
0answers
15 views

Randomizing array elements with specific conditions for repetition

I have written a function for producing a 16 step array (note[16]), intended to generate two numbers (in this example 1 and 2) with the following conditions: Any of the numbers can only be repeated ...
3
votes
1answer
65 views

Find number of horizontal brush strokes to paint a skyline

Asked in interview today: You want to paint a skyline on your wall using only horizontal brush strokes. You are given an array of numbers, each representing the size of the column/building in that ...
1
vote
2answers
52 views

Removing duplicate hashes in an array while keeping count of the times the hash was present

I have an array of hashes (price_params['items']) where each item has a key called quantity what I'm trying to do is to clean ...
-2
votes
1answer
56 views

Writing array to vector slows down program after each iteration [closed]

I have a C++ program where the input are 2 arrays, each containing a and z number of elements. The program then creates all ...
2
votes
3answers
87 views

My own array implementation in C

I've been trying to remember old programming concepts like data structures. My first challenge was about implementing my own array of positive integers: ...
4
votes
5answers
208 views

Counting number of `1` digits in the value of \$11^n\$

I am trying to improve the efficiency of my code, The Question is: Given a value n, where n is in the range ...
-5
votes
1answer
48 views

Find pair of adjacent prime numbers in a two-dimensional array

Does anybody know how to find pair of adjacent prime numbers in two-dimensional array, quicker than this? I'm talking especially about this part which looks for adjacent numbers not about function ...
3
votes
1answer
43 views

Easier way to find matching array from a lot of arrays

I have the following arrays which save the MAC-adresses of a lot of bluetooth beacons and their positions in a building: ...
8
votes
3answers
702 views

Creating an affinity-matrix between protein and RNA sequences

I wrote an algorithm that analyzes protein-RNA interactions and I found that the following function is the bottleneck that causes performance issues: ...
1
vote
1answer
95 views

Comparing information to a directory of active enployees

The code is doing everything that I need it to. It's taking much too long though upwards of a couple minutes to complete the macro. Does anyone know how I code optimize this VBA code to run quicker? I'...
7
votes
2answers
1k views

Move all zeros to the left with TDD approach

The task Given an integer array, move all elements that are equal to 0 to the left while maintaining the order of other elements in the array. Let's look at the following integer array. ...
2
votes
1answer
96 views

Bingo Game that needs someone to look over because of repetitive coding

I am a beginner Java programmer and am in need of someone to read over it and help me condense my repetitive coding. I wrote code for a Bingo game and feel like I repeat code too often. If anyone ...
2
votes
2answers
200 views

Working with Arrays in Swift

It's an exercise from a Swift-course I'm currently taking. You are given an array of integers. Make an additional array named computedNumbers. computedNumbers should multiply each element in the ...

1 2 3 4 5 34