Category "data-structures"

Circular linked list not working after appending 3rd node

It's Showing output for 2 nodes but after adding 3rd node it doesn't showing any output, what i'm doing anything wrong?? This is the append method that i have

Is there a way to make a node of Linkedlist point to a node that isnt next in the list

I am making a snakes and ladders game in C using a LinkedList, I have a square struct that represents squares on the board. I need to add snakes and ladder that

insert zk log check in and out to one row in database

I am retrieving data from ZK attendance device using zkteco-sdk-php. The out come is like this UID ID NAME STATE DATE TIME TYPE 55 275 Employ1 Fingerprint 19-0

Python modulo returning wrong answer

I was attempting this question on leetcode using python3. My solution for this problem is as follows: class Solution: def __init__(self): self.memo

Tokenize a std::string to a struct

Let's say I have the following string that I want to tokenize as per the delimiter '>': std::string veg = "orange>kiwi>apple>potato"; I want every

Find the maximum number of distinct elements that can be achieved in array a after at most k operations

My assignment: Consider two arrays a and b where each consists of n integers. In one operation: Select two indices i and j (0 <= i,j < n) Swap integers a

Island perimeter problem - cannot count all neighbor cells

I'm working on the Island Perimeter Problem from LeetCode. I tried to use the DFS algorithm, based on LeetCode#200, to solve this problem. For example 1, the ou

How to write this piece of code more briefly

I am trying to implement a graph using HashMap where I store the nodes (vertices) on the key column and the adjacent nodes ( adjacent list ) as a HashSet on the

Is it right to implement queue with single linked list?

My Code ↓ Some macros defined by #include <stdio.h> #include <malloc.h> #define ElementType int #define ERROR 0 // 队列ஷ

Is there a way to initialize or modify a list that allows to reference previous values?

I want to store non-rectangular data in a structure, e.g. in a list. Referencing previous data works using a tibble, e.g. like this: dat <- tibble(a = 2,

How can I organize Role Based Access Control (?) in my scenario?

I have a database where there are products grouped by categories. When a user registers, he selects a category, which cannot be changed. The user will be able t

Java - Predicate to find Node with set value

I came upon object graphs while studying. And while they seem "cool" and useful, a related problem to the material made absolutely no sense to me. public class

How do i create a function to convert a binary tree to a tuple?

i came across this question where i was tasked to convert a tuple into binary tree and then convert binary tree back to tuple and return both tree and tuple. i

Describing a numbering system that counts from x at the y position in an index

From a theoretical perspective, I'm interested in learning how one would correctly describe a numbering system that starts counting from x at the y position in

Recursively creates dataclasses based in nested dictionary

I have a dataclass called Config that is created through the properties and values of a dictionary. Since this dictionary can have nested dictionaries, i would

Distirbute Candy - Finding minimum reproducible example of the problem

The question is to distribute candies to N children.Each child has a rating. Distribution should be such that each child have at least one candy and children wi

How to convert circular linked list into singly linked list

First, I make circular linked list that look like 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> (head) Now, I am trying to convert this circular linked list

Fold in Scade Suite is confusing me

So I know how the reduce, accumulator and how fold works in C++, Python, etc... But for some reason in Scade Suite it's kinda confusing to me. Scade Suite Examp

Maximum Frequency Number in an array using Hashmaps

Problem: You are given an array of integers that contain numbers in random order. Write a program to find and return the number which occurs the maximum

Can we detect cycles in directed graph using Union-Find data structure?

I know that one can detect cycles in direct graphs using DFS and BFS. I want to know whether we can detect cycles in directed graphs using Union-Find or not? I