Find all positive integers $n$ such that equation $$3a^2-b^2=2018^n$$ has a solution in integers $a$ and $b$.
To find all positive integers \( n \) such that the equation 
\[ 3a^2 - b^2 = 2018^n \]
has a solution in integers \( a \) and \( b \), we will consider the parity of \( n \).

1. **Case 1: \( n \) is odd.**
   - Let \( n = 2m + 1 \) for some positive integer \( m \).
   - We need to find integers \( a \) and \( b \) such that:
     \[ 3a^2 - b^2 = 2018^{2m+1} \]
   - Consider the solution \( (a, b) = (27 \times 2018^m, 13 \times 2018^m) \).
   - Substitute \( a = 27 \times 2018^m \) and \( b = 13 \times 2018^m \) into the equation:
     \[
     3(27 \times 2018^m)^2 - (13 \times 2018^m)^2 = 3 \cdot 729 \cdot 2018^{2m} - 169 \cdot 2018^{2m}
     \]
     \[
     = 2187 \cdot 2018^{2m} - 169 \cdot 2018^{2m}
     \]
     \[
     = (2187 - 169) \cdot 2018^{2m}
     \]
     \[
     = 2018 \cdot 2018^{2m}
     \]
     \[
     = 2018^{2m+1}
     \]
   - Thus, the solution \( (a, b) = (27 \times 2018^m, 13 \times 2018^m) \) works, and there exists a solution for all odd \( n \).

2. **Case 2: \( n \) is even.**
   - Let \( n = 2m \) for some positive integer \( m \).
   - Consider the equation modulo 3:
     \[
     3a^2 - b^2 \equiv 2018^{2m} \pmod{3}
     \]
   - Since \( 2018 \equiv 2 \pmod{3} \), we have:
     \[
     2018^{2m} \equiv 2^{2m} \equiv 1 \pmod{3}
     \]
   - Therefore, the equation becomes:
     \[
     3a^2 - b^2 \equiv 1 \pmod{3}
     \]
   - Note that \( 3a^2 \equiv 0 \pmod{3} \), so:
     \[
     -b^2 \equiv 1 \pmod{3}
     \]
     \[
     b^2 \equiv -1 \pmod{3}
     \]
   - However, the quadratic residues modulo 3 are 0 and 1. There is no integer \( b \) such that \( b^2 \equiv -1 \pmod{3} \).
   - Hence, there are no solutions for even \( n \).

Conclusion:
The equation \( 3a^2 - b^2 = 2018^n \) has integer solutions \( (a, b) \) if and only if \( n \) is odd.

The final answer is \( \boxed{ n } \) is odd.