dp in java, c++ , objective-c and rust