Category "data-structures"

C# Traverse tree and find all unique hierarchy chains from root to leaf

I am working on a tree problem and not able to figure out how to solve the problem at hand. I've googled and also checked on SO, but could not find a suitable a

How to store sets of objects that have occurred together during events?

I'm looking for an efficient way of storing sets of objects that have occurred together during events, in such a way that I can generate aggregate stats on them

Inserting a key-value pair in a specified position of a JS Map object (akin to Array's .splice()) [duplicate]

Is there a way to performance-efficiently insert a key-value pair in a specific place of a Map object? The problem I'm trying to solve is sto

Find the Longest Subarray

Given an array of integers, what is the length of the longest subarray containing no more than two distinct values such that the distinct values differ by no mo

Nested for loop in Big Oh Complexity

for(int i = 0; i < n; i++) { for(int j = 0; j < i; j++){ // do swap stuff, constant time } } I read that single for loop is O(N) and trav

How to loop over all examples in a tensorflow DatasetV1Adapter?

I have a dataset of images saved in 97 .tfrecord-files. Each example includes image data as well as groundtruth data (classes and bounding boxes) for object det

Minimum car required to accommodate given people

I had one coding round where question statement was like this *You have a given number of friends and seating capacity of their cars now you need to find minimu

How to find the winner(s) of Brazil's Mega Sena lottery most efficiently?

Mega Sena is Brazil's most famous lottery. The number set ranges from 1 to 60 and a single bet can contain each from 6 to 15 numbers selected (the more numbers

Unable to convert class syntax to function syntax for a Linked List

Okay so I'm learning Data Structures where my tutorial is following class syntax. So now I am trying to convert it to function declarations as I want to practic

Removing an item from a priority queue

In Python, the heapq module provides a priority queue. It has methods for inserting and popping items. How do you remove an item that you have inserted that i

How to merge 3 sorted arrays into 1 sorted array in Big-O(N) time?

Trying to merge 3 arrays into one so that the final array is in order. Given int[] a = {1,3}; int[] b = {2,4}; int[] c = {1,5}; Merge the arrays so that t