Found 33676 Articles for Programming

Java Program to Determine the Unicode Code Point at a given index

AmitDiwan
Updated on 29-Mar-2022 11:39:21

427 Views

In this article, we will understand how to determine the unicode code point at a given index. Each character is represented by a unicode code point. A code point is an integer value that uniquely identifies the given character. Unicode characters can be encoded using different encodings, like UTF-8 or UTF-16.Below is a demonstration of the same −Suppose our input is −Input String: Java Program Index value: 5The desired output would be −Unicode Point: 80AlgorithmStep 1 - START Step 2 - Declare a string value namely input_string and two integer values namely index and result Step 3 - Define the ... Read More

C++ code to check pile count is valid from second day

Arnab Chakraborty
Updated on 29-Mar-2022 11:35:35

206 Views

Suppose we have two arrays X and Y of same size. There are stone piles with X[i] number of stones on ith index on the first day and on the second day ith index has Y[i] number of stones. On the first day many members have come. Either they do nothing or they add few stones to some pile or they swap few stones from one pile to another. We have to check whether Y is valid from X or not.So, if the input is like X = [1, 2, 3, 4, 5]; Y = [2, 1, 4, 3, 5], ... Read More

C++ code to find minimum k to get more votes from students

Arnab Chakraborty
Updated on 29-Mar-2022 11:33:28

245 Views

Suppose we have an array A with n elements. There are n students in a school and each of them has exactly k votes and all votes should be used. There are two parties. The A[i] represents ith student has given A[i] amount of votes to first party and this implies the second party will get k- A[i] number of votes. The second party wants to set k in such a way that they win. What will be the minimum possible value of k.So, if the input is like A = [2, 2, 3, 2, 2], then the output will ... Read More

Java program to print first letter of each word using regex

AmitDiwan
Updated on 29-Oct-2024 00:38:40

779 Views

In this article, we will understand how to print the first letter of each word using regex. A regular expression is a sequence of characters that forms a search pattern. A regular expression can be a single character or a more complicated pattern. A regular expression helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. They can be used to search, edit, or manipulate text and data. Problem Statement Write a program in Java to print the first letter of each word using regex. Below is a demonstration of the same ... Read More

C++ code to check triangular number

Arnab Chakraborty
Updated on 29-Mar-2022 11:31:34

1K+ Views

Suppose we have a number n. We have to check whether the number is triangular number or not. As we know, if n dots (or balls) can be arranged in layers to form a equilateral triangle then n is a triangular number.So, if the input is like n = 10, then the output will be True.StepsTo solve this, we will follow these steps −for initialize i := 1, when i

C++ code to find corrected text after double vowel removal

Arnab Chakraborty
Updated on 29-Mar-2022 11:27:52

168 Views

Suppose we have a string S with n character. On a text editor, there is a strange rule. The word corrector of this text editor works in such a way that as long as there are two consecutive vowels in the word, it deletes the first vowel in a word. If there are no two consecutive vowels in the word, it is considered to be correct. We have to find corrected word from S. Here vowels are 'a', 'e', 'i' 'o', 'u' and 'y'.So, if the input is like S = "poor", then the output will be "por".StepsTo solve this, ... Read More

Java program to check whether the given string is pangram

AmitDiwan
Updated on 05-Nov-2024 22:03:46

707 Views

In this article, we will understand how to check whether the given string is a pangram in Java. A string is a pangram string if it contains all the characters of the alphabet ignoring the case of the alphabet. Here, we will be using two different approaches: using the main() method and using encapsulation. Problem Statement Given a string write a program in Java to find whether the string is pangram or not. Below is a demonstration of the same − Input  Input string: Abcdefghijklmnopqrstuvwxyz Output Yes, the string is a pangram Different approaches Following are the steps to check whether ... Read More

C++ code to count steps to reach final position by robot

Arnab Chakraborty
Updated on 29-Mar-2022 11:24:46

378 Views

Suppose we have two coordinates (x1, y1) and (x2, y2). A robot is at the point (x1, y1) and wants to go to the point (x2, y2). In a single step, the robot can move towards one cell to its 8 adjacent coordinates. We have to find minimal number of steps needed to reach the final position.So, if the input is like x1 = 3; y1 = 4; x2 = 6; y2 = 1;, then the output will be 3, becauseStepsTo solve this, we will follow these steps −return maximum of |x2 - x1| and |y2 - y1|ExampleLet us see ... Read More

C++ code to count numbers after division elements greater than half of array size

Arnab Chakraborty
Updated on 29-Mar-2022 11:20:32

162 Views

Suppose we have an array A with n elements. We have to find some non-zero integer d, such that such that, after each number in the array is divided by d, the number of positive values that are presented in the array is greater than or equal to the half of the array size. If there are multiple values of d that satisfy the condition. If there are multiple answers, return any one of them.So, if the input is like A = [10, 0, -7, 2, 6], then the output will be 4, because here n = 5 , so ... Read More

Java program to swap pair of characters

AmitDiwan
Updated on 09-Aug-2024 23:59:56

2K+ Views

In this article, we’ll learn how to swap pairs of characters in a Java string. We start with a simple method that converts the string into a character array, allowing us to swap characters directly. Then, we’ll explore an object-oriented approach where the swapping logic is encapsulated in a separate method. Both approaches highlight key Java concepts such as string manipulation and method encapsulation. Problem Statement Write a Java program to swap a pair of characters. Below is a demonstration of the same − Input  Input string: Java program Output The string after swapping is: Javg proaram Steps for basic ... Read More

Advertisements