public boolean solutionA(int[] A) {
        // write your code in Java SE 8
        if (A.length <= 1) return true;
        int wrongPos = -1;
        int swapPos = -1;

        for (int i = 1; i < A.length; i++) {
            // look for first wrong pos
            if (wrongPos < 0) {
                if (A[i] < A[i -1]) {
                    wrongPos = i - 1;
                }
            } else {
                // looking for swap position
                if (A[i] > A[wrongPos]) {
                    swapPos = i - 1;
                    break;
                }
                swapPos = i;
            }
        }

        // if wrongPos and swapPos is valid, swap
        if (wrongPos >= 0 && swapPos >= 0)
            swap(A, wrongPos, swapPos);

        // validate if the array is sorted after swap.
        for (int i = 1; i < A.length; i++) {
            if (A[i] < A[i -1]) {
                return false;
            }
        }
        return true;
    }