There is a similar question here, but it's asking that if two matrices have the same characteristic polynomial then are they similar. If the answer were positive then the answer to my question will also be positive, but it's not.
Now, if two matrices have the same characteristic polynomial then they are of the same order. Suppose $A$ and $B$ are matrices of order 2 and they both have a characteristic polynomial of $t^2+at+b$. We know that $t^2+at+b=t^2-\text{trace}(A)t+\text{det}(A)=t^2-\text{trace}(B)t+\text{det}(B)$, so in this case the answer to my question is affirmative.
However, I don't think the answer is "yes" in general because then I probably will have a theorem which says this in my book. I looked for counterexamples but couldn't find any. Basically, I made up random matrices and never got a counterexample. So if the answer to the question is "no", can you please explain how you arrived at the counterexample.