Found 34472 Articles for Programming

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

Rohan Singh
Updated on 11-Jul-2023 14:21:54

3K+ Views

A Unicode code point is a unique number that represents a number in the Unicode character set. Unicode is a character encoding standard that is used to assign unique codes to every character in the world. Unicode supports around 130, 000 characters including letters, symbols, and emojis.We can determine the Unicode Code point at a specific index using the ord() function, codecs module in Python, unicodedata module, and array module in Python. In this article, we will discuss how we can determine the Unicode code point at a given index using all these methods. Unicode Code Point According to ... Read More

Python Program to Compare two strings lexicographically

Rohan Singh
Updated on 11-Jul-2023 14:19:53

2K+ Views

We can compare two strings lexicographically in Python using comparison operators like '', '==', ' string2[i]: print(string2, "comes before", string1) break i += 1 else: if len(string1) < len(string2): print(string1, "comes before", string2) elif len(string1) > len(string2): print(string2, "comes before", string1) else: print("The two strings are equal") Output apple comes before banana Example In the below ... Read More

How to Save Pandas Dataframe as gzip/zip File?

Rohan Singh
Updated on 11-Jul-2023 14:16:35

5K+ Views

Pandas dataframe can be saved in gzip/zip format using the gzip and zipfile module in Python. Pandas is a Python library that is used for data manipulation and analysis. It provides a two-dimensional labeled data structure with columns of potentially different data types. To reduce the size of the data frame we need to store it in gzip/zip format. In this article, we will understand how we can save Pandas Dataframe as gzip/zip file. Algorithm A generalized algorithm to save a Pandas DataFrame as a compressed gzip/zip file is written below. However, the exact implementation of this algorithm may vary ... Read More

Final vs Immutability in Java

Deepti S
Updated on 11-Jul-2023 11:05:02

868 Views

The "final" keyword in Java may be employed to define a constant value as well as prevent a variable, method, or class from being changed or overridden. On the other side, immutability describes an object's characteristic of keeping a constant state across the course of its existence. The values of an object don't change after it is formed. Variables, methods, and classes are constrained by the "final" keyword, but immutability goes a step farther by guaranteeing that the object's whole state is preserved. Let us learn the key differences between final vs immutability in this article. Final in Java ... Read More

Few Tricky Programs in Java

Deepti S
Updated on 11-Jul-2023 10:37:08

363 Views

Confounding Java questions stem from loops, multithreading, overloading, overriding, and more, making them challenging to navigate. Occasionally, seemingly simple questions confound us, leading to haphazard code instead of straightforward solutions. With analytical thinking, we can crack these questions even without prior knowledge. Join us as we explore tricky programs in Java. Methods Used Comments that work Named loops Method 1: Comments that work In the realm of programming, Java comments are textual statements within a program that hold no significance in terms of execution by the compiler or interpreter. The purpose behind incorporating comments into code is multifold. ... Read More

Filter Pattern in Java

Deepti S
Updated on 11-Jul-2023 10:33:38

313 Views

The Filter Design Pattern, also known as the Criteria Design Pattern, is a structural design pattern used by developers to filter objects based on different criteria. It enables decoupled filtering and logical operations by chaining multiple criteria into a single criterion. It provides two techniques for creating filters: filtering for the entire collection or filtering for a particular collection member. To apply criteria to a class, you can follow these steps: Create a class that requires filtering. Develop the criteria's interface. Implement concrete classes that meet the interface's requirements. Filter out certain objects by using a variety of criteria ... Read More

Java Program for Left Rotation and Right Rotation of a String

Prabhdeep Singh
Updated on 11-Jul-2023 08:55:14

2K+ Views

Rotation means we have to shift each character either in a forward direction or backward direction. Forward direction means right rotation (Or anticlockwise) and backward direction means left rotation (Or clockwise). In this problem, we have given a string of characters of size n and integer d. Here d is less than n. Our task is to print the left rotated string or right rotated string by d integer. Only the permutation of the current string changes, not the length or frequency of the characters in the given string. Input 1 str = “apple”, d = 2 Output 1 Left ... Read More

Sort a string without altering the position of vowels

Prabhdeep Singh
Updated on 11-Jul-2023 09:02:29

385 Views

Sorting a string means we have to arrange a given string either in an ascending or descending order or any given order. In this problem given a string 'str' of size n. Our aim is to sort the given string without altering means without changing the position of vowels present in the string. Let's see examples with explanations below to understand the problem in a better way. Sample Examples Input 1 str = “abdecokfee” Output 1 abcedofkee Explanation Constant present in the string = bdckf Sort the constant string = bcdfk Merge the given string with the sorted instant string ... Read More

Maximum Number of 0s Placed Consecutively at the Start and End in any Rotation of a Binary String

Prabhdeep Singh
Updated on 11-Jul-2023 09:00:04

75 Views

Binary string means the string contains only two types of char either 1 or 0. It is known as base 2. In this problem, we have given a binary string str and also the size of the string 'n'. Our task is to find the maximum number of zeros places consecutively at the start and end of any rotation of a binary string. Let's see examples with explanations below to understand the problem in a better way. Sample Example Input 1 str = “101001, n = 6 Output 1 2 Explanation The string can be rotated in any of the ... Read More

C++ Program for Left Rotation and Right Rotation of a String

Prabhdeep Singh
Updated on 11-Jul-2023 08:56:40

680 Views

Rotation means we have to shift each character forward or backward direction. In the case of forward, the last character is forwarded to the index 0 also known as right rotation. In the case of backward first character at index 0 is backward to the last index also known as left rotation. In this problem, we have given a string of characters and integer d. Our task is to print the left rotated string or right rotated string by d integer. Only the permutation of the current string changes, not the length or frequency of the characters in the ... Read More

Advertisements