Consider the case n=5 and k=12, so in the first iteration we are looking in the set for the value 6+1=7, which should return st.end() and dereferencing it should give a garbage value unless we handle this case. I don't understand how did it get accepted.
@mennaselim4095 ай бұрын
Thanks for this explanation. Do you have any recommendations for improving observation skills?
@jeevanalexen5 ай бұрын
Not really, I have explained how I observed the observations in the problem, it was either by trying to find a pattern or trying to think in terms of how I have solved similar problems previously.
@jeevanalexen5 ай бұрын
We're you able to understand my explanation properly?
@mennaselim4095 ай бұрын
@@jeevanalexen yup I was able to understand your explanation, thanks a lot, but I am not able to make good observation and notice the pattern. is it improved by practice or is there technique to do this?
@jeevanalexen5 ай бұрын
@@mennaselim409it can be improved only by practise.
@deboshrutimukhopadhyay79254 ай бұрын
could you explain why this code is not getting accepted though I went with a similar approach #include using namespace std; #define ll long long int main() { int t; cin >> t; while (t--) { long long n, k; cin >> n >> k; // Check if k is odd if (k % 2 != 0) { cout
@vedanta-xw3se5 ай бұрын
why are u using remain + i + 1 why not just remain
@jeevanalexen5 ай бұрын
Because we are doing val - (i+1) below, there we subtract i+1 from val. So to negate that, we are taking remain + i + 1, so that the subtraction below wont affect it.
@jeevanalexen5 ай бұрын
Please let me know if you need further explanation