PYTHON BASIC PROBLEMS SOLUTIONS(HACKERRANK) Day-12 LEARN CODING EASILY. HOW TO BE GOOD PROGRAMMER? смотреть онлайн
Hello, Young Coders our channel will give you Hackerrank solutions.It will be very useful for you Kindly make use of it..You will be know how the format strings work in python and What is use of these format specifiers.If you face this situation you can use format function to get the result.
These Hackerrank solutions will be very useful for you.
Thanks for watching.
PROBLEM SOLVED IN THIS LECTURE::
PROBLEM LINK: https://www.hackerrank.com/challenges/python- lists/problem?isFullScreen=true
Consider a list (list = []). You can perform the following commands:
1. insert i e: Insert integer e at position .i
2 print: Print the list.
3. remove e: Delete the first occurrence of integer e .
4. append e: Insert integer c at the end of the list.
5. sort: Sort the list.
6. pop: Pop the last element from the list.
7. reverse: Reverse the list.
Initialize your list and read in the value of n followed by n lines of commands where each command will be of the 7 types listed above. Iterate through each command in order and perform the corresponding operation on your list.
EXAMPLE:
N=4
append 1
append 2
insert 3 1
print
1. append 1: Append 1 to the list, arr[1]
2: append 2 : Append 2 to the list, arr[1,2]
3. insert 3 1 : Insert 3at index 1 arr=[1,3,2] .
4 print: Print the array
.
Output:
[1, 3, 2]
INPUT FORMAT:
The first line contains an integer, n, denoting the number of commands.
Each line i of the n subsequent lines contains one of the commands described above.
CONSTRAINTS:
The elements added to the list must be integers.
Output Format
For each command of type print, print the list on a new line.
SAMPLE INPUT 0:
12
insert 0 5
insert 1 10
insert 0 6
print
remove 6
append 9
append 1
sort
print
pop
reverse
print
SAMPLE OUTPUT: 0
[6, 5, 10]
[1, 5, 9, 10]
[9, 5, 1]
SOLUTION:
if __name__ == '__main__':
N = int(input())
m=list()
for i in range(N):
s=input().strip().split(" ")
if(s[0]=="insert"):
m.insert(int(s[1]),int(s[2]))
if(s[0]=="print"):
print(m)
if(s[0]=="remove"):
m.remove(int(s[1]))
if(s[0] == "append"):
m.append(int(s[1]))
if(s[0] == "sort"):
m.sort()
if(s[0] == "pop"):
m.pop()
if(s[0] == "reverse"):
m.reverse()
See the Video again to conform whether this solution will work or not.
Again Thanks for watching this video.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «PYTHON BASIC PROBLEMS SOLUTIONS(HACKERRANK) Day-12 LEARN CODING EASILY. HOW TO BE GOOD PROGRAMMER?» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.