An array a is called beautiful if for every pair of numbers ai, aj, (i ≠ j). There does not exist any pair in the first place, and for a n==1, we cannot have i!=j. So wouldn’t the default answer for n==1 be “Not Beautiful”.
Didn’t mean to shock you but kindly look into this.
An application of some definition should work in this way, take the definition, apply on your object (in this case array), if it violates the conditions, then the array is bad, otherwise it is good. Now, our example for n = 1, there are no two i, j such that i != j, so the array is good implicitly. This type of statements are called vacuously true.
2 Likes
Okay, thank you. Perfectly fine
You can refer to my answer above
Yeah!Thanks.
CodeChef: Practical coding for everyone the code is readable and logic is surely easy to understand.
1 Like
For n=1, array is beautiful. AFter accounting for this, you will get TLE. Make some observations on when an array can be beautiful. Take an array of-
only 0,
0 and 1
0,1 and >=2 elements with abs(arr[i])>1
These 3 will give you a direction to think.
1 Like