Coding
Coding
Creating Potygon
Input Format:
The input conssts of two lines
. The first line consists dt a single irteger denoting n.
The second line consists of n space-separated integers denoting the
array sides
The input will be read from the STDIN by the candidate
Output Format:
Print the perimeter of the polygon otherwise print -1.
The output will be matched to the candidate's output printed on the
STDOUT
01. Sub-sequence Problem
Problem Statement Now let's start coding :
You are given an array arr of size N, your task is to re-order the
array and find the length of the longest increasing sub-sequence Language: Python 3.10
from that re-ordered array and print the same as the output. 1 naint (input())
2 arr=[]
A sub-sequence of a given sequence is a sequence that can be 3 for _ in range (n):
derived from the given sequence by deleting some or no elements 4 "arr. append (int (input ()))
without changing the order of the remaining elements. 5 arr.sort ()
6 print(l en(set(arr) ))
Input Format:
The input is in the foilowing format:
. The first line contains N, denoting the number of elements
in the array arr
Output Format:
Print the maximum index difference 1-k.
The output will be matched to the candidate's output
printed on the STDOUT
01. String Conversion
1.
Problem Statement Now let's start coding:
string X into
You are given a string X. Your task s to convert the Language: Python 3.10 v
string Y such that Y represents the minimum possible number
the characters of X with 1 x=input ()
that can be formed from X by replacing
(9 the value of the character to be replaced), i.e. you can
3 if x[ej="9" :
replace a character d in X with (9 - d) in Y -if int(x[e])>m5:
5 -y*wstr(9-int(x[e]))
Note: -else:
The string should not start with a zero and the transformed string 7 "y+*str(int(x[e]))
Y must have the same number of characters as X. 8 else:
-y+zstr(int (x [e)))
Input Format: 10 for i in range(1,len(*)):
The input consist of a single line: 11 if int(x[il)>m5 :
The line contains a string X. 12 *y+zstr(9-int(x[i]))
.
-else:
The input will be read from the STDIN by the candidate.
13
14 y+mx[i ]
15 print (y)
Output Format:
Print the string Y such that Y represents the minimum possible
number that can be formed from X.
The output will be matched to the candidate's output
printed on the STDOUT.
Constraints: