Vaishnavi Tripathi has Published 24 Articles

Largest number that is not a perfect square

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 05-Oct-2023 11:34:32

77 Views

In this article, we will discuss two different approaches to find out the largest number smaller than a given number which is not a perfect square. In the first approach, we will run a loop to check for every number until we find the desired number while in the second ... Read More

k smallest elements in same order using O(1) extra space

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 05-Oct-2023 11:32:10

49 Views

We have an array "nums" consisting of "size" elements and an integer "number" denoting the number of smallest elements we have to return. Our task is to find out the "number" smallest elements from the given array. The order of the elements should be preserved and we are not allowed ... Read More

Total numbers with no repeated digits in a range

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 16-Aug-2023 10:38:47

2K+ Views

In this article, we will discuss different approaches to calculate the number of positive integers which have no repeated digits between a given range Low to high. The first approach is a brute force approach which iterates over all the numbers in the range and check if they contain repeated ... Read More

Tomohiko Sakamoto’s Algorithm- Finding the day of the week

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 16-Aug-2023 10:32:42

184 Views

In this article, we will discuss what is Tomohiko Sakamoto’s algorithm and how this algorithm is used to identify which day of the week does the given date occurs. There are multiple algorithms to know the day of the week but this algorithm is the most powerful one. This algorithm ... Read More

Recursive Practice Problems with Solutions

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 16-Aug-2023 10:22:31

748 Views

In this article, we will discuss a few recursive practice problems with their detailed solutions. Let us first understand what recursion is and how it works: Recursion − Recursion is a programming technique in which a function or method calls itself multiple times in order to solve a problem. ... Read More

Swap every two bits in bytes

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 16-Aug-2023 10:16:20

151 Views

In this article, we will discuss the code solution to swap every alternate bit in a given number and return the resultant number. We will use the concept of bit manipulation in order to solve the problem in constant time without using any loops. Problem statement − We are ... Read More

Sum of Series (n^2-1^2) + 2(n^2-2^2) +….n(n^2-n^2)

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 16-Aug-2023 10:14:31

44 Views

In this article, we will study different approaches to calculate the sum of the series- (n^2 - 1^2) + 2(n^2 - 2^2) + …. n(n^2 - n^2). In the first approach, we will calculate the series sum one by one for each i in the range 1 to n and ... Read More

Sort an array containing two types of elements

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 11-Apr-2023 17:02:38

195 Views

There are different approaches to sort an array containing only two types of elements i.e., only 1’s and 0’s. We will discuss three different approaches to do so. First approach simply uses a predefined sort() function to sort the given array. Second approach is a count sort approach in which ... Read More

Expressing factorial n as sum of consecutive numbers

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 11-Apr-2023 17:01:33

211 Views

We will discuss two approaches to find out how we can express the factorial of a number as the sum of consecutive numbers. First one is a straightforward and simple approach while in the other approach we use the concept of arithmetic progression to make it less complex in terms ... Read More

Sorting array except elements in a subarray

Vaishnavi Tripathi

Vaishnavi Tripathi

Updated on 11-Apr-2023 17:00:26

352 Views

This article is about how we can sort an array by neglecting a subarray of elements present in the same array. We will discuss two approaches for the same. The first approach is a brute force approach with time complexity O(n*n) while the second approach is by using an additional ... Read More

Advertisements