1038. Print X N numbers of times

Given two integers X and N, print the value X on the screen N times.

  • Separate each number by a single space.
  • Do not add a space after the last number.
  • After printing all N numbers, move to the next line.
  • If N = 0, still move to the next line (print an empty line).

Example 1:

Input: X = 7, N = 5

Output: 7 7 7 7 7

Example 2:

Input: X = 15, N = 1

Output: 15

Now Your Turn!

Pick the correct output for the given input

Input: X = -5, N = 4

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • -100 <= X <= 100
  • 0 <= N <= 100
0
class Solution {
public:
void printX(int X, int N) {
 
}
};
Test Case

Input:

N
X