Category Archives: Algorithms

What is Algorithm | Introduction to Algorithms

What and Why? Algorithms are a well-ordered sequence of instructions that are used to solve a particular problem. The algorithm design technique is a strategy of developing an efficient algorithm to solve a problem or to do any computations. Various algorithm techniques are implemented to reach higher performance which is measured in terms of efficiencies. Here, the efficiency… Read More »

Pythagorean Triplet in an array using STL

Given an array of integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a2+b2=c2 Example: Input: arr[] = {8, 1, 4, 6, 10} Output: True There is a Pythagorean triplet (8, 6, 10). Input: arr[] = {1, 2, 4, 3} Output: False There is no Pythagorean triplet. Approach: The problem… Read More »

Balanced Brackets Problem in Data Structures in C++

Write a program to validate whether the brackets in the given input string are balanced or not. Examples: Input : {[()]} Output : Valid Input :{{(}}[] Output : Invalid Explanation: This problem is a very common application of stacks in data structures. An opening bracket may be ‘{‘,'[‘,'(‘ and their corresponding closing brackets are ‘}’,’]’,’)’. The brackets are… Read More »