Hackerrank Java BitSet Solution
Java's BitSet class implements a vector of bit values (i.e.: () or ()) that grows as needed, allowing us to easily manipulate bits while optimizing space (when compared to other collections). Any element having a bit…
Java's BitSet class implements a vector of bit values (i.e.: () or ()) that grows as needed, allowing us to easily manipulate bits while optimizing space (when compared to other collections). Any element having a bit…
You are given a list of student information: ID, FirstName, and CGPA. Your task is to rearrange them according to their CGPA in decreasing order. If two student have the same CGPA, then arrange them according to their…
In computer science, a set is an abstract data type that can store certain values, without any particular order, and no repeated values(Wikipedia). is an example of a set, but is not a set. Today you will learn how to…
For this problem, we have types of queries you can perform on a List: Insert at index : Insert x y Delete the element at index : Delete x Given a list, , of integers, perform queries on the list. Once all queries are…
Sometimes it's better to use dynamic size arrays. Java's Arraylist can provide you this feature. Try to solve this problem using Arraylist. You are given lines. In each line there are zero or more integers. You need to…
We define the following: A subarray of an -element array is an array composed from a contiguous block of the original array's elements. For example, if , then the subarrays are , , , , , and . Something like would not…
You are given a 2D array. An hourglass in an array is a portion shaped like this: For example, if we create an hourglass using the number 1 within an array full of zeros, it may look like this: Actually, there are many…
An array is a simple data structure used to store a collection of data in a contiguous block of memory. Each element in the collection is accessed using an index, and the elements are easy to find because they're stored…
In computer science, a priority queue is an abstract data type which is like a regular queue, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority…
In computer science, a double-ended queue (dequeue, often abbreviated to deque, pronounced deck) is an abstract data type that generalizes a queue, for which elements can be added to or removed from either the front…
Comparators are used to compare two objects. In this challenge, you'll create a comparator and use it to sort an array. The Player class is provided for you in your editor. It has fields: a String and a integer. Given…
A string containing only parentheses is balanced if the following is true: 1. if it is an empty string 2. if A and B are correct, AB is correct, 3. if A is correct, (A) and {A} and [A] are also correct. Examples of some…
Let's play a game on an array! You're standing at index of an -element array named . From some index (where ), you can perform one of the following moves: Move Backward: If cell exists and contains a , you can walk back…
Solution in java8 Approach 1. Approach 2. Approach 3.
There is a collection of input strings and a collection of query strings. For each query string, determine how many times it occurs in the list of input strings. For example, given input and , we find instances of ', of…
Given a 2D Array, : We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation: There are hourglasses in , and an hourglass sum is the sum of an hourglass'…
A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing…