Two Sum Algorithm Javascript Substring Function In C