Skip to content
Advertisement

Tag: data-structures

Flatten a Multilevel Doubly Linked List leetcode

You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in the example

Create a list of List from an Array

How can i create a list of List from Array eg: int[] arr = {3, 1, 5, 8, 2, 4}. Such that the lists in the List have only two elements eg: [[3,1], [5,8], [2,4]]. So far i have tried code below but it return only lists with one element,I can’t figure out where i went wrong. Result: [[3], [1],

Custom LinkedList constructor with array as a parameter

I’ve written this program to implement a LinkedList. There are 2 classes: Node and IntLinkedList and the relationship between them is aggregation. In the IntLinkedList class, the constructor’s parameter is an array and I’ve tried to use a for-each loop to add the data of the array to the linked list. Here is my code: Node.java IntLinkedList.java I’ve tried for

Search Suggestions System

Below is the problem statement and below it , is my solution using TrieNode Data structure but My ans is wrong and i am not able to understand where my code gone wrong , please help …… Given an array of strings products and a string searchWord. We want to design a system that suggests at most three product names

Down to Zero II

This is the question: You are given Q queries. Each query consists of a single number N . You can perform any of the operations on in each move: If we take 2 integers a and b where N=a*b (a ,b cannot be equal to 1), then we can change N=max(a,b) Decrease the value of N by 1 . Determine

Way to overcome fail-fast iterator in HashMap

In competitive programming, I was solving a given problem – given an array nums of non-negative integers, and a target sum S, we have to find out the number of ways we can obtain target sum from sum of given numbers (where each nums[i] can be taken as nums[i] or -nums[i]. Although I came across some solutions that mainly relied

Advertisement