Using "java.math.BigInteger" to complete this question is a right way?

  • 0
    import java.math.BigInteger;
    public class PlusOne {
    	public int[] plusOne(int[] digits) {
    		if(digits==null || digits.length==0){
    			return null;
    		StringBuffer sb = new StringBuffer();
    		for(int d : digits){
    		BigInteger bi = new BigInteger(sb.toString());
    		bi=bi.add(new BigInteger("1"));
    		String newIntStr = bi.toString();
    		int[] a = new int[newIntStr.length()];
    		for(int i=0,len=newIntStr.length();i<len;i++){
    		return a;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.