Skip to content
the poor coder

Home / Topics / #hackerrank

#Hackerrank

419 posts · page 19 of 21
2020

Hackerrank - Mod Divmod - Solution

One of the built-in functions of Python is divmod, which takes two arguments and and returns a tuple containing the quotient of first and then the remainder .

Hackerrank1 min read
2020

Hackerrank- Find a string Solution

In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to…

Hackerrank1 min read
2020

Hackerrank - Company Logo Solution

A newly opened multinational brand has decided to base their company logo on the three most common characters in the company name. They are now trying out various combinations of company names and logos based on this…

Hackerrank1 min read
2020

Hackerrank Piling Up! Solution

There is a horizontal row of N cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile should follow these directions: if is on top of then .

Hackerrank1 min read
2020

Hackerrank Collections Deque Solution

collections.deque() A deque is a double-ended queue. It can be used to add or remove elements from both ends. Deques support thread safe, memory efficient appends and pops from either side of the deque with…

Hackerrank2 min read
2020

Hackerrank OrderedDict solution

collections.OrderedDict An OrderedDict is a dictionary that remembers the order of the keys that were inserted first. If a new entry overwrites an existing entry, the original insertion position is left unchanged…

Hackerrank2 min read
2020

Hackerrank namedtuple solution

collections.namedtuple() Basically, namedtuples are easy to create, lightweight object types. They turn tuples into convenient containers for simple tasks. With namedtuples, you don’t have to use integer indices for…

Hackerrank2 min read
2020

Hackerrank - Defaultdict Solution

The defaultdict tool is a container in the collections class of Python. It's similar to the usual dictionary (dict) container, but the only difference is that a defaultdict will have a default value if that key has not…

Hackerrank2 min read
2020

Hackerrank Collections Counter Solution

collections.Counter() A counter is a container that stores elements as dictionary keys, and their counts are stored as dictionary values. Sample Code Task is a shoe shop owner. His shop has number of shoes. He has a…

Hackerrank2 min read
2020

Hackerrank - Compress the String! Solution

In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools . To read more about this function, Check this out . You are given a string . Suppose a character '' occurs…

Hackerrank1 min read
2020

Hackerrank - Matrix Script Solution

Neo has a complex matrix script. The matrix script is a X grid of strings. It consists of alphanumeric characters, spaces and symbols (!,@,#,$,%,&). To decode the script, Neo needs to read each column and select only…

Hackerrank1 min read
2020

Hackerrank - Text Alignment Solution

In Python, a string of text can be aligned left, right and center. .ljust(width) This method returns a left aligned string of length width. .center(width) This method returns a centered string of length width…

Hackerrank2 min read
2020

Hackerrank Combination With Replacement Solution

itertools.combinations_with_replacement(iterable, r) This tool returns length subsequences of elements from the input iterable allowing individual elements to be repeated more than once. Combinations are emitted in…

Hackerrank1 min read
2020

Hackerrank -itertools.combinations() Solution

itertools.combinations(iterable, r) This tool returns the length subsequences of elements from the input iterable. Combinations are emitted in lexicographic sorted order. So, if the input iterable is sorted, the…

Hackerrank1 min read
2020

Hackerrank - itertools.product() Solution

itertools.product() This tool computes the cartesian product of input iterables. It is equivalent to nested for-loops. For example, product(A, B) returns the same as ((x,y) for x in A for y in B). Sample Code Task You…

Hackerrank2 min read
2020

Hackerrank - Designer Door Mat Solution

Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications: Mat size must be X. ( is an odd natural number, and is times .) The design should have…

Hackerrank2 min read
2020

Hackerrank - Alphabet Rangoli

You are given an integer, . Your task is to print an alphabet rangoli of size . (Rangoli is a form of Indian folk art based on creation of patterns.) Different sizes of alphabet rangoli are shown below: The center of…

ESC