Vanshika Sood

Vanshika Sood

27 Articles Published

Articles by Vanshika Sood

27 articles

Smallest string divisible by two given Strings

Vanshika Sood
Vanshika Sood
Updated on 27-Oct-2023 1K+ Views

The objective of this article is to determine the smallest string that is a multiple of both given strings. An interesting observation to note is that for two given strings s and t, the string s is a multiple of t if and only if s can be formed by repeating t one or more times. We have to find the smallest such string. Problem Statement Given two non-empty strings, s1 and s2, with lengths n and m respectively, the objective is to determine the smallest string that is a multiple of both s1 and s2. A ...

Read More

Set the Leftmost Unset Bit

Vanshika Sood
Vanshika Sood
Updated on 27-Oct-2023 773 Views

This article seeks a method for setting a given number's leftmost unset bit. The first unset bit after the most significant set bit is considered the leftmost unset bit. Problem Statement Given a number n, the task is to set the left most bit of the binary expansion of the number that is unset. All the other bits should be left unchanged. If all the bits of the original number are already set, return the number. Examples Input: 46 Output: 62 Explanation Binary Expansion of 46 = 101110. Left most unset bit is 101110. Upon setting the underlined ...

Read More

Print the frequency of adjacent repeating characters in a given string

Vanshika Sood
Vanshika Sood
Updated on 25-Oct-2023 335 Views

A string is a data structure consisting of a sequence of characters. The end of the string is marked by a special character, called a null character, which is usually represented by the ASCII code 0. Problem Statement Given a string s of a certain length, the task at hand is to print adjacent repeating characters along with the frequency of their repetition. For Example Input: s = “committee” Output: [[m, 2], [t, 2], [e, 2]] Explanation The character m occurs consecutively twice. Similarly the character t and e also occur twice consecutively. Therefore we return the vector ...

Read More

Minimize removals to remove another string as a subsequence of a given string

Vanshika Sood
Vanshika Sood
Updated on 25-Oct-2023 370 Views

A subsequence refers to a sequence that can be obtained from another sequence by removing zero or more elements, without altering the order of the remaining elements. In simpler terms, a subsequence is derived by selecting elements from the original sequence, while preserving their relative order. For example, consider the sequence [1, 2, 3, 4]. Some possible subsequences of this sequence are: [1, 2], [1, 3, 4], [2, 4], [1, 2, 3, 4], [3], and [4]. Problem Statement The objective is to determine the minimum number of character removals from string s1 in order to eliminate any occurrence of ...

Read More

Check if given string is prefix subarray of the given array

Vanshika Sood
Vanshika Sood
Updated on 25-Oct-2023 327 Views

A subarray of an array is a contiguous part of the array in which we take a group of consecutive elements while also maintaining the relative ordering of elements as present in the original array. Example − Some valid subarrays are − etc. A prefix subarray is a special type of subarray that begins with the first element of the array and ends at some ith index where 0

Read More

Check if every row in given Matrix contains all the integers from 1 to N

Vanshika Sood
Vanshika Sood
Updated on 25-Oct-2023 303 Views

A matrix is a two-dimensional data structure made up of rows and columns set out like a grid of squares. Grids, multidimensional arrays, and tabular data are frequently represented using it. Problem Statement We are given a matrix of dimensions and the task is to check whether each row of the matrix consists of every number from 1 to n. The order of the numbers in the row do not matter. Return true if this statement holds true else return false. For Example Input: mtx = [[1, 2, 3], [3, 2, 1], [2, 1, 3]] Output: True ...

Read More

Numbers whose Factorials end with n Zeros

Vanshika Sood
Vanshika Sood
Updated on 08-Sep-2023 702 Views

A factorial of a number is the product of all positive integers up to the given number. For example, the factorial of 5 is denoted as 5! and is equal to the product of all positive integers up to 5: 5! = 5 x 4 x 3 x 2 x 1 = 120 The number of zeros at the end of the decimal representation of a number's factorial is referred to as the "trailing zeros" in a factorial. The factorial of 5, for instance, is 120, which has one trailing zero, while the factorial of 10, on the other hand, ...

Read More

Time Required to Meet in Equilateral Triangle

Vanshika Sood
Vanshika Sood
Updated on 08-Sep-2023 309 Views

An equilateral triangle is a triangle with all of its sides equal in length. As the three sides are equal, the three angles opposing the equal sides are also equal in magnitude. As a result, it is also known as an equiangular triangle, with each angle measuring 60 degrees. The centroid of an equilateral triangle is the point where its three medians intersect. In an equilateral triangle, all three sides are of equal length and all three angles are of equal measure, so each median will intersect at the same point, which is the centroid. Problem Statement Given length ...

Read More

Program to calculate Volume and Surface area of Hemisphere

Vanshika Sood
Vanshika Sood
Updated on 08-Sep-2023 522 Views

A sphere is a three-dimensional geometric shape that is perfectly round like a ball, while a hemisphere is one half of a sphere. In essence, a sphere would split into two hemispheres if it were sliced in half. Hemispheres are identified by their curving surface, which radiates out from the sphere's core. The Greek terms "hemi" (half) and "sphaira" (sphere) are where the name "hemisphere" comes from. Hemispheres are used to describe and simulate a variety of events in a number of disciplines, including geography, astronomy, mathematics, and physics. Volume of a Hemisphere The volume of a hemisphere is equal ...

Read More

Leibniz Harmonic Triangle

Vanshika Sood
Vanshika Sood
Updated on 08-Sep-2023 540 Views

The Leibniz harmonic triangle, also known as Leibniz's series or the Leibniz formula, is a triangular arrangement of numbers discovered by German mathematician and philosopher Gottfried Wilhelm Leibniz in the late 17th century. The Leibniz harmonic triangle is a triangular arrangement of fractions. We start at the top with the number and the outermost terms are reciprocal of the natural numbers depicting that particular row number. In general, a term in the leibniz harmonic triangle can be determined by the following equation, where r is the row number and c is the column number with the condition that c

Read More
Showing 1–10 of 27 articles
« Prev 1 2 3 Next »
Advertisements