# Optimized

## Count Vowels in a String with JavaScript

Problem Statement: For any given string write JavaScript code to console log the count of vowels with separate counts for each vowel occurrence. e.g if enter the string “apple” the output should be vowel count:: a:1, e:1, i:0, o:0, u:0. Let’s try to do this in a single iteration i.e.… Read More »Count Vowels in a String with JavaScript

## Even Odd Separation O(N) Single Iteration

• DSA

Given an array containing a mix of even and odd numbers, and we need to perform Even Odd Separation. In this post we’ll see how to separate even and odd numbers in a single iteration using two pointers. Example Solution Approach Method 1 To separate even-odd elements, we can take… Read More »Even Odd Separation O(N) Single Iteration

## Balanced Parenthesis Program

• DSA

We have an expression that contains brackets and alphanumeric characters, and we need to check whether the parenthesis are balanced or not. Balanced Parenthesis means an equal number of opening and closing brackets. Example Solution Approach – Using Stack Why Stack Data Structure? Here, our priority is to find if… Read More »Balanced Parenthesis Program

## How the bits/stdc++ .h works in C++

• DSA

I often wonder, How does #include < bits/stdc++.h> work?. I’ve seen this while solving competitive problems and referring to various solutions and I wanted to know what’s happening in the background. Here’s what I found It is a precompiled header file that contains every standard library Once, we use this… Read More »How the bits/stdc++ .h works in C++

## Separate 0s and 1s – O(N) Single Iteration

• DSA

Given an array of numbers consisting of only zeroes and ones, and we need to separate 0s and 1s. This problem can be solved in many ways like sorting and performing basic swapping but I learned a method to do all of this in a single iteration. So, let’s do… Read More »Separate 0s and 1s – O(N) Single Iteration

## Count the Duplicates of Array O(N)

• DSA

In the given problem, we have a sorted array, and we need to count the duplicates of each element. In simple words, we should print the no.of times each element occurs. Example Solution approach Since we have a sorted array, things become much easier. Once we traverse through an element,… Read More »Count the Duplicates of Array O(N)