Overview Of This Week
After two uneventful weeks of University, the course finally started this week and the briefing was set and explained thoroughly. Since there were no tasks set to train for Unreal C++ (like the blueprint fundamentals last year), I decided to brush up on base C++ in the form of questions presented from LeetCode.
LeetCode
Over the course of the week I managed to complete three different questions. The questions completed will be shown below:

Two Sum Problem
First I completed the two sum problem. This involved selecting two numbers within a vector that would add up to a selected number.

The code I ended up completing will be shown below:

I forgot some of the functionalities of the vector class but brushed up on them to figure out this question. The code first goes through the for loop which will check each index until reaching the size of the vector. After gaining the index from the first for loop, it will go through another for loop which will go in reverse order finishing at the index right after the first for loop. It will then check if the two indices if they add up to the target number which will then return the numbers. If no numbers add up to the target number, it will return a null value.
Palindrome Number Problem
The next problem was the palindrome number. This was to check if the number presented was the same backwards. I first tried turning the number into the string but it kept having overflow errors when the number was 11. My theory is that the base 2 system of binary has trouble converting integers into strings within the standard library of C++ This is where I looked at the solutions tab to see how other people solved the problem. I found a very interesting way of checking if the number was a palindrome without switching it into a string:

First you check if the number is less than 0. This is because negative numbers can never be a palindrome due to the negative sign not being translated. the integers would then have to be set to a long long due to there being use of very large numbers. The code then goes into a while loop until the temporary number is not equal to 0. In the while loop, a new variable named digit is created from the temp to the modulus of 10. This was a very interesting discovery for me. This is because the modulus with 10 always gets the rightmost value of any digit. This is due to the fact that the modulus is essentially division with a remainder instead of a decimal number. the reversed variable will then be shifted to the left and then added the digit on the rightmost variable. e.g: 1 will = 10 and then the current digit will be added on (such as 6) making the total sum = 16. This works for the first number ever inputted to the reversed variable because by default it is 0 and 0 * 0 = 0. The temp variable will then divide by 10 to make the variable lose it’s rightmost digit due to integers requiring to be full numbers. After the while loop is finished, it will then return the Boolean of whether the reversed value is equal to the inputted x value.
Roman Numerals Problem
My final problem solved this week was with Roman numerals. The problem required the inputted Roman numeral to be translated into an integer. A lot of my time this week researching rules to Roman numerals to try to implement them into code. The final outcome will be below:



There is a lot to uncover with this code. Simply put, it checks whether the numeral presented is a possible combo value as I like to call it. E.G IV = 4; this requires forethought of looking to the next numeral to know if the value is 4. However, not every Numeral needs to check the next value. It checks for these values and then keeps adding each Numeral value until the very end and then returns the final number.
Extra Things I Have Learnt Or Problems I Have Solved This Week
- Whilst dealing with all the problems I completely forgot how to deal with vectors among other things within C++. This is where I read a book by the name of C++ Primer 5th edition to understand the libraries held within the coding language which helped me tackle all these questions.
Plans For Next Week
After completing a few problems, I started to realise that I was hitting a roadblock within my coding that required more knowledge of standard libraries. However, Unreal C++ uses libraries built into the engine and disregards the standard library most of the time. This means that for next week I will have to teach myself the basics to Unreal C++.