Hello everyone, I know it has been a while, but here is my first attempt at coding using C++, which I have recently decided to take up. Its time to revisit the first ever problem solution which I have posted on this blog, except this time I use C++ instead of Java:
This question, as it can be seen, is quite simple. Given the array nums, and integer target, the easiest way to solve this problem should be pretty apparent, and that is to just check every combination of indices until you have a sum that adds to target, and that is exactly what I did:
Note: I made the int j = i +1, and not just 0, because j and i cannot be the same
As you can see, C++ has a very similar syntax to that of Java, therefore it is a lot easier for me to pick it up due to my somewhat extensive knowledge of Java.
When I ran this method, it indeed gave the expected result:
Results:
Overall, not bad for my first time coding using C++. I am proud of what I have done so far, but I know that I have a long way to go. I plan on using more C++ in future blog entries, in order to help me grow my skills.
That is all from me for now. I know it has been a while, but I will get back to posting more regularly. I hope you guys at least learned something today, and that you all have a great day!