For the particular case \(G = \mathbb {Z}\)  (where the additive notation
\(x_1 \cdot g_1 + \cdots + x_k \cdot g_k = g\)  is usually preferred)
these problems are NP-complete if the numbers \(g_1, \ldots , g_k,g\)  are
encoded in binary representation. For subset sum, this is a classical result from Karp's seminal paper [1]} on
NP-completeness. Knapsack for integers is usually formulated in a more general form in the literature;
NP-completeness of the above form (for binary encoded integers) was shown in [2]}, where
the problem was called multisubset sum.Note that if we ask for a solution \((x_1,\ldots , x_k)\) 
in \(\mathbb {Z}^k\) , then knapsack can be solved in polynomial time (even for binary encoded integers) by checking whether
\(\mathrm {gcd}(g_1, \ldots , g_k)\)  divides \(g\) .
Interestingly, if we consider subset sum for the group
\(G = \mathbb {Z}\) , but encode the input numbers \(g_1, \ldots , g_k, g\) 
in unary notation, then the problem is in DLOGTIME-uniform
\(\mathsf {TC}^0\)  (a small subclass of polynomial time and even of logarithmic space that captures the complexity
of multiplication of binary encoded numbers; see e.g.
the book [3]} for more details) [4]}, and
the same holds for knapsack (see thm-TC0). Related results can be found in
[5]}.
