You implemented binary lifting in a class structure, which is common in interview settings. You handled the sentinel value for invalid ancestors.
You also saw how the same technique works in both competitive programming and LeetCode-style problems. The core idea is identical. If you can implement this class, you understand binary lifting. Practice writing it from memory until you can code it in under minutes.