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, G6xeY5 - Online C++0x Compiler & Debugging Tool - Ideone.com 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 ++){

Edit:

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:

2 Likes

Thankssss, so dumb :sob:

1 Like

https://www.codechef.com/viewsolution/28600836

Thanks again for your suggestion !!!

1 Like