C++ Unexpected Behaviour in code

@ssjgz I really need your help on this one, have been stuck for a long time not able to figure out why the code shows unexpected behavior.

So, I am basically coding a solution for this question - Indraneels Experiment

Here is the code I wrote, https://ideone.com/G6xeY5 I commented out a lot of it because it was anyways not working out. Can anybody figure out why this is happening >? Is there anything undeclared?

EDIT: I am basically executing LCS by increasing values of an array by an arbitrary value

1 Like
    int mx = -INF;
    int diff = 0;
    bool cond = 0;
    for (int i = 0 ; i<= 1001 /* Out of bounds access when i == 1001!*/ ; i ++){


Part of the reason why I always use vectors instead of C-style arrays - I think the “WA in ___” threads would halve in frequency if people just adopted this simple rule (in conjunction with using the relevant C++ Standard Library “debug mode” flags) :slight_smile:


Thankssss, so dumb :sob:

1 Like


Thanks again for your suggestion !!!

1 Like