Array out of bound exception while doing topological sort

This code takes the no. of nodes in a graph and creates the graph with the number of nodes and then the user has to input the one-way edges between two vertices.(The formed Graph is a Directed Acyclic …

Problem in “between two set” hackerrank problem

Problem:You will be given two arrays of integers and asked to determine all integers that satisfy the following two conditions: The elements of the first array are all factors of the integer being …

Sorting based on order mentioned in a static map using java

How to sort a list of strings based on order mentioned in static map having item of list as key. List={“AU”,”I”,”U”, “O”, “A1”} Need to sort the above list of string using the below map which has …

Change node values to their heights in a binary tree

My task is to change the values of nodes to their heights in a binary tree. By the condition of the task, you need to change all the values in 1 pass of the tree, but you can violate this condition …

Is it possible to decrement counter within a condition?

i am trying to detect a jokerStraightFlush when analysing a poker hand. I need to add a feature where this hand works 8S JK 6S JK 4S. The JK are jokers. I am using the exact same code logic as https://…

Make a sequence an increasing sequence by adding a number multiple times

I have an array of numbers, now I want to make this as increasing sequence by adding a fixed number b. I want to find how many times the fixed number b is added to make my array as increasing sequence….

Can’t access my linked list methods and can’t iterate trough it

So im following along this playlist about data structures and in this video to conclude the linked list part, the professor explain we need an inner class called IteratorHelper. Video: https://www….

Concatenate the words to obtain a single word with the longest possible substring composed of a single letter

An array of N words is given. Each word consists of small letters (‘a’- ‘z’). Our goal is to concatenate the words in such a say as to obtain a single word with the longest possible sub-string …

Need explanation for algorithm searching minimal large sum

I’m solving Codility questions as practice and couldn’t answer one of the questions. I found the answer on the Internet but I don’t get how this algorithm works. Could someone walk me through it step-…

Given n and k, return the kth permutation sequence

The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3 ) : “123” “132” “213” “231” “…