return-1; // II) Find the smallest digit on right side of (i-1)'th // digit that is greater than number[i-1] intx = number[i-1], smallest = i; for(j = i+1; j < number.length; j++) if(number[j] > x && number[j] <= number[smallest]) smallest = j; // III) Swa...
hence size of torch.Size([])). If you want to assign anything to it, the right hand side can only be a scalar. That is not the case, as one of the terms is a tensor with 1 dimension (a vector), namely your maxq[j].
Solution Code: publicclassSolution{publicintnextGreaterElement(int n){char[]number=(n+"").toCharArray();int i,j;// I) Start from the right most digit and// find the first digit that is// smaller than the digit next to it.for(i=number.length-1;i>0;i--){if(number[i-1]<number[...
classSolution{publicintnextGreaterElement(intn){char[]digits=Integer.toString(n).toCharArray();intlen=digits.length;// I) Start from the right most digit and// find the first digit that is// smaller than the digit next to it.inti=len-1;while(i>0&&digits[i-1]>=digits[i]){--i;}/...