I'm solving an exercise on leetcode which is to write a solution that takes strings of variable length and returns a modified version of them. In the course of my code, I want to use if
statements with conditionals like if (my_string[i+j]==my_string[i-j])
. But my_string[i+j]
may cause an out of range error.
Is it good practice to do this, if you as the coder want an exception to evaluate to false
?
Aucun commentaire:
Enregistrer un commentaire