In this article, we will explore an intriguing computational problem - "Minimum number of digits required to be removed to make a number divisible by 4". This problem is a common one in coding contests and algorithm-based interviews and offers excellent practice for enhancing your problem-solving skills. First, let's understand the problem statement: We have a number, and our task is to remove the minimum number of digits such that the remaining number is divisible by 4. Conceptual Understanding The problem lies in the realm of number theory. One key fact to understand is that a number is divisible by ... Read More
In this problem, we will learn to find the count of minimum deletion required so that when we take the XOR of any two adjacent elements, we should either get 0 or 1. We will use the properties of the XOR operations to solve the problem. For example, when we take XOR of the same numbers, we always get 0; when we take XOR of the consecutive even and odd number, we get 1. Problem Statement We have given a num_str string containing the numeric digits. We need to count the minimum deletions required so that the XOR ... Read More
In computer science, string manipulation is an essential topic that involves operations such as concatenation, substring, reversing, and more. One common problem related to string manipulation is to remove all 0s from a binary string. In this article, we will discuss an algorithm to solve this problem using a minimum number of non-adjacent pair flips. Problem Statement Given a binary string, we have to remove all 0s from the string using the minimum number of non-adjacent pair flips. A flip is defined as selecting two adjacent characters and swapping them. In other words, we need to find the minimum number ... Read More
In this article, we delve into a fascinating problem of string manipulation and character encoding in computer science. The task at hand is to minimize the number of swaps between same-indexed characters of two strings to make the sum of ASCII values of characters in both strings odd. A robust and versatile programming language favored by many software developers. Understanding ASCII ASCII, short for American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices that use text. Problem Statement We are given two strings of ... Read More
Block-level elements have their CSS display property set to either ‘block’, ‘list-item’, or ‘table’ and these elements force a line break above and below themselves. Block-level boxes are generated by each block-level element which is a part of the positioning scheme as well as contains child boxes. Block container boxes contain either block-level boxes and follow block formatting context or contain inline-level boxes and follow inline formatting context. Block boxes is a term used if block-level boxes are also block containers. Anonymous block boxes are those boxes over which developer has no control. If an inline box contains a block ... Read More
Using JavaScript, we can set our TextArea element to automatically grow with its content. The following examples illustrate how we can achieve the above scenario. Let us say the following is our TextArea before adding content − The following is the TextArea after adding content − The following is the same TextArea that auto grows itself after adding more content − Auto Grow a Textarea Example Let us see how to auto grow a textarea − * { ... Read More
The filter property is used to set visual effects, such as drop shadow, contrast, brightness, saturation, shadow to images in CSS. The following is the syntax − Syntax filter: none | drop-shadow() | blur() | brightness() | contrast() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia() | url(); As you can see above, with the filter property, we can set the following effects: contrast, drop shadow, blur, brightness, grayscale, hue-rotate, invert, opacity, saturate, sepia, url. The sepia sets the sepia effect to an image. To set the sepia effect in CSS3, use the ... Read More
We can align elements using the CSS positioning schema methods (fixed, relative, absolute and static) and properties (left, right, top and bottom). To align elements in CSS, use the position property. The position can be set using the following values − static relative fixed absolute sticky For example, the following is achieved by aligning divs on a web page using the position property − Align Elements With Absolute and Relative Positions Example Let’s see an example to align elements using the positioning schema. We have shown the absolute and relative positions here − ... Read More
We can easily align the flex items along cross axis, but first let us understand what cross axis is. The cross axis is perpendicular to the main axis. The main axis is like the flex direction − Create a Container div First, set the divs inside a container(flex container) − First Div Second Div Third Div Style the Container and Make it Flexible The flex container becomes flexible by setting the display property to flex. The flex items are aligned using the align-items property − ... Read More
CSS3 provides a layout mode Flexible Box, commonly called as Flexbox. Flexbox (flexible box) is a layout mode of CSS3. Using this mode, you can easily create layouts for complex applications and web pages. It includes the container, flex items, etc. The container has the following properties − flex-direction flex-wrap flex-flow justify-content align-items align-content Here are all the Flexbox examples in a single image. It uses the flex, flex-wrap, justify-content, align-items, etc. − Style the Parent Container We have styled the parent container here. The flex container becomes flexible by setting the display property to flex ... Read More