Skip to main content

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.

2 votes
2 answers
97 views

Generic Dynamic Array Implementation

I wrote a dynamic array implementation in ISO C11 using void pointers. Everything I've implemented works--at least in all my tests--on a 64-bit machine. It has some vague type-checking and resizes ...
Zenais's user avatar
  • 23
0 votes
0 answers
32 views

Presence of UB and memory usage of a std::array initialization: version with temporary array on heap

I proposed several techniques to answer to https://stackoverflow.com/q/78672409/21691539. A classical way to answer would be to use std::index_sequence-based ...
Oersted's user avatar
  • 337
5 votes
2 answers
909 views

Optimized data structure mapping finite set of integers to values in C++

I'm looking for a mapping data structure, but knowing that the possible values of my keys are small numbers, I would like to trade memory for better performances (for both random access and value ...
Delgan's user avatar
  • 611
3 votes
1 answer
221 views

Presence of UB and memory usage of a std::array initialization

I proposed several techniques to answer to https://stackoverflow.com/q/78672409/21691539. A classical way to answer would be to use std::index_sequence-based ...
Oersted's user avatar
  • 337
4 votes
1 answer
63 views

Array Math to Calculate Ice Thickness -- Need Help Simplifying

I posted this on Stack but since it's working code, it was suggested I post it here. I wrote this code to calculate ice thickness using the following equation from Stephenson, 2011. It's a daily ...
emmahaggerty's user avatar
2 votes
1 answer
185 views

Hackerrank "New Year chaos" solution - permute sequence by swapping adjacent terms

I was doing the Hackerrank "New Year chaos" problem. Here is the description: It is New Year's Day and people are in line for the Wonderland rollercoaster ride. Each person wears a sticker ...
user12138762's user avatar
2 votes
1 answer
73 views

Research program for examining array list arithmetic contractions

Introduction Suppose we have a dynamic table \$T\$. Let \$\vert T \vert\$ denote the number of elements currently stored in \$T\$, and \$\vert \vert T \vert \vert\$ denote the capacity of \$T\$. Also, ...
coderodde's user avatar
  • 28.9k
6 votes
5 answers
469 views

Fill missing data in between available data with default value

My raw data has values on some random times: const rawData = [ {hour: 3, value: 3} , {hour: 5, value: 9} , {hour: 10, value: 5} , ] as const I would like to ...
Ooker's user avatar
  • 201
-2 votes
1 answer
60 views

I wrote a O(log N) code for largest element in an array today but is this an already existing way to find max element in an array? [closed]

Largest element in an array's most optimal approach. The code I have written has passed all test cases in https://www.naukri.com/code360/problems/largest-element-in-the-array-largest-element-in-the-...
im3shn's user avatar
  • 1
4 votes
3 answers
261 views

Given two sparse vectors, compute their dot product

Problem Statement: Given two sparse vectors, compute their dot product. Implement class SparseVector: SparseVector(nums) Initializes the object with the vector nums dotProduct(vec) Compute the dot ...
Pankaj Kumar's user avatar
4 votes
1 answer
123 views

Finding the earliest time we can schedule

We have a list of \$j \in \{1,\ldots,N\}\$ jobs with a processing time \$p_j\$ and a demand \$d_j\$ between 0 and 1. These are real numbers. Jobs require the fixed demand over the entirety of their ...
Titan's user avatar
  • 41
1 vote
1 answer
84 views

Find Method Implementation for Multidimensional Array in C#

I found that Array.Find(T[], Predicate) Method is only support one dimensional array. I am trying to generalize it to multi-dimensional array in this post. The experimental implementation The ...
JimmyHu's user avatar
  • 5,392
3 votes
1 answer
98 views

Creating an array (temporary table) in SQL and iterating through each row within this table to preform a check on the data in each row

The SQL Server version I am using is SQL Server 2008. I've got an SQL query/script I've written which is to help simplify some things while our API is being rebuilt. Essentially, this script allows ...
level42's user avatar
  • 131
3 votes
1 answer
47 views

Comparing a set of parameters contained in two separate strings in Powershell

I have a situation where I need to compare two strings with each other in a foreach loop that potentially run over millions of rows of data. The two strings will always contain between 1 and 12 ...
Tanaka Saito's user avatar
0 votes
1 answer
46 views

Updating class method to use data from new weather API endpoint while keeping same return value object structure as with old endpoint

I needed to update a class in Node.js that parses the response from a new weather API endpoint but still preserves the same object structure and key values from having been using the old weather API ...
Aaron Goldsmith's user avatar

15 30 50 per page
1
2 3 4 5
142