# Category: Data structures

#### Java – Valid Parentheses

This is one of the most common datastructure interview questions and to validate parenthesis. Examples of valid parentheses: (()){}{} Examples of Invalid parentheses : ({) or {(((()))) Problem: Given a…

#### Java Valid Parentheses with out stack

In this post, we will see Valid Parenthesis with stack. This solution uses a counter to keep track of the balance of parentheses. Whenever an opening parenthesis is encountered, the…

#### Java Rotate Array K Times

Problem : Given of size ‘n’ and a values ‘k’ around which we need to right rotate the array. Array: [1,2,3,4,5,6,7], K = 3 Rorate1: 7,1,2,3,4,5,6 Rotate2: 6,7,1,2,3,4,5 Rotate3: 5,6,7,1,2,3,4 Solution…

#### Java Left Rotate Array K Times

Problem: Given array of size ‘n’ and left rotate k times Input : [1,2,3,4,5,6,7], K=3 Left Rotate 1: 2,3,4,5,6,7,1 Left Rotate 2: 3,4,5,6,7,1,2 Left Rotate 3: 4,5,6,7,1,2,3 Solution: Reverse the…

#### Remove duplicates from a linked list

In this, we will see java code to remove duplicates from linked list Java Code: class LinkedList { static class Node { int data; Node next; Node(int d) { data…

#### Implement Stack using a linked list

In this tutorial, we will see Java program to implement a stack using a linked list class Stack { static class Node { int data; Node next; Node(int d) {…

#### Detect cycle in linked list

In this tutorial, we will see Java program to detect a cycle in a linked list The LinkedList class defines a Node inner class that represents a node in the…

#### Remove a loop in a linked list

In this tutorial, we will see java program to remove a loop in linked list In this code,If a loop is detected, we use another pointer to find the starting…

#### Graphs Introduction

Graphs are an important data structure in computer science and are used to model many real-world scenarios. Here are some common interview questions related to graphs: Graph A graph is…