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…

The “Hello world” of Data Structure-Linked List.

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…

Beautiful Triplets

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.

Halloween Sale

Problem:-

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

Minimum Distances

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.

Repeated String

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 …

Taum and B’day

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.

Jumping on the Clouds

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.

ACM ICPC Team

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. …

Modified Kaprekar Numbers

Problem statement-

Parag Naik

Work in progress

Get the Medium app