Articles for author: Aditya Trivedi

Trapping Rain Water Problem

Problem Statement The width of each and every bar on to an elevation map is 1. Determine how much water it can hold after it rains by computing the heights of the elevation map bars, which are represented by n non-negative integers. Example Input: Output: Example Explanation Representation of above input heights is given below in ...

Searching in Data Structure

Searching in data structures involves finding the location of a specific element or value within a collection. It is a fundamental operation that can greatly influence data handling efficiency in applications like databases and search engines. There are various types of searching in data structure, the most common being Linear Search and Binary Search. Types of ...

Difference Between Algorithm and Flowchart

The difference between algorithm and flowchart is simply that algorithm is the collection of rules that should be followed while solving any particular problem. flowchart is diagrammatic representation of the algorithm. What is Algorithm? Let’s understand what an algorithm is to clarify the difference between algorithm and flowchart. An algorithm is a method for solving a problem step by step. An algorithm is a set ...

Subarray with Given Sum

Problem Statement An unsorted array nums and an integer sum k is given. Array has non- negative integers in it. Find out the continuous subarray which elements sums up to the given sum. There can be multiple such subarray with given sum, print out the first such subarray with given sum. If the subarray with ...

Reverse a Linked List

Problem Statement The objective is to reverse a given linked list, which involves altering the pointers between nodes such that the last node becomes the new head node, and each subsequent node points to its predecessor. For Example: Input1 : Output1 : Input2 : Output2 : Input3 : Output3 : Approach 1 : Iterative Method ...

Space Complexity in Data Structure

Let’s take an example of sorting alogrithms like insertion and heap sort doesn’t creates a new array during sorting as they are in-place sorting techniques but merge sort creates an array during sorting of elements which takes an extra space so if there is a concern of space then obviously one will prefer the insertion ...

Balanced Parentheses

Check for balanced parentheses in the expression Scope This article tells how to check balanced parentheses using stack. In this article we will learn implementation in different programming language. In this article we will learn time complexity of the stack approach. Takeaways Balanced parentheses means that each opening symbol has a corresponding closing symbol and ...