Articles on Trending Technologies

Technical articles with clear explanations and examples

How to Show or Hide Element in React?

Rohit Kumar Dwivedi
Rohit Kumar Dwivedi
Updated on 16-Dec-2024 353 Views

In this article, we are going to cover the implementation of dynamically showing or hiding elements in React. To understand this concept, you must be familiar with hooks in React. By leveraging hooks like useState, you can toggle and update the state to effectively control the visibility of an element. Approaches to Show or Hide Elements in React Using && Operator Using return null Using && Operator We have to change the state when a button is clicked, then it will determine the visibility of the element. With ...

Read More

JavaScript Program to Check if a Given Matrix is Sparse or Not

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Dec-2024 341 Views

To check if a given matrix is sparse or not, we will be discussing two different approaches, their complexities, and example codes. A sparse matrix is a special type of matrix in which the number of zeroes is strictly more than half of the the total number of elements present in the given matrix. In this article we are having a 2D matrix, our task is to write a JavaScript program to check if a given matrix is sparse or not. Users must be familiar with conditional statement, nested for loop and javascript methods. Example Input: Matrix: [[1, ...

Read More

Convert Integer to Hex String in Java

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 14-Dec-2024 15K+ Views

In Java, converting an integer value to a hexadecimal (hex) string means transforming the number from its base-10 (decimal) format to base-16 format. This conversion uses digits 0-9 and letters A to F to represent the values. Integer: An integer is a whole number without having a fractional part, such as -2, -1, 0, 1, 2, etc. Hex String: A hexadecimal (hex) string represents a number in base-16, using digits 0-9 and letters A-F. We represent the A-F in numbers as 10 to 15. Example Let’s say the following are our integer values. int val1 = 5; int val2 ...

Read More

Java Program To Reverse A Number And Check If It Is A Palindrome Number

Rudradev Das
Rudradev Das
Updated on 13-Dec-2024 4K+ Views

What is a Palindrome Number? If a number is given (two, three or four-digit number) and reversing each individual number with the positions from front to back and then vice versa , and then if the number output is the same after reversing all the elements then it is said to be a palindrome number. Just like we will check whether the string or array is palindrome number. String - A string is a storing capsule or a storing method in which we can store a sequence of characters in a Java program. Array - An array is a collection ...

Read More

Java Program for Pigeonhole Sort

Alshifa Hasnain
Alshifa Hasnain
Updated on 13-Dec-2024 543 Views

In this article, we will learn Pigeonhole Sort in Java, a sorting algorithm designed for arrays with a small range of integer values. It organizes elements into "pigeonholes" based on their values and then reconstructs the sorted array. We’ll discuss two approaches: a basic method using arrays and an optimized approach using LinkedLists. What is Pigeonhole Sort? Pigeonhole Sort works by distributing elements into a range of buckets based on their values. It is most effective when the range of input values is relatively small compared to the size of the dataset. The algorithm ensures stability and simplicity in sorting ...

Read More

JavaScript - Finding the third maximum number in an array

Alshifa Hasnain
Alshifa Hasnain
Updated on 13-Dec-2024 988 Views

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

Java Program to Save Decimal

Alshifa Hasnain
Alshifa Hasnain
Updated on 13-Dec-2024 970 Views

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

C# Program to Check If a Number is a Happy Number

AYUSH MISHRA
AYUSH MISHRA
Updated on 13-Dec-2024 8K+ Views

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

Java Program to get frequency of words with Lambda Expression

Alshifa Hasnain
Alshifa Hasnain
Updated on 13-Dec-2024 739 Views

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

Java Program for Pancake sorting

Alshifa Hasnain
Alshifa Hasnain
Updated on 13-Dec-2024 780 Views

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
Showing 12741–12750 of 61,248 articles
Advertisements