Given the head of a singly linked list, reverse the list, and return the reversed list.

A easy category linked list problem where we need to reverse the Linked list.For this there are two method-iterative and recurrssive method.Here we will apply the iterative method. For this method we will need to use to variable “prev” and “next_current”.Let’s move toward the code.

def reverseList(self, head: ListNode) -> ListNode:
prev=None
current=head
while current:
next_current=current.next
current.next=prev
prev=current
current=next_current
current=head
return prev

First we will give initial value of Null to prev variable and save head of Linked list in variable “current”. The we…


Linked is type of linear data structure which is widely use to solve specific problem raise due to the limitation of arrays.
Linked list can be define as linear data structure in which the elements are not stored in contiguous memory location. In Laymen terms we can say a linked list is a collection of nodes in which each node has a data and the reference to the next node.

The first node of the linked list is called as Head and the last node of the linked list points to null. In this tutorial we will perfomer following operations:-
1.Insert…


Problem statement:-

Solution:-
A very straight forward hackerrank problem where we have to find the count of triplet form based on condition given in the problem statement.


Problem:-

Solution:-
A
straight forward hackerrank problem where we have to calculate the number of gifts one can buy with given amount.


Problem:-The distance between two array values is the number of indices between them. Given a, find the minimum distance between any pair of equal elements in the array. If no such value exists, return -1.


Problem Statement:-
There is a string ”s”, of lowercase English letters that is repeated infinitely many times. Given an integer ,”n”. Find and print the number of letter “a” in string “s” in the first “ n” letters of the infinite string.

Solution:-
Interesting hackerrank problem where we need to find the letter “a” in first “n“ letters a given string which is repeated infinitely. Lets move towards the code.In …


Problem Statement:-

Solution:-
A very simple one line solution to this problem. Here we are trying to find out the minimum cost at which we can buy both white and black gifts.


Problem statement:-

Solution:-Simple but not so straight forward hackerrank problem where we have to count the number of jumps based on which type of cloud is allowed to jump on it or not in that case the jump range will increase.


Problem Statement:-
There are a number of people who will be attending ACM-ICPC World Finals. Each of them may be well versed in a number of topics. Given a list of topics known by each attendee, presented as binary strings, determine the maximum number of topics a 2-person team can know. Each subject has a column in the binary string, and a ‘1’ means the subject is known while ‘0’ means it is not. Also determine the number of teams that know the maximum number of topics. Return an integer array with two elements. …

Parag Naik

Work in progress

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store