TCS digital coding problems and solutions 2022-2023

TCS Digital Coding Problem -2


 Problem Description -:  Given two non-negative integers n1 and n2

For example:

Suppose n1=11 and n2=15.

There is the number 11, which has repeated digits, but 12, 13, 14 and 15 have no repeated digits. So, the output is 4.

Example1:

Input:

  • 11 — Vlaue of n1
  • 15 — value of n2

Output:

  • 4

Example 2:

Input:

  • 101 — value of n1
  • 200 — value of n2

Output:

  • 72
Python -

n1=int(input())
n2=int(input())
l=[]
c=0
for i in range(n1,n2+1):
    while i!=0:
        r=i%10
        l.append(r)
        i=i//10
    if not(len(set(l))<len(l)):
        c+=1
    l.clear()
    
print(c)
    


Comments

Popular posts from this blog

Create account in java |deposit money|withdraw money

Library Management System in python OOPs Concept

List comprehension hackerrank solution in python