Yes, the recommendation would be to use the child theme.
style.css
/*
Theme Name: My Child Theme
Description: My Child Theme's description
Author: John Doe
Author URI: http://example.com
Template: child-theme
Version: 1.0.0
*/
@import url("../parent-theme/style.css");
Then create a functions.php in child theme.
However, the next part is that you're wanting to replace some code, which should not be done, instead you should remove it's action/filter hook that it has implemented :
remove_action( $tag, $function_to_remove, $priority );
Or if it was added as a filter:
remove_filter( $tag, $function_to_remove, $priority );