problem statement : https://online.codingblocks.com/app/player/49396/content/53525/4801/code-challenge
my code : https://ide.codingblocks.com/s/196480
for test case : 5
5
4
3
4
5
It should say false but CB says true.
problem statement : https://online.codingblocks.com/app/player/49396/content/53525/4801/code-challenge
my code : https://ide.codingblocks.com/s/196480
for test case : 5
5
4
3
4
5
It should say false but CB says true.
@prateek_5 you are doing this in n^2 it can be done in n. We just need to check the immediate surrounding.
Keep moving forward till the new number encountered is smaller then the previous. As soon as a number larger or equal to previous is encountered move to next condition and check if encountered number is larger than previous . if we reach end answer is true else answer is false.
If this solves your doubt mark it as resolved.
this is my code : https://ide.codingblocks.com/s/196659 and it works.
I have used just one while loop here, why will my complexity be N^2 ?
KINDLY SUGGEST SOME WAY TO OPTIMIZE MY CODE.
@prateek_5 you are using wrong logic you are counting the length of sub-sequence and then comparing them, which is wrong.
I have described the approach above.
You can refer this code.
if this helps mark it as resolved.
It is mentioned there in problem not to use array,
@prateek_5 the above approach can be easily converted for using only 2 variable instead of array.
I have made the changes. If this solves your doubt mark it as resolved.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.