The area of a triangle is given as (base * height) / 2, and the area of a parallelogram is base * height. For calculating the area of the triangle inside the parallelogram, we divide the area of the parallelogram by 2, i.e., (base * height) / 2, where the base and the height of the parallelogram are given. Here are some example scenarios to calculate the area of a triangle inside a parallelogram using the above formula: Scenario 1 Input: base = 10, height = 8 Output: 40 Explanation: Using the formula: Area ... Read More
Java does not have built-in tuple support; to use the tuple, we use the third-party library called Javatuples. This library provides classes representing fixed-size tuples of different sizes. The Quartet class is one of these classes that represents a tuple with 4 values. Creating a Quartet Tuple in Java We can create a Quartet in Java in the following ways: Using a Constructor Using fromCollection() method Using with() method Using fromArray() method Using a Constructor The constructor of the Quartet class accepts ... Read More
What is 2-3 Trees? A 2-3 tree is a tree data structure, where each internal node has either 2 or 3 children (also, we can say that 2-nodes and 3-nodes, respectively). It is a type of B-tree that ensures efficient search, insertion, and deletion operations with O(logn) time complexity. Properties of 2-3 tree 2-node contains one data element and has two children (or none if it is a leaf). 3-node contains two data elements and has three children (or none if it is a leaf). Data ... Read More
An arithmetic mean is the average of all the given numbers, which is calculated by summing all the numbers and dividing this calculated sum by the total number of elements. The formula for calculating the arithmetic mean is: $$ \bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i = \frac{x_1 + x_2 + x_3 + \cdots + x_n}{n} $$ Here, we are given an array of integers and our task is to calculate the arithmetic mean of these numbers using the above formula: Scenario 1 Input: num = 2, 7, 4, ... Read More
The matplotlib is a library in Python that allows us to create graphs and plots for data visualization. This library provides several functions to adjust the height, width, and other layout properties of individual subplots in a figure. In this article, we will learn how to adjust the heights of individual subplots in matplotlib using Python. Subplots in Matplotlib Adjusting Heights of Subplots Using gridspec_kw Adjusting Heights of Subplots Using GridSpec Conclusion Subplots in Matplotlib A subplot is a smaller ... Read More
The matplotlib is a library in Python that allows us to create graphs and plots for data visualization. This library have several built-in functions to style the plots, such as changing colors, adding titles, setting backgrounds, labels, and adjusting the layout of subplots. In this article, we will learn how to adjust the transparency of text backgrounds in matplotlib plots. Text Backgrounds in Matplotlib Adjusting Background Transparency of Title Text Adjusting Background Transparency of Labels Conclusion Text Backgrounds in Matplotlib ... Read More
Array transformation is a popular coding question asked in technical assessments and interviews. In this article, we will discuss the problem of array transformation with example testcases, the algorithm to solve it, and provide a C/C++ implementation. Array Transformation Based on Local Maxima and Minima In this problem, you are given an array of integers arr[] of size N. Every day the array undergoes a transformation which can be defined as follows: The first and last elements of the array are not transformed. For every other element arr[i] in the array, where 0 < i < N-1, ... Read More
LinkedHashMap is a data structure in Java that is part of the Java Collections Framework. It is very similar to HashMap.It stores key-value pairs, where each key is unique, and it allows null values, but allows only one null key. The main difference is that the LinkedHashMap returns the elements in the order they were inserted. This is because it maintains a linked list with entries in the map, which helps it to retain the insertion order of the elements. Our task is to check if a particular key exists in a LinkedHashMap in Java. Scenario 1 Following is a ... Read More
A string is a sequence of characters, like words, numbers, or sentences, enclosed in double quotes ("). The given task is to add a closed pair of HTML bold tags around a string using C++.Let us understand this with an example: Input: abc Output: abc Add Bold Tag in String in C++ To add bold tags to a string in C++, we use string concatenation. This is the process of joining two or more strings together to form a new string. In C++, this can be done using the '+' operator. To wrap a string with bold ... Read More
Adding two numbers is a basic arithmetic operation, where we simply combine their values to get the total. The given task is to add two numbers using the "++" operator in C++. Let's understand this with an example: Scenario 1 // Adding two numbers using '+' operator Input: a = 7, b = 3 Output: 10 Explanation: a + b => 7 + 3 = 10 Scenario 2 // Adding two numbers using '++' operator Input: a = 7, b = 3 Output: 10 Explanation: a + b => 7 + 1 + ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP