Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 8 months ago. Improve this question getting Exception in thread “main” java.lang.ClassCastException: class java.lang.Integer cannot be cast to class
Tag: data-structures
Prefix To Postfix Java
I need some help with my prefix to postfix code. When ever I generate the action through GUI from the expression “* 2 + 2 – + 12 9 2” it returns 2*. It should be returning “2 2 12 9 + 2 -+*”. I keep changing the code around and I keep ending up with the same result. Please
get kth-largest-element-in-an-array – implemented using maxheap but getting time exceeded in leetcode
I am trying to solve this leetcode challenge . I implemented a MaxHeap and tried to popout the values to get the Kth largest element in the array but I get a time limit exceeded. Is there any issue with my MaxHeap implementation that it is slow or can this be done in a faster method? Problem https://leetcode.com/problems/kth-largest-element-in-an-array/ } Answer
Longest common prefix in binary representation
We are given a undirected tree with N (1 to N) nodes rooted at node 1. Every node has a value assigned with it, represented by array – A[i] where i:[1:N]. We need to answer Q queries of type : -> V X : longest length of the common prefix between value V and any ancestor of node X including
Transform trie class method to trie node method
my question is how to transform this method from the trie class into a method of the node class that doesn’t use the node as a parameter, I know that I have to make a first method on the tree like this: But I don’t know how to make the transformation of the method into the node class. This is
Count nodes that are bigger than all their sons
I have to make a programm that counts the nodes bigger than their sons without including the leaf nodes for example: This is my approach: But I can’t see the error Answer Assuming info is an int, this could work for you. I haven’t tested the code, so let me know if there are issues.
Simple Linked List: getting an ‘error – found cycle’ in code
I have this reverseList function: But I get an error that says ‘found cycle in the LinkedList’ when iterating specifically through ‘curr.next = prev’ and ‘prev = curr’. Any ideas on why this might be occuring? Thanks Answer As far as I can tell you are testing your code with some kind of judge since there is no “found cycle”
Couldn’t implement binary search on linked list
i am a cse student who takes data structures course. Trying to implement binary search algorithm to my SinglyLinkedList class, somehow i’ve failed. Could you check it what’s wrong please ? The related method; I’ve debugged and it just enters the loops this side: else if(temp.getElement() > target) All class for better understanding; And the main method; It returns; Answer
Merge two object lists in java of the same type [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question How do i merge two object lists in java for eg: i have 2 lists listA listB with one object each like listA[name=abc,age=56, weight=null] listB[name=Null,age=Null,weight=70]
Making a island large leetcode – spotting mistake Java
I am working on LeetCode problem 827. Making A Large Island: You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-directionally connected group of 1s. Example 1: Input: grid =