public String solve(String s, String t) {
BigInteger s1 = new BigInteger(s);
BigInteger t1 = new BigInteger(t);
return s1.add(t1).toString();
}
特别简单就是单纯的使用BigInterger 来进行加法,这个类里面已经实现了题目的过程就是时间复杂度比较高;
反正就是我第一次看到这个题目想到了解法!不过时间复杂度太高了,之后应该会有优化。

京公网安备 11010502036488号