Please Help Me To Debug The Code

Problem Link: https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/559/week-1-october-1st-october-7th/3482/

My Solution Link: https://ide.codingblocks.com/s/349224

I am not able to figure out what is the problem with my approach please help me to debug.

i am storing the unique pair in a set of string. the unique pair is represented by a string, where “;” is seperating the two numbers.

Hey @amangoel987357

if(nums[j] - nums[i] == k){
string a;
a=to_string(nums[i]);
a.push_back(’;’);
a+=to_string(nums[j]);
s.insert(a);
}

We can only push characters to string and u were trying to push nums (10^7) in it so that was the issue

to_string convert int to string
a+=b concatenates a & b if both are string

Thanks Kartik. I got it.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.