A common problem in mathematics is to determine which quadrant a given point lies in. There are four quadrants, numbered from 1 to 4, as shown in the diagram below: For example, the point A, which is at coordinates (12,5) lies in quadrant 1 s ...

#### Funny Divisors in java

Ninja is bored with his previous game of numbers, so now he is playing with divisors. He is given 'N' numbers, and his task is to return the sum of all numbers which is divisible by 2 or 3. Let the number given to him be - 1, 2, 3, 5, 6. As 2, 3, ...

#### Insertion Sort 2 in java

In Insertion Sort Part 1, you inserted one element into an array at its correct sorted position. Using the same approach repeatedly, can you sort an entire array? Guideline: You already can place an element into a sorted array. How can you use th ...

#### Print Repeated Elements in Sorted Order in java

You are given an array A of size N. The array contains almost distinct elements with some duplicated. You have to print the elements in sorted order which appears more than once. If no such element exist print -1. Input Format T ...

#### Sara’s Strings in java

Sara does not like strings that have both the uppercase and the lowercase characters. She thinks only those strings are good which have only lowercase characters( wherever possible) or only uppercase characters( wherever possible). Given a string ...

#### Remove Zeroes in java

You are given a string s. Each character is either 0 or 1. You want all 1s in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all ones (1) form a contiguous subsegment, and if the string is ...

#### Find First and Last Position of Element in Sorted Array in java

Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, print. You must write an algorithm with O(log n) runtime complexity. Input F ...

#### CHECK IF TWO ARRAYS ARE EQUAL OR NOT in java

Given two arrays A and B of equal size n, the task is to find if given arrays are equal or not. Two arrays are said to be equal if both of them contain same set of elements, arrangements (or permutation) of elements may be different though. Note ...

#### Print Matrix in snake Pattern in java

Given a matrix of size N x N. Print the elements of the matrix in the snake like pattern depicted below. Your task is to complete the function printSnakePattern which receives the input matrix and N as its p ...

#### Array Rotation in java

John Watson knows of an operation called a right circular rotation on an array of integers. One rotation operation moves the last array element to the first position and shifts all remaining elements right one. To test the abilities of Sherlock , Wa ...