In this article, we will learn to find the third maximum unique number in an array of JavaScript, or the largest number if there are fewer than three unique values. We will be using three methods: a single-pass approach for efficiency, a sorting method to identify the number after removing duplicates, and a combination of Set and Max-Heap for optimal handling of large datasets. Each method includes examples and a comparison of time and space complexities. Problem Statement Given an array of integers, find the third maximum unique number. If the array contains fewer than three unique numbers, return the ... Read More
In this article, we will learn two ways to handle decimal values in Java. First, we will use the BigDecimal class to ensure precision when working with decimals. Then, we will use the DecimalFormat class to format decimal values. Both examples will show how to scale decimal values to three places. Different Approaches to Save Decimal Values The following are the two approaches to save decimal values in Java − Using BigDecimal Using DecimalFormat Save Decimal Values Using BigDecimal for Precision Control The BigDecimal class of java.math package is used for ... Read More
Problem DescriptionWe are given a number as input, we have to check whether the number is a happy number or not. In this article, we are going to learn how we can check if a number is a happy number or not in C#. What is a happy number?A happy number is a special type of number that will at last become equal to 1 when we replace the number with the sum of the square of its digits again and again. If the number is stuck in the loop such that it never becomes equal to 1 then the ... Read More
In this article, we will learn how to calculate the frequency of words in a text using Java and Lambda Expressions. By leveraging concise syntax and functional programming techniques, we can efficiently process text data and determine word occurrences. This approach is particularly useful for applications like text analysis and natural language processing. What is Lambda Expression? A lambda expression in Java is a concise way to represent an anonymous function(a function without a name). Introduced in Java 8, it simplifies the implementation of functional interfaces (interfaces with a single abstract method), enabling cleaner and more readable code. Syntax of ... Read More
In this article, we will learn pancake sorting which is a unique way to sort an array by flipping sections of it. The algorithm finds the largest unsorted element, flipping it to the front, and then flipping it to its correct position. Although not the fastest sorting method, it’s an interesting and creative way to learn about problem-solving and data manipulation. This article explains the algorithm in simple steps and shows how to implement it in Java. What is Pancake Sorting? Pancake sorting is a sorting technique that resembles selection sort, i.e. sorting the largest element first thereby reducing the ... Read More
In the given problem statement we have to find that the string is a palindrome and the string should also have punctuation and write code with the help of Javascript functionalities. Here we will learn two methods to determine if a string is a palindrome in JavaScript while handling punctuation and spaces effectively. What is a Palindrome? A palindrome is not limited to single words like "radar" or "level"; it can include phrases or sequences like "Madam, in Eden, I’m Adam." We need to ignore punctuation, spaces, and case differences to ensure accurate palindrome checks. Using JavaScript String and Array ... Read More
We are given an array of string/number literals. We are required to create a function removeRandom() that takes in the array, recursively removes one random item from it, and simultaneously prints it until the array contains items. This can be done by creating a random number using Math.random(), removing the item at that index using Array.prototype.splice(), and printing it until the length of the array shrinks to 0. Approaches to remove random items from array Following are the different approaches to removing the random item from an array and then removing it from the array until ... Read More
What is Floating Point Number? Floating point number formatting is the process of controlling how floating point numbers (numbers with decimal points) are displayed(printed in a program). For example, if we have a decimal number of 123.45678, the formatted number can be 123.457, 123.46, and 123.5 instead of that number. This makes the numbers easier to read and more consistent. The Floating point is just a number with decimal points. For example 1.2, 2.45 and 123.4 are the examples of the point numbers. It helps ensure the number of decimal places, making numerical data easier to read and maintaining a ... Read More
Inline Function An inline function in C reduces function calls by expanding the function's code at the call site during compile time. This increases the efficiency of the function. The inline function can be substituted at the point of the function call, but this substitution is always the compiler's choice. In an inline function, the function call is replaced by the actual program code. Most Inline functions are ... Read More
Databases are decidedly one of the most essential parts of modern-day applications, as there are solutions available for high performance, large storage capacity, hybrid of both, reporting etc. Two such databases are Valentina Server and VoltDB, each of which stands out in different aspects.Valentina Server is a universal hybrid database featuring reporting capabilities while VoltDB is a high speed distributed in-memory database intended for real-time data transactions. This article explores their individual features, their main functions, comparisons and contrasts in a bid to grasp the variety of contexts within which they are used.What is Valentina Server?VDS Server is a universal ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP