File tree 3 files changed +70
-0
lines changed
3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Given an integer array A of size n. Find and print all the leaders present in the input array.
2
+ # An array element A[i] is called Leader, if all the elements following it (i.e. present at its right) are less than or equal to A[i].
3
+ # Print all the leader elements separated by space and in the same order they are present in the input array.
4
+
5
+ # Sample Input 1 :
6
+ # 6
7
+ # 3 12 34 2 0 -1
8
+ # Sample Output 1 :
9
+ # 34 2 0 -1
10
+
11
+ ## Read input as specified in the question.
12
+ ## Print output as specified in the question.
13
+
14
+ n = int (input ())
15
+ arr = list (map (int , input ().split ()))
16
+ ma = arr [- 1 ]
17
+ arr = arr [::- 1 ]
18
+ k = [arr [0 ]]
19
+ for i in range (1 , n ):
20
+ if arr [i ] >= ma :
21
+ ma = arr [i ]
22
+ k .append (arr [i ])
23
+ k = k [::- 1 ]
24
+ print (* k )
Original file line number Diff line number Diff line change
1
+ # Given a string S (that can contain multiple words), you need to find the word which has minimum length.
2
+ # Note : If multiple words are of same length, then answer will be first minimum length word in the string.
3
+ # Words are seperated by single space only.
4
+
5
+ # Sample Input 1 :
6
+ # this is test string
7
+ # Sample Output 1 :
8
+ # is
9
+
10
+ ## Read input as specified in the question.
11
+ ## Print output as specified in the question.
12
+
13
+ s = input ().split ()
14
+ l = []
15
+ for i in s :
16
+ l .append (len (i ))
17
+ print (s [l .index (min (l ))])
Original file line number Diff line number Diff line change
1
+ # Given a 2D integer array with n rows and m columns. Print the 0th row from input n times, 1st row n-1 times…..(n-1)th row will be printed 1 time.
2
+ # Input format :
3
+ # Line 1 : No of rows (n) and no of columns (m) (separated by single space)
4
+ # Line 2 : Row 1 elements (separated by space)
5
+ # Line 3 : Row 2 elements (separated by space)
6
+ # Line 4 : and so on
7
+ # Sample Input 1:
8
+ # 3 3
9
+ # 1 2 3
10
+ # 4 5 6
11
+ # 7 8 9
12
+ # Sample Output 1 :
13
+ # 1 2 3
14
+ # 1 2 3
15
+ # 1 2 3
16
+ # 4 5 6
17
+ # 4 5 6
18
+ # 7 8 9
19
+
20
+ from os import *
21
+ from sys import *
22
+ from collections import *
23
+ from math import *
24
+
25
+ n , m = map (int , input ().split ())
26
+ for i in range (n ):
27
+ a = list (map (int , input ().split ()))
28
+ for j in range (n - i ):
29
+ print (* a )
You can’t perform that action at this time.
0 commit comments