You are on page 1of 1

k = 9

n = 3
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]

# Create an empty n x n matrix


matrix = [[0 for j in range(n)] for i in range(n)]

# Fill the matrix with the elements from the list


for i in range(n):
for j in range(n):
index = i * n + j
if index < k:
matrix[i][j] = lst[index]
#include<bits/stdc++.h>
using namespace std;

int find(int n1, int n2) {


int count = 0;
for (int i = n1 ; i <= n2 ; i++) {
int num = i;

vector<bool> visited;
visited.assign(10, false);

while (num > 0) {


if (visited[num % 10] == true)
break;
visited[num % 10] = true;
num /= 10;
}

if (num == 0)
count++;
}
return count;
}

int main()
{
int n1 = 101, n2 = 200;
cout << find(n1, n2);
}

You might also like