0% found this document useful (0 votes)
39 views

Competitive Coding: January 23, 2021

The document discusses competitive coding challenges involving array rotations and Barua numbers. It provides an example of printing the contents of an array after k left rotations in O(n) time using modulo. It then defines Barua numbers as those containing only 1s and 0s, starting with 1, and having at most one decimal place, and provides some examples.

Uploaded by

suryansh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Competitive Coding: January 23, 2021

The document discusses competitive coding challenges involving array rotations and Barua numbers. It provides an example of printing the contents of an array after k left rotations in O(n) time using modulo. It then defines Barua numbers as those containing only 1s and 0s, starting with 1, and having at most one decimal place, and provides some examples.

Uploaded by

suryansh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Competitive Coding

January 23, 2021

[9, 6, 5, 0, 8, 2]
Print the array content after ’k’ rotations towards left in O(n).

[5]: a = [int(i) for i in input('Enter values: ').split()]


k = int(input("Enter no of left rotations: "))
n = len(a)

# for i in range(k % n, n):


# print(a[i], end = " ")
# for i in range(0, k % n):
# print(a[i], end = " ")

print(a[k % n: ] + a[0 : k % n])

Enter values: 9 6 5 0 8 2
Enter no of left rotations: 3
[0, 8, 2, 9, 6, 5]
Barua Numbers
- Contains only 1 or 0 - Contains only one 1 and any no of 0’s - it must start with 1
1, 10, 1000, 100000, 1000000000000, 100000000000000000000000000000
There can be only one decimal number 13400000000000000
Result: 10000000 X 1350000 = 135000000000000
[ ]:

You might also like