In this article, we will learn to print the ASCII value of a particular character in Java. ASCII (American Standard Code for Information Interchange) is a standard encoding system that assigns a unique numeric value to characters like letters, digits, and symbols. We’ll explain the concept of ASCII, demonstrate how to retrieve and display ASCII values in Java and provide practical examples to help you understand and apply this concept effectively. What Is ASCII? ASCII is a character encoding standard where each character (letters, digits, and symbols) is assigned a numeric value. For instance − ... Read More
In this article, we will learn to count the total number of minimum required rotations to get the original string in Java. We can solve the problem by getting the rotations substrings of the original string or concatenating the original string to itself. Problem statement We have given string str of length N. The task is to find the total number of minimum rotations we need to perform to get the original string. Input 1 str = "bcdbcd"; Output 1 3 Explanation − We need to make 3 rotations to get the original string. ... Read More
A heterogram is a string where each letter appears only once, with no repeated characters. This property makes it unique and an interesting problem to solve in Java. In this article, we will learn to determine whether a given string is a heterogram using a frequency-based approach and introduce an alternative using a Set. Set A Set is a type of Collection designed to hold unique elements, ensuring no duplicates are present. It reflects the concept of a mathematical set and includes methods from the Collection interface while enforcing this rule of uniqueness. Using an Array for Character Frequency This ... Read More
What is a Perfect Number?A perfect Number is a positive integer that is equal to the sum of its proper divisors(excluding itself). For example, 6 is a perfect number because its divisors (1, 2, and 3) sum up to 6. Proper divisors are those numbers that leave no remainder when divided by numbers. The proper divisor should not include that number itself otherwise it would always be greater than a number.Problem DescriptionIn this article, we will learn how to check whether a number is a perfect number or not using C#.Below are a few examples including edge case examples to ... Read More
When working with React class components, one often encounters the super() and super(props) calls inside the constructor. These methods are crucial for initializing a class component and inheriting properties from React.Component base class. While they may look similar at first glance, they serve different purposes depending on how you intend to use props. In this article, we’ll explore the difference between super() and super(props) and help you understand when to use each. Introduction of super() and super(props) in React super(): The super() function is used to call the constructor of the parent class. In ... Read More
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
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
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP