Given a string, we need to find the length of the longest prefix which is also a suffix of the same string. For example, in the string "abcab", "ab" is both a prefix and suffix with length 2. Syntax int longest_prefix_suffix(char str[], int n); Algorithm The approach uses the KMP (Knuth-Morris-Pratt) failure function concept − Start comparing from the middle of the string to avoid overlap Use two pointers: one for prefix (length) and one for suffix (i) When characters match, increment both pointers When they don't match, reset according to the ... Read More
The CSS rotate in up left animation effect creates a smooth rotational transition where an element rotates from its normal position to -90 degrees around the left bottom corner while fading out. This animation is commonly used for exit effects and interactive elements. Syntax @keyframes rotateInUpLeft { 0% { transform-origin: left bottom; transform: rotate(0deg); opacity: 1; } 100% { ... Read More
Given an array arr[m] with m number of integers and n, which is the value to be added in an array and r queries are given with some start and end. For each query we have to add value n from the start till the end of the limit in an array. Syntax struct range { int start, end; }; void add_tomatrix(int arr[], struct range r[], int n, int size, int m); Example Input and Output Input: arr[] = {1, 2, 3, 4, 5} query[] = { { 0, ... Read More
The CSS wobble animation effect creates a shaking or oscillating motion by combining horizontal translation and rotation transforms. This effect is commonly used to draw attention to elements or create playful interactions. Syntax @keyframes wobble { /* Define keyframe percentages with transform values */ } .element { animation: wobble duration timing-function; } Example: Simple Wobble Animation The following example creates a wobble effect on a box element − .wobble-box { ... Read More
Given a matrix of n x n, the task is to print that matrix in lower triangular pattern. A lower triangular matrix is a matrix which has elements below the principal diagonal including the principal diagonal elements, with all other elements set as zero. Let's understand this with help of a diagram − Original Matrix 1 2 ... Read More
The CSS Xray filter is an Internet Explorer-specific filter that flattens the color depth by creating a grayscale, inverted effect similar to an X-ray image. This filter removes color saturation and inverts the brightness values. Syntax selector { filter: Xray; } Parameter ParameterDescription XrayGrayscales and flattens the color depth, creating an inverted monochrome effect Note: The Xray filter is a legacy Internet Explorer filter and is not supported in modern browsers. Consider using CSS filters like grayscale() and invert() for cross-browser compatibility. Example: Applying ... Read More
You are provided with a string str with some length n. Print the position of every element of the string so it can form a palindrome, else print a message "No palindrome" on screen. What is palindrome? Palindrome is a word, sequence of characters which reads same from the reverse or backward as from the forward manner, like MADAM, racecar. To find a sequence or a word is palindrome we generally store the reverse of a word in a separate string and compare both if they are same then the given word or sequence is palindrome. But ... Read More
The CSS rotate in down right animation effect creates an element that rotates from a 90-degree angle to its normal position while fading in, with the rotation origin set to the bottom right corner of the element. Syntax @keyframes rotateInDownRight { 0% { transform-origin: right bottom; transform: rotate(90deg); opacity: 0; } 100% { ... Read More
The CSS rotate in animation effect creates a smooth spinning motion that rotates an element into view from a specified angle. This animation is commonly used for entrance effects where elements appear to spin into position while fading in. Syntax @keyframes rotateIn { 0% { transform: rotate(-200deg); opacity: 0; } 100% { transform: rotate(0deg); ... Read More
Given a number n, we have to print the steps to make the number in the form of 2^X-1 by using XOR operation and increment operations. At odd steps, XOR the number with any 2^M-1, where M is the position of the leftmost unset bit. At even steps, increment the number by 1. Keep performing these steps until n becomes 2^X-1 (a number with all bits set), and print all the steps. Syntax int find_leftmost_unsetbit(int n); void perform_steps(int n); Algorithm The algorithm works by finding the leftmost unset bit and ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance