Arnab Chakraborty has Published 4293 Articles

Ugly Number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 10:39:27

967 Views

Ugly numbers are those numbers whose prime factors are 2, 3 or 5. From 1 to 15, there are 11 ugly numbers 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15. The numbers 7, 11, 13 are not ugly because they are prime. The number 14 is not ... Read More

Valid Anagram in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 10:33:32

648 Views

Anagrams are basically all permutations of a given string or pattern. This pattern searching algorithm is slightly different. In this case, not only the exact pattern is searched, it searches all possible arrangements of the given pattern in the text. So if the inputs are “ANAGRAM” and “NAAGARM”, then they ... Read More

Power of Two in C

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 10:28:29

885 Views

Suppose we have a number n. We have to check whether the number is the power of 2 or not. So is n = 16, then the output will be true, if n = 12, it will be false.To solve this we will use logical operations. If we see the ... Read More

Invert Binary Tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 10:26:40

979 Views

Suppose we have a binary tree. our task is to create an inverted binary tree. So if the tree is like below −The inverted tree will be likeTo solve this, we will use a recursive approachif the root is null, then returnswap the left and right pointersrecursively solve left subtree ... Read More

Reverse Linked List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:57:13

524 Views

Suppose we have a linked list, we have to reverse it. So if the list is like 1 → 3 → 5 → 7, then the new reversed list will be 7 → 5 → 3 → 1To solve this, we will follow this approach −Define one procedure to perform ... Read More

House Robber in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:50:44

1K+ Views

Suppose there is a city, and each house in the city has a certain amount. One robber wants to rob the money in one single night. The city has one security system, that is as if two consecutive houses are broken on the same night, then it will automatically call ... Read More

Rotate Array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:45:51

717 Views

Suppose we have an array A. We have to rotate right it k steps. So if the array is A = [5, 7, 3, 6, 8, 1, 5, 4], and k = 3, then the output will be [1, 5, 4, 5, 7, 3, 6, 8]. The steps are like[4, ... Read More

Factorial Trailing Zeroes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:41:55

267 Views

Here we will see how to calculate the number of trailing 0s for the result of factorial of any number. So if the n = 5, then 5! = 120. There is only one trailing 0. For 20! it will be 4 zeros as 20! = 2432902008176640000.The easiest approach is ... Read More

Excel Sheet Column Number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:40:10

826 Views

We know that the excel column numbers are alphabetic. It starts from A, and after Z, it will AA, AB, to ZZ, then again AAA, AAB, to ZZZ and so on. So column 1 is A, column 27 is Z. Here we will see how to get the column letter ... Read More

Majority Element in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:37:37

1K+ Views

Suppose we have an array; we have to check whether given number x is the majority element of that array or not. The array is sorted. One element is said to be the majority element when it appears n/2 times in the array. Suppose an array is like {1, 2, ... Read More

Advertisements