Computers and Technology, 17.08.2020 01:01 Paigex3
You are given an array of integers a. A new array b is generated by rearranging the elements of a in the following way:
b[0] is equal to a[0];
b[1] is equal to the last element of a;
b[2] is equal to a[1];
b[3] is equal to the second-last element of a;
and so on.
Your task is to determine whether the new array b is sorted in strictly ascending order or not.
Example
For a = [1, 3, 5, 6, 4, 2], the output should be alternatingSort(a) = true.
The new array b will look like [1, 2, 3, 4, 5, 6], which is in strictly ascending order, so the answer is true.
For a = [1, 4, 5, 6, 3], the output should be alternatingSort(a) = false.
The new array b will look like [1, 3, 4, 6, 5], which is not in strictly ascending order, so the answer is false.
Input/Output
[execution time limit] 3 seconds (java)
[input] array. integer a
The given array of integers.
Guaranteed constraints:
1 ≤ a. length ≤ 105,
-109 ≤ a[i] ≤ 109.
[output] boolean
A boolean representing whether the new array bwill be sorted in strictly ascending order or not.
Answers: 1
Computers and Technology, 22.06.2019 14:30
Complete the sentence based on your knowledge of the professional difficulties faced by music artists. digital technology allows audiences to see free live telecasts of music or dance performances through
Answers: 1
Computers and Technology, 22.06.2019 23:00
In which part of a professional email should you try to be brief, but highly descriptive?
Answers: 1
Computers and Technology, 23.06.2019 18:40
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
You are given an array of integers a. A new array b is generated by rearranging the elements of a in...
Mathematics, 05.11.2020 17:50
Biology, 05.11.2020 17:50
Mathematics, 05.11.2020 17:50
Social Studies, 05.11.2020 17:50
Mathematics, 05.11.2020 17:50
Mathematics, 05.11.2020 17:50
Health, 05.11.2020 17:50
Mathematics, 05.11.2020 17:50
Mathematics, 05.11.2020 17:50
Geography, 05.11.2020 17:50
Business, 05.11.2020 17:50