Solution for hackerrank problem Mandragora Forest in Java. The evil forest is guarded by vicious mandragoras. Garnet and her pet must make a journey through. She starts with pet health point s and 0 e
Program to convert a binary search tree to doubly linked list with in order traversal. The left and right pointers in nodes are to be used as previous and next pointers respectively in converted Circu
Here s your coding interview problem for today. This problem was asked by Google. Given a string of parentheses, write a function to compute the minimum number of parentheses to be removed to make the
Imagine you are building a compiler. Before running any code, the compiler must check that the parentheses in the program are balanced. Every opening bracket must have a corresponding closing bracket.
This problem was asked by Facebook. Given a multiset of integers, return whether it can be partitioned into two subsets whose sums are the same. For example, given the multiset 15, 5, 20, 10, 35, 15,
This problem was asked by Facebook. Given an array of integers, write a function to determine whether the array could become non decreasing by modifying at most 1 element. For example, given the array
This problem was asked by Facebook. Given three 32 bit integers x, y, and b, return x if b is 1 and y if b is 0, using only mathematical or bit operations. You can assume b can only be 1 or 0. Idea be
This problem was asked by Amazon. Given a matrix of 1s and 0s, return the number of islands in the matrix. A 1 represents land and 0 represents water, so an island is a group of 1s that are neighborin
This problem was asked by Google. Given two non empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists o
This problem was asked by Airbnb. We re given a hashmap associating each courseId key with a list of courseIds values, which represents that the prerequisites of courseId are courseIds. Return a sorte
This problem was asked by Two Sigma. Using a function rand7 that returns an integer from 1 to 7 inclusive with uniform probability, implement a function rand5 that returns an integer from 1 to 5 i
This problem was asked by Snapchat. Given a list of possibly overlapping intervals, return a new list of intervals where all overlapping intervals have been merged. The input list is not necessarily o
This problem was asked by Google. Given the head of a singly linked list, reverse it in place. Idea behind the solution Consider this list 1 2 3 4 5 The reverse would be 5 4 3 2 1 or 1
This problem was recently asked by Facebook You are given a list of numbers, and a target number k. Return whether or not there are two numbers in the list that add up to k. Example Given 4, 7, 1 , 3
This problem was recently asked by Facebook Given a sequence of numbers, find the longest sequence that contains only 2 unique numbers. Example Input 1, 3, 5, 3, 1, 3, 1, 5 Output 4 The longest se
Hi, here s your problem today. This problem was recently asked by AirBNB You are given a singly linked list and an integer k. Return the linked list, removing the k th last element from the list. Try
NetBeans is a popular IDE for Java and other application development. Which allows applications to be developed from a set of modular software components called modules. NetBeans is available to run o
Manasa is out on a hike with friends. She finds a trail of stones with numbers on them. She starts following the trail and notices that any two consecutive stones numbers differ by one of two values.
Prettier is an opinionated code formatter which support many languages. In this example we will see how to prettify java code. NPM Modules We need Prettier Prettier Java NPM Installation npm install s
Trees Is This a Binary Search Tree?, is a HackerRank problem from Data Structures subdomain. In this post we will see how we can solve this challenge in Java For the purposes of this challenge, we de
Recent comments on java
count + n 2 0 ?1 0 n 2 explain why n 2 0 and why n 2 these are not clear
if a number gets repeated thrice then how will this progrm work??
Or maybe from Java 5 String has a format method which we can use to print 2 digit aft
fayek or maybe we can use the old C programming style in JAVA by simply using printf
Thanks shihab And from that explanation i have come to know that there might be more
As we can see we have to print square matrix So if we use a single space every time o