Precision of Floating Point Numbers in C++

Tapas Kumar Ghosh
Updated on 06-Jun-2025 19:32:33

8K+ Views

Precision of floating point numbers is the accuracy upto which a floating point number can hold the values after decimal. For example, 10/6 = 1.6666666… these have recurring decimals which can take infinite memory spaces to be stored. To avoid memory overflow in such cases the compiler set a precision limit to the number. For float values in C++, the precision is set to 6-7 digit after that if the decimal recurs it will discard the value. So, to avoid any major losses when this discarding takes place there are methods and libraries that support the precision is float values. ... Read More

Count Pairs with Given Sum in JavaScript

Ravi Ranjan
Updated on 06-Jun-2025 19:17:34

1K+ Views

To count pairs with given sum, is a common problem asked in job interviews and is often used in many real-world applications such as cryptography and data compression. In this article we are having an array and a target sum value, our task is to write a Javascript program to count pairs with given sum. Example Input: arr = [1, 2, 3, 5, 6, 7, 9] sum = 8 Pairs = (1, 7), (2, 6), (3, 5) Output: Count: 3 Approaches to Count Pairs with Given Sum Here is a list of ... Read More

JavaScript Program for the Third Largest Element in an Array

Ravi Ranjan
Updated on 06-Jun-2025 19:17:02

807 Views

For the third largest element in an array of distinct elements, we will discuss three different approaches. We will improve efficiency with each approach and discuss their complexities. In this article we are having an array of distinct elements, our task is to find third largest element in an array of distinct elements in Javascript. Users must be familiar with array, loops and conditional statement. Example Input: arr = [2, 5, 8, 1, 4, 10, 7] => Highest: 10, second highest: 8, third highest: 7 Output: 7 Approaches for Third Largest Element in Array ... Read More

JavaScript Program for Counting Frequencies of Array Elements

Ravi Ranjan
Updated on 06-Jun-2025 19:16:49

1K+ Views

Counting frequencies of array elements means we have to count the number of times an element from the array appears in the given array. We will be discussing five different approaches to achieve this. We can use some inbuilt data structures or external libraries for easy implementation. In this article we are having an array with duplicate elements, our task is to count frequencies of array elements in JavaScript. Users must be familiar with array and it's functions, JavaScript methods and function, loops, conditional statement and Javascript objects. Approaches to Count Array Elements Frequencies Here is a list of ... Read More

Find Common Elements in Two Sorted Arrays

Ravi Ranjan
Updated on 06-Jun-2025 19:16:37

531 Views

To find common elements in two sorted arrays using JavaScript, we will be discussing various approaches. Common element refers to element which is present in both the arrays. First, we will try brute force approach and then we will optimize our code to improve the time complexity. In this article we are having two sorted arrays, our task is to find common elements in two sorted arrays. Users must already know about JavaScript arrays, its function and operations on arrays, loops, searching technique and conditional statement. Example Input: arr1 = [1, 2, 3, 4, 5] ... Read More

Search an Element in a Sorted Rotated Array in C++

Ravi Ranjan
Updated on 06-Jun-2025 19:16:12

1K+ Views

A sorted and rotated array is an array that is sorted in ascending order and then rotated either left or right by a specific number of elements. There should exist exactly one pivot point around which the array is rotated. The array can be said to be split into two halves and each half is a sorted array. For example: {5, 6, 7, 1, 2, 3} is a sorted and rotated array and {5, 6, 7, 8, 2, 5, 4, 5} is not a sorted and rotated array. In this article, we have an array of integers. Our task is ... Read More

Check If an Array is Sorted and Rotated in C++

Ravi Ranjan
Updated on 06-Jun-2025 19:15:03

2K+ Views

A sorted and rotated array is an array that is sorted in ascending or descending order and then rotated either left or right by a specific number of elements. There should exist exactly one pivot point around which the array is rotated. The array can be said to be split into two halves and each half is a sorted array. For example: {5, 6, 7, 1, 2, 3} is a sorted and rotated array and {5, 6, 7, 8, 2, 5, 4, 5} is not a sorted and rotated array. In this article, our task is to check if the ... Read More

Mirror of Matrix Across Diagonal in JavaScript

Ravi Ranjan
Updated on 06-Jun-2025 19:14:12

433 Views

To write a javascript program for mirror of matrix across diagonal, we will be discussing two approaches with their code example and explanation of code. In this article we are having a 2D matrix. Our task is to write a JavaScript program for mirror of matrix across diagonal. Example Input: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Output: [[1, 4, 7], [2, 5, 8], [3, 6, 9]] Approaches ... Read More

Find Lexicographically Minimum String Rotation in JavaScript

Ravi Ranjan
Updated on 06-Jun-2025 19:13:41

627 Views

To find lexicographically minimum string rotation in Javascript, we will understand two different approaches in this article. A lexicographically minimum rotation of a string is the smallest string that can be obtained by rotating the original string any number of times in lexicographical order. By lexicographical order it means dictionary order such as: a < b, ab < ac. In this article we are having a string. Our task is to write a JavaScript program to find lexicographically minimum string rotation. Example Input: bba All lexicographical order are: bba, bab, abb Output: Smallest lexicographical rotation: abb ... Read More

Convert 24 Hours Format to 12 Hours in JavaScript

Ravi Ranjan
Updated on 06-Jun-2025 19:13:26

2K+ Views

To convert 24 hours format to 12 hours in Javascript, we have discussed two different approaches. In this article we are having time in 24 hours format, our task is to write a JavaScript program to convert 24 hours format to 12 hours. Approaches to Convert 24-hours format to 12-hours Here is a list of approaches to write a JavaScript program to convert 24 hours format to 12 hours which we will be discussing in this article with stepwise explanation and complete example codes. Using if-else Statement Using Date Object ... Read More

Advertisements