The inverse also has a constant $a$ on the main diagonal and $b$ everywhere else. The constants do depend on the matrix size $n;$ as noted, for $n=2$ there is no inverse. Just try the thing for $n=3$ and $n=4$ and $n=5.$ By that time you should have it, for $n \geq 3$
for $n=3:$
$$
\left(
\begin{array}{rrr}
-1 & 1&1 \\
1 & -1&1 \\
1 & 1&-1 \\
\end{array}
\right)
\left(
\begin{array}{ccc}
a & b&b \\
b & a&b \\
b & b&a \\
\end{array}
\right)=
\left(
\begin{array}{rrr}
1 & 0&0 \\
0 & 1&0 \\
0 & 0&1 \\
\end{array}
\right)
$$
for $n=4,$ different $a,b:$
$$
\left(
\begin{array}{rrrr}
-1 & 1&1&1 \\
1 & -1&1&1 \\
1 & 1&-1&1 \\
1 & 1&1&-1 \\
\end{array}
\right)
\left(
\begin{array}{cccc}
a & b&b&b \\
b & a&b&b \\
b & b&a&b \\
b & b&b&a \\
\end{array}
\right)=
\left(
\begin{array}{rrrr}
1 & 0&0&0 \\
0 & 1&0&0 \\
0 & 0&1&0 \\
0 & 0&0&1 \\
\end{array}
\right)
$$
for $n=5,$ still different $a,b:$
$$
\left(
\begin{array}{rrrrr}
-1 & 1&1&1&1 \\
1 & -1&1&1&1 \\
1 & 1&-1&1&1 \\
1 & 1&1&-1&1 \\
1&1&1&1&-1 \\
\end{array}
\right)
\left(
\begin{array}{ccccc}
a & b&b&b &b\\
b & a&b&b&b \\
b & b&a&b &b \\
b & b&b&a &b \\
b&b&b&b&a \\
\end{array}
\right)=
\left(
\begin{array}{rrrrr}
1 & 0&0&0 &0 \\
0 & 1&0&0&0 \\
0 & 0&1&0 &0 \\
0 & 0&0&1 &0 \\
0&0&0&0&1
\end{array}
\right)
$$