harshit2202's blog

By harshit2202, history, 5 years ago, In English

I have been doing this code Code Link

Problem is that when I iterating over keys to sort their vector, then sorting is not working properly. Test Case:- 3 4 3 4 3 3 3 7 5 5 1 1 5 3 3 3 7 3 4 1 5 5 3 1 5 3

Input is n and m, then two matrices of n*m

Any idea why? Thanks in advance:)

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by harshit2202 (previous revision, new revision, compare).

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by harshit2202 (previous revision, new revision, compare).

»
5 years ago, # |
Rev. 2   Vote: I like it +12 Vote: I do not like it

You are not passing reference while sorting. Pass it by reference like this.

    for(auto &it:m1)        sort(all(it.second));
    for(auto &it:m2)        sort(all(it.second));