Found 27104 Articles for Server Side Programming

Get the Most recent previous business day using Python

Asif Rahaman
Updated on 28-Jul-2023 12:39:24

1K+ Views

In today's fast-paced based business environment and with a huge amount of work going on around the world, developers need to analyze the dates accurately up to date. The business days are different from normal days. Business days are different from normal days. Typically the days on which office works run, like the stock market, government officials, schools, offices, banks, etc. While dealing with real-world problems involving such institutions, developers must design the systems as per the business days. This article will explain how to get the most recent business day in Python. Use The date time Library The date ... Read More

Gaussian fit using Python

Asif Rahaman
Updated on 28-Jul-2023 12:33:33

4K+ Views

Data analysis and visualization are crucial nowadays, where data is the new oil. Typically data analysis involves feeding the data into mathematical models and extracting useful information. The Gaussian fit is a powerful mathematical model that data scientists use to model the data based on a bell-shaped curve. In this article, we will understand Gaussian fit and how to code it using Python. What is Gaussian Fit A bell-shaped curve characterizes the Gaussian distribution. The bell-shaped curve is symmetrical around the mean(μ). We define a probability density function as follows f(x) = (1 / (σ * sqrt(2π))) * exp(-(x - ... Read More

Minimum addition/removal of characters to be done to make frequency of each character prime

Sakshi Koshta
Updated on 31-Jul-2023 13:29:57

57 Views

Optimising character frequency for primality is a challenging task in computer science that entails identifying the smallest number of character additions or removals required to make the frequency of each character in each string a prime integer. Cryptography, data reduction, and natural language processing are just a few of the applications for this issue. The frequency of characters in a string can be optimised for primality in this tutorial using a C++ method. We will start by involving further into the problem description and then propose an efficient solution. Method Dynamic programming Approach minOperations function Method Method ... Read More

How to merge images with same size using the Python 3 module pillow?

Tarun Singh
Updated on 31-Jul-2023 09:59:26

248 Views

The pillow or PIL is a powerful Python library for handling and manipulating images. One of the most common tasks in image processing is merging multiple images into a single image. It provides a range of functions for loading, manipulating, and saving images in various formats. One of the main features of Pillow is its support for image merging. It supports a variety of images including “jpeg”, “png”, “bmp”, “gif”, “ppm”, “tiff”. With this module, we can do almost anything with digital images like basic image processing functionality, point operations, filtering images using built-in convolution kernels, and color space conversions. ... Read More

Segregate 1s and 0s in separate halves of a Binary String

Shubham Vora
Updated on 28-Jul-2023 13:10:17

190 Views

In this tutorial, we need to separate all 1s and 0s of the given binary string in the two halves. Here, we need to take a substring from the given string and reverse it to separate 0s and 1s in different parts. Ultimately, we need to count the total number of reversals required for substring to separate 1s and 0s in two halves. Problem statement − We have given a binary string of even length. We need to take any substring from the given string multiple times and reverse it to separate it into two halves. We need to print ... Read More

Modify string by replacing all occurrences of given characters by specified replacing characters

Shubham Vora
Updated on 28-Jul-2023 13:07:54

88 Views

In this problem, we need to replace the characters of the given string according to the characters given in the array of pairs of characters. We will discuss two different approaches to solving the problem. In the first approach, we iterate through the characters of the given string and pairs of characters to replace each character. In the second approach, we will use an array of length 26 to store the replaced character related to each character and change the character of the given string. Problem statement − We have given a string str containing N lowercase alphabetic characters. Also, ... Read More

Minimum removals required such that a string can be rearranged to form a palindrome

Shubham Vora
Updated on 28-Jul-2023 13:06:05

681 Views

In this problem, we need to remove the minimum characters from the string and rearrange the remaining characters to make the string palindromic. To solve the problem, the first question we should ask ourselves is when we can make string palindromic. In below two cases, we can make string palindromic. If each character’s frequency is even in the given string. If only one character’s frequency is odd and all other characters' frequency is even. So, we need to remove minimum characters to make each character’s frequency even except for any single character. Problem statement − We have given ... Read More

Minimize removal of substring of 0s to remove all occurrences of 0s from a circular Binary String

Shubham Vora
Updated on 28-Jul-2023 13:04:06

58 Views

In this problem, we require to remove all zeros from the given binary string. Also, we require to remove pair of consecutive zeros at once and count the total number of pairs of zeros removal. We can solve the problem by counting the number of pairs of consecutive zeros in the given string. In this tutorial, we will learn two different solutions to solve the problem. Problem statement − We have given circular binary string str of length N. We need to find the minimum number of consecutive zeros required to remove all zeros from the string. Sample Examples Input ... Read More

Minimize flips required such that string does not any pair of consecutive 0s

Shubham Vora
Updated on 28-Jul-2023 12:58:09

79 Views

Here, we require to manipulate the binary string so that it doesn’t contain any consecutive zeros. If we find consecutive zeros, we need to change any zero to 1. So, we require to count the total number of 0 to 1 conversion we should make to remove all consecutive zeros from the string. Problem statement − We have given a binary string ‘str’ containing only 0 and 1. We require to find the minimum number of flips required so that the resultant string doesn’t contain any consecutive zeros. Sample Examples Input – 0101001 Output – 1 Explanation ... Read More

Longest Non-Increasing Subsequence in a Binary String

Shubham Vora
Updated on 28-Jul-2023 12:55:09

159 Views

In this problem, we require to find the longest non-increasing subsequence of the given string. The meaning of non-increasing is either character should be the same or in decreasing order. As binary string contains only ‘0’ and ‘1’, the resultant string should start with ‘1’ and end with ‘0’, or start and end with either ‘0’ or ‘1’. To solve the problem, we will count prefix ‘1’s and suffix ‘0’ at each position of the string and find the maximum sum of prefix ‘1’s and suffix ‘0’s. Problem statement − We have given binary string str. We need to ... Read More

Advertisements