Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
0 answers
116 views

Code 1 In code one we are using the binary exponentiation. public class Solution { public int pow(int A, int B, int C) { if (C == 1) return 0; long base = (A % C + C) % C; ...
Prashant Vats's user avatar
3 votes
1 answer
137 views

I’m currently learning about data structures and algorithms (DSA) by reading the book “Learning JavaScript Data Structures and Algorithms – 2nd Edition” by Loiane Groner. I am implementing the DSAs in ...
Gabriel França's user avatar
2 votes
1 answer
103 views

I am a student studying graph algorithms and learning topological sorting of a Directed Acyclic Graph (DAG). The topological_sort function below is provided in our textbook, and I am not allowed to ...
user30659876's user avatar
Advice
1 vote
4 replies
156 views

I want to learn Data Structures, Algorithms, and Big-O notation from scratch, but there are too many resources online and it’s difficult to determine which ones are trustworthy or widely used by ...
quantumlattice's user avatar
-2 votes
1 answer
78 views

Something called reversed() on an instance of a class of mine, which resulted in the error TypeError: 'HBox' object is not reversible What does it mean for an object to be reversible?
Marnanel Thurman's user avatar
-4 votes
0 answers
45 views

so I was trying to reverse an array by recursion so the code logic is we are swaping right most end value to the left most end. I have implemented logic but the thing is My recursion function retuns ...
Divya priya's user avatar
1 vote
1 answer
76 views

I’m studying red–black trees (CLRS style) and I’m confused about how black-height behaves during RB-INSERT-FIXUP. I quote here that procedure from CLRS: RB-INSERT-FIXUP(T, z) while z.p.color == ...
Sami Barakinston's user avatar
0 votes
1 answer
102 views

I'm working on a small DSA practice problem involving frequency counting, but with a twist. I have a list of tuples where each tuple represents a (category, item). Example: data = [ ("fruit&...
Ridit's user avatar
  • 23
Advice
0 votes
1 replies
43 views

I'm trying to model a generic "capability" or "permission" structure. The part I'm having trouble with is finding the name of the specific data structure. It's not a formal tree, ...
Jim Garrison's user avatar
1 vote
1 answer
220 views

I'm interesting in possible implementation approaches for a quite special variant of a list, with the following requirements: Efficient inverse lookup ("index of"): "give me an index ...
cubuspl42's user avatar
  • 8,631
0 votes
2 answers
166 views

I have a folder containing huge numbers of files in many subfolders, and I want to select the files with a name that matches any of a specified list of patterns (regular expressions). My regular ...
Theodor Zoulias's user avatar
-3 votes
1 answer
193 views

The algorithm I've written for an assignment is closely related to this monotonic stack approach https://www.geeksforgeeks.org/dsa/next-greater-element/ Best case: n pushes → Time complexity: O(n) ...
user29898's user avatar
Advice
1 vote
1 replies
42 views

I understand the standard explanation for why B-trees are used in databases: they minimize disk seeks by packing many keys into each node, keeping the tree shallow (3-4 levels), and enabling efficient ...
j.i.l.l's user avatar
  • 11
1 vote
1 answer
109 views

Problem summary: Each person in line has tickets[i] tickets to buy. Every second The person at the front buys one ticket. If they still need more tickets, they move to the end of the queue. We need ...
Hercules's user avatar
-2 votes
1 answer
38 views

Consider the following LeetCode problem: You are given an array nums of n positive integers and an integer k. Initially, you start with a score of 1. You have to maximize your score by applying the ...
Yousef Marey's user avatar
1 vote
1 answer
168 views

I have a JSON file with nested objects, and I want to update specific values inside it using Python. The structure can vary, but it usually looks something like this: { "user": { "...
JEFFERSON FRANCISCO ABAC LEMUS's user avatar
-4 votes
1 answer
64 views

📝 Body I have a Mongo collection CollectionA where each top-level object contains a nested array of meetings now each meetings have start and end times, for example: CollectionA = [ { &...
LEO_007's user avatar
  • 51
-1 votes
1 answer
135 views

I have two lists in Python: list1 = [1, 2, 3, 4] list2 = [3, 4, 5, 6] I want to merge them into a single list such that: No duplicates remain The original order of elements is preserved For the ...
Binil S Mathew's user avatar
1 vote
1 answer
58 views

I am learning about queue data structure in python. I learnt the implementation of a queue using list in python and the issue of memory wastage when we dequeue a few elements from the front. We use a ...
dataminer's user avatar
2 votes
2 answers
103 views

I’m trying to implement a mutual friends feature using a graph data structure represented as an adjacency list in Python. Each node represents a person, and each edge represents a friendship (an ...
Durga's user avatar
  • 21
1 vote
2 answers
102 views

The method below has been taken from the book Data Structures & Algorithms by Robert Lafore. This method is used to bubble sort a given array. nElems is the number of elements in the array. In my ...
Azer Shukurzade's user avatar
1 vote
1 answer
83 views

I'm searching for a very flexible data structure being able to describe what data to fetch from an API (assuming I would own that API by creating a custom wrapper plugin). The data itself is quite ...
m477h145h3rm53n's user avatar
3 votes
2 answers
558 views

Given StartTime and endTime for N employees, an employee can form a team if his working hour overlaps with other employees' (both startTime and endTime inclusive). Find the maximum team size. Example: ...
QA Android Alfa's user avatar
4 votes
2 answers
401 views

A lexicographical swap is defined as: At each step, pick the earliest possible inversion (i, j) (smallest i, then smallest j > i with a[i] > a[j]) and swap them. Repeat until the array is sorted....
ISG's user avatar
  • 49
1 vote
1 answer
167 views

I'm trying to solve LeetCode 199. Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. I've ...
Benny's user avatar
  • 519
2 votes
1 answer
201 views

An abstract data type maintains a subset of numbers {0,1,2,...,n-1}. The operations allowed on this are: insert(i) - Insert element i in the subset if not already present. find(i) - Return True iff ...
abora's user avatar
  • 1,101
10 votes
3 answers
621 views

This is the code I have written for searching a node in a tree as a part of my assignment: typedef struct NODE { int key; struct NODE *left, *right; } Node; Node *search(Node *head, int key)...
M.B.'s user avatar
  • 279
4 votes
2 answers
277 views

I'm working on an interesting question about answering range h-index queries. Fyi h-index is the max integer h that an author has published at least h papers that each are cited at least h times. You ...
Isabella's user avatar
2 votes
1 answer
130 views

I have embeddings (about 160 Million) that I created with a BERT-based encoder model. Right now they are in a .pt format and takes about 500GB in the disk. I want 2 things: To save them in an ...
Noam's user avatar
  • 55
5 votes
1 answer
269 views

I was trying to check for wrap around property when the value is greater than the container that can hold it. public class Main { public static void main(String[] args) { double value = ...
shajid's user avatar
  • 53
3 votes
2 answers
163 views

I think this is a design problem. I’m trying to implement a hash table library in C89 in which the user will be able to insert mixed-type literal keys and values, e.g., HT_SET_LITERAL(&ht, "...
os_user's user avatar
  • 100
0 votes
0 answers
66 views

In databases such as PostgreSQL, doing exact counts like select count (*) from table where condition perform a full table scan. PostgreSQL will need to scan either the entire table or the entirety of ...
user22476690's user avatar
1 vote
1 answer
125 views

I'm trying to write a queue that will store strings. Using GDB I can tell that I make a memory allocation error in the function resizeQueue. Here's the exact message: Program received signal SIGTRAP, ...
user31051859's user avatar
0 votes
0 answers
33 views

In Python, we can use collections.deque to implement FIFO queue operations. For example: from collections import deque queue = deque([1, 2, 3]) print("Initial queue:", queue) # ...
douya huang's user avatar
0 votes
1 answer
135 views

I have a C++ dll that collects the data from our hardware. I am trying to get a pointer to that data from the C++ dll into C#. Here is the C++ data structure #pragma pack (push, 1) typedef struct ...
Gary's user avatar
  • 117
0 votes
0 answers
74 views

In Rust, how can I define&manipulate objects that cannot be just copied bit-by-bit when they're moved? For example, an object that contains a relative pointer (i.e. a pointer whose target is ...
Stefan's user avatar
  • 28.8k
4 votes
1 answer
84 views

We know that a swap object consists of a shared register and supports a swap operation between the shared register and any local register, which atomically exchanges the values of the two registers. A ...
Algo's user avatar
  • 61
0 votes
2 answers
322 views

I have a use case requiring the reliable, durable storage, and efficient retrieval, of a large number of index entries (for which I've an application-specific serialization to bytes that preserves ...
aSteve's user avatar
  • 2,056
3 votes
1 answer
105 views

I'm trying to convert this Wikipedia table into a nested JSON object. I want to group each entry into its parent category. e.g., { "name": "Mining, quarrying, and oil and gas ...
George P's user avatar
0 votes
0 answers
97 views

I'm trying to understand how an AVL tree is built from a sequence of integer keys. The keys I have are: 10, 20, 5, 4, 3, 2, 30, 40 I want to construct the AVL tree step by step and see how rotations ...
shakir Sumon's user avatar
0 votes
1 answer
272 views

I am implementing search-trees and hash-tables in pure C (C89). Although the time+space asymptotic complexity is good, the constants and cache-efficiency… not so much. The keys and values are void* ...
Samuel Marks's user avatar
  • 1,940
1 vote
2 answers
183 views

I'm trying to understand how type information is stored in memory. We often say that an 8-bit value can store 2⁸ = 256 different values. But I'm wondering — when we create an object of that type, ...
toliveira's user avatar
  • 1,867
0 votes
1 answer
107 views

I'm trying to create a chrome extension where the user adds text snippets to the extension, then when they type in textarea/input/contenteditable/rich-text editors a selection dropdown appears with ...
neophoriac's user avatar
0 votes
0 answers
121 views

I tried my best implementing a Skip List in C++ in which I had a particular idea that I wanted to try out. Instead having every element in the base level be a column vector, I only only have a singly-...
Issac Howard's user avatar
2 votes
1 answer
79 views

Please check the below code, the mat array after the second rotation should be identical to the target array tar. However, it is not happening. Could you please review to check where the logic is ...
Sakib's user avatar
  • 47
2 votes
4 answers
190 views

I'm working on a problem where I need to maintain the median of a data stream, but unlike typical implementations that only support insertions, I also need to support deletions of arbitrary values. ...
Aditya Rawat's user avatar
0 votes
1 answer
63 views

I’m implementing a game leaderboard in Python where players can have the same score (ties), and I need to support three operations efficiently: add_score player_id score — update a player’s score (...
maverick's user avatar
-1 votes
1 answer
135 views

I would like to generate a minimum spanning tree for the following graph: I am using the disjoint set data structure and I am having trouble with the union (Union Rank) operation. The edges get ...
EngineerP's user avatar
1 vote
0 answers
56 views

I am trying to put together some code to find duplicated files between two or more directories, for this I am using C libs like tinydir, and plibsys, the idea is traverse dirs get the hash of every ...
anewb33's user avatar
  • 121
1 vote
3 answers
114 views

I was watching a youtube video on doubly linked lists in C. One of the functions made for the doubly linked list was an "insert_after_node" function, which as the name suggests inserts a new ...
Samo's user avatar
  • 11

1
2 3 4 5
683