question link
solution link
kindly check why it is throwing error
There is a problem in one leetcode problem please help me out
AddressSanitizer:DEADLYSIGNAL ================================================================= ==31==ERROR: AddressSanitizer: SEGV on unknown address 0x6021da7e24d0 (pc 0x0000003780a9 bp 0x7fff769f8990 sp 0x7fff769f8880 T0) ==31==The signal is caused by a READ memory access. #3 0x7fbc5680f0b2 (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) AddressSanitizer can not provide additional info. ==31==ABORTING this error is coming
yeah …
here is ur updated code->
yeah correct.

a) first of all i and ex will remain same.
b)
we know that from index [ex…n-1] array is sorted in decreasing order right.
so the last element that satisfy the if condition will be our required candidate for swapping