Algorithm Problems using java

  1. Given an array arr[] of N distinct integers, check if this array is Sorted and Rotated clockwise.
    A sorted array is not considered as sorted and rotated, i.e., there should be at least one rotation.

Note:-Array can be sorted both increasingly and decreasingly


The first line of input contains number of testcases T. Each testcase contains 2 lines, the first line contains N, the number of elements in array, and second line contains N space separated elements of array.

1 <= T <= 50
3 <= N <= 10^3
1 <= A[i] <= 10^4


Print “Yes” if the given array is sorted and rotated, else Print “No”, without Inverted commas.


Sample Input:
3 4 1 2
1 3 2

Sample Output:

  1. Given an integer K, find a positive integer x such that K = x2 + 3*x. If no such positive integer x exists, print -1.


First and the only line of the input contains an integer K.

1 <= K <= 1018


Print a positive integer x such that the above equation satisfies. If no such integer x exists, print -1.

1 Like

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

1 Like

For some questions I am not able to build logic or I fail to get the proper way to solve them.

If you are unable to write any code, then you will at least need to attempt to right out an algorithm in pseudo-code.

If you do not understand the instructions of a problem, you can ask for clarification.

1 Like