SAP interview question

Leetcode DP question, and some concepts about OOP, JVM, dynamic memory allocation.