Faulty Keyboard Codevita 9 Solution
Mr. Wick has a faulty keyboard. Some of the keys of the keyboard don’t work. So he has copied all those characters corresponding to the faulty keys on a clipboard. Whenever those characters need to be typed he pastes it from the clipboard. In typing whatever is required he needs to make use of paste, backspace and cursor traversal operations. Help him in minimize the number of operations he needs to do to complete his typing assignment. Each operation has one unit weightage.
Constraints
- 1 <= S <= 16
- 1 <= T<= 10^4
String T and S will only be comprised of letters a-z and digits 0-9
Input
- First line contains text T to be typed Second line contains string S of all the faulty keys pasted on clipboard
Output
- Print the minimum number of operations required for typing the text T
Time Limit
1
Examples:
Example 1
Input
experience was ultimate
ew
Output
14
Explanation
- experience =(2+2+2+2) =[ {p+b} + {p+b} +{p+b} +{p+b} ]
- was=(4)=[ p+m+b+m]
- ultimate=(2)=[ p+b ]
- where p=paste, b=backspace ,m= move cursor
Example 2
Input
supreme court is the highest judicial court
su
Output
17
Explanation
- supreme =(1) =[ p]
- court=(4)=[ p+m+b+m]
- is=(2)=[ p+b ]
- the=(0)
- highest=(2)=[p+b]
- judicial=(4)=[p+m+b+m]
- court=(4)=[p+m+b+m]
SOLUTION
Program: Faulty Keyboard Codevita 9 Solution in python
p=input("")
q=input("")
s=""
p1=list(p.split(" "))
q1=list(q.split(" "))
for t in range(0,len(q1)-1):
c=[0 for i in range(t,len(q1))]
for i in p1:
for j in range(len(q1)):
k1=0
while(k1):
m2=c.index(m1)
for i in range(m2,len(c)):
if(c[i]==m1):
if(ord(q1[i])<ord(q1[m2])):
m2=i
else:
m2=c.index(m1)
q1[m2],q1[t]=q1[t],q1[m2]
s+=q1[0]
print(len(s))
Codevita Season 9 All Questions Solution
- Even Odd Codevita 9 Solution
- Largest Gold Ingot Codevita 9 Solution
- Fill the Cube Codevita 9 Solution
- Logic for Single Lane Highway Codevita 9
- Faulty Keyboard Codevita 9 Solution 2020
- Signal Connection Codevita 9 Solution 2020
- Closing Value Codevita 9 Solution
- CodeVita season 9 Zone 2 All Solutions
- Railway Station Codevita 9 Solution
- Count Pairs Codevita 9 Solution
- 7 X 7 Codevita 9 Solution
- Tennis Score codevita 9 Solution
- Unlocker Codevita 9 Solution
- Path through graph Codevita 9 Solution
- Secret Word Codevita 9 Solution
- 3 Palindrome Codevita 9 Solution
- Max Sum Codevita 9 Solution
- Equalize Weights Codevita 9 Solution
- Binary Equivalent Codevita 9 Solution
- String Word Codevita 9 Solution
- 4 Particles Codevita 9 Solution
- String Pair Codevita 9 Solution
- Corona Virus Codevita 9 Solutions
- Factor of 3 Codevita 9 Solutions
- Single Lane Highway Codevita 9 Solution