# Optimized

## Target Sum – Single Iteration O(N)

• DSA

Given, a sorted array of elements and we need to find all the pairs of elements that add up equally to a given target sum number, this can be done usually done using two loops, like a brute force method where all the elements are compared with every other element… Read More »Target Sum – Single Iteration O(N)

## Fibonacci Series – Iterative vs Recursive

• DSA

The Fibonacci Series is a standard programming problem scenario, and we can obtain the series or nth Fibonacci number using both iterative as well as recursive. In this post, we’ll compare, discuss both methods and their complexities. Fibonacci Series – Example The principle behind this order/sequence is very simple The… Read More »Fibonacci Series – Iterative vs Recursive

## Bubble Sort Algorithm

• DSA

Bubble sort is one of the simple sorting techniques and it is also easier to code and understand. Bubble sort follows the simple principle of comparing two adjacent elements and swapping them according to our desired order. How Bubble Sort works? Consider the below example where we try to sort… Read More »Bubble Sort Algorithm

## Template Functions in C++

• DSA

Template Functions in C++ are easy to implement and powerful at the same time, also known as Generic Programming, where we don’t specify the data type and can use any type when needed. The template function follows the concept of data type as a parameter for initializing variables at compile… Read More »Template Functions in C++

## Two Sum LeetCode Optimized

• DSA

The Two Sum problem from LeetCode. Given an array of numbers and a target number and we should return the indices of the two numbers that sum up to the target. Let our target be 7 and then if our array contains 3,4 and 3+4=7 we will return the index… Read More »Two Sum LeetCode Optimized

## Squares of a Sorted Array LeetCode O(N)

• DSA

In this problem, given a sorted array in decreasing order and we should return the squares of each number and in the same ascending order, and the one thing we need to take care of is that the negative numbers, which when squared disturb the ascending ordered array. Problem Statement… Read More »Squares of a Sorted Array LeetCode O(N)