JOHNY - Editorial

My code keeps giving me either SIGSEGV or SIGEMT error, when I checked other people’s submitted code - I found that majority had the same algorithm, and their code got successfully submitted, why is that?

Can somebody pls help

If you’re referring to e.g. this, let’s see what clang has to say about it:

[simon@simon-laptop][16:41:52]
[~/devel/hackerrank/otherpeoples]>clang++ -std=c++14 -stdlib=libc++ darshpatel-JOHNY.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_LIBCPP_DEBUG=1
darshpatel-JOHNY.cpp:10:18: warning: variable 'n' is uninitialized when used here [-Wuninitialized]
            int n, k, a[n];
                        ^
darshpatel-JOHNY.cpp:10:11: note: initialize the variable 'n' to silence this warning
            int n, k, a[n];
                 ^
                  = 0
1 warning generated.

(gcc doesn’t report the warning, for some reason).

1 Like

Thank you so much for the help, appreciate it.

1 Like