Becoming a Better developer by using the SOLID Design principles

Consider that you are working in good startup based company. There you were assigned with the role of Software Development Engineer. So that, you are the most responsible person for developing core features from end to end. But the problem is, in early stage startups, things are not very organized. So we ended up by … Continue reading Becoming a Better developer by using the SOLID Design principles

9) Linked List Cycle II

In this article we going to see about how to Detect Loop in a Linked List and Return the Loop Node. Below is our given problem from Leetcode, Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we … Continue reading 9) Linked List Cycle II

8) Detect Loop in linked list

In this article, we going to see how to detect loop in a linked list. Here is our given problem, Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects … Continue reading 8) Detect Loop in linked list

7) Reverse a Linked List – Iterative and Recursive approach

This is one of the most important interview question, How to reverse a linked list using iterative and recursive approach? In this article, I will help you to understand, how to approach and solve this problem. I'm going to make a diagrammatic representations, so that you can easily understand the problem well. Here is our … Continue reading 7) Reverse a Linked List – Iterative and Recursive approach

6) Swap Nodes in Pairs

Hi geeks! Today we going to see about how to swap the linked list nodes in a pair wise. Given a¬†linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be changed. Example: Given 1->2->3->4, you should return the list as 2->1->4->3. … Continue reading 6) Swap Nodes in Pairs

5) Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Input: 1->2->3->3->4->4->5 Output: 1->2->5 Example 2: Input: 1->1->1->2->3 Output: 2->3 Solution: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; … Continue reading 5) Remove Duplicates from Sorted List II

Singleton Design Pattern

The singleton pattern ensures that, "A class has only one instance and provides a global point of access to it". It comes under the creational design pattern. Just think about that, you have a class and singleton pattern helps you to make it impossible to instantiate that class except for a single time and whenever … Continue reading Singleton Design Pattern

4) Remove Zero Sum Consecutive Nodes from Linked List

Hi geeks! In this article, we going to play with Linked list and hash map by solving this interesting problem remove Zero Sum Consecutive Nodes from Linked List. Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return the head of … Continue reading 4) Remove Zero Sum Consecutive Nodes from Linked List

3) Next Greater Node In Linked List

Hi friends! In this article, we going to find next greater node in linked list after that we going to convert that into an array. Lets jump into problem. We are given a linked list with head as the first node.  Let's number the nodes in the list: node_1, node_2, node_3, ... etc. Each node may have a next larger value: for node_i, next_larger(node_i) is … Continue reading 3) Next Greater Node In Linked List

2) Rotate List

Hi Geeks! Today we going to see, how to rotate the linked list with fun. Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1->2->3->NULL Explanation: rotate 1 steps to the right: 5->1->2->3->4->NULL rotate 2 steps to the right: 4->5->1->2->3->NULL Example 2: Input: 0->1->2->NULL, … Continue reading 2) Rotate List

1) Design Linked List

Hi geeks, in this article we going to design the Linked List with add at head, add at tail, insert at specific position and delete operations. This is one of the good question from Leetcode to test the LinkedList knowledge. Design your¬†implementation of the linked list. You can choose to use the singly linked list … Continue reading 1) Design Linked List

2020 – Consistency is the Key

I always used to say, consistency is the key to success. We going to practice the consistency in programming. Why Consistency in programming? Today, in the IT industry, majority of people don't have good command over the subject. Recent studies proven that, there is huge chuck of software engineers are unfit for software development jobs. … Continue reading 2020 – Consistency is the Key