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 .
Hackerrank - Triangle Quest Solution You are given a positive integer . Print a numerical triangle of height like the one below:
Integers Come In All Sizes Solution Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is: (c++ int) or (C++ long long int).
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 left. NOTE: String letters are case-sensitive. Input Format The first
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 condition. Given a string , which is the company name in lowercase letters, your
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 .
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 approximately the same performance in either direction. Click on the link to learn more
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. Example Code >>> from collections import OrderedDict >>> >>> ordinary_dictionary
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 accessing members of a tuple. Example Code 01 >>> from collections import namedtuple >>> Point
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 been set yet. If you didn't use a