Array-target sum pairs


Help to resolve no output

Hello @Yukta,

  1. Assign i=0 before while loop
    Reason:
    You have altered it’s vale to n in the input loop

  2. Conditional expression of first for loop inside the while loop is wrong:
    Modification:
    i<n

  3. The logic you have applied has higher time complexity and would not account for all cases.
    Reason:
    For i=0;
    inner for loop will iterate from j=0 to j=n-1 and would terminate with j=n
    For i=2 to n-1,
    inner loop will not execute as j=n

I have modified your code:

Hope, this would help.
Give a like, if you are satisfied.

1 Like