Found 1860 Articles for Data Structure

Hoax Number

Rinish Patidar
Updated on 28-Aug-2023 15:28:20

334 Views

The problem statement includes checking if the given number N, which will be the user input, is a hoax number or not. A Hoax number is a composite number whose sum of digits of its distinct prime factors is equal to the sum of the digits of the composite number itself. Since 1 is not a prime number, we don’t consider 1 as a sum of digits of distinct prime numbers. If a prime number is a factor of the composite number more than once, it is just considered once while taking the sum of digits of prime factors. In ... Read More

Hardy-Ramanujan Theorem

Rinish Patidar
Updated on 28-Aug-2023 15:27:05

261 Views

The Hardy−Ramanujan Theorem states that the number of distinct prime factors of any natural number N will be approximately equal to the value of $\mathrm{\log(\log N)}$ for most of the cases. For example, let’s consider N to be 1000. The number of distinct prime factors of 15 are 2 and 5 i.e. 2 distinct prime factors. The value of $\mathrm{\log_{e}(\log_{e}(1000))}$ is equal to 1.932 which is approximately equal to 2. The Hardy−Ramanujan theorem is proved in the above case. Since the theorem states that the number of distinct prime factors will be approximately equal to $\mathrm{\log(\log(N))}$ for most of ... Read More

Given a Number N in Decimal Base, find Number of its Digits in any Base (base b)

Rinish Patidar
Updated on 28-Aug-2023 15:25:51

356 Views

The problem statement includes finding the number of digits in N when represented in any base b numeral system. Initially, N is given in the base−10 numeral system. In the problem, we will be provided with a positive integer N in the input which will be in the base−10 numeral system and a positive integer b greater than 1. Our task will be to find the number of digits when N is being represented in the base−b numeral system. Any number represented in any base number, every digit from right represents the number of times power of that base number ... Read More

Count Numbers formed by given two Digit with Sum having given Digits

Rinish Patidar
Updated on 28-Aug-2023 15:23:19

180 Views

The problem statement includes counting the numbers formed by the given two digits, x and y of size N with sum having given digits only i.e. x and y. We need to count the distinct numbers which can be formed by the digits, x and y which will be the user input of size N where N ranges from 1 to 10^6. The N will also be provided in the input. The numbers formed using the digits, x and y of size N must be such that the sum of digits of the numbers formed should have only digits ... Read More

Frequency Measuring Techniques for Competitive Programming

Avinash Gupta
Updated on 28-Aug-2023 18:17:21

266 Views

In this article, we are going to find the different ways to find the frequency of numbers present in an array []. These methods are very useful in doing competitive programming for different problems for different cases. Sometimes, calculating the frequency of elements whether it is numbers or alphabets presented in the array is a complicated task. Various algorithms like Searching, array, divide and conquer can be used to find the repeated elements defined in the array. Note- Take an integer array. Let's explore the article, to know how it can be solved by using Java programming ... Read More

Smallest string divisible by two given Strings

Vanshika Sood
Updated on 27-Oct-2023 16:00:53

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

Nearest power of 2 of frequencies of each digit of a given number

Vanshika Sood
Updated on 27-Aug-2023 11:39:30

164 Views

The article describes a method to calculate the closest power of 2 for the frequency of each digit in a given number. The term "frequencies" refers to the count of occurrences of each unique digit in the number. Problem Statement Determine the occurrence count of each digit in a positive integer N. Then, for each digit, find the nearest power of 2 to its frequency. If there are two nearest powers of 2 for any frequency, print the larger one. Example Input n = 677755 Output 5 -> 2 6 -> 1 7 -> 4 ... Read More

Maximize count of occurrences of S2 in S1 as a subsequence by concatenating N1 and N2 times respectively

Vanshika Sood
Updated on 27-Aug-2023 11:35:53

337 Views

The following article discusses an approach to count the maximum occurrences of a string s2 in another string s1 after they have been concatenated N1 and N2 times respectively. This is an interesting type of pattern searching problem. In this article we have employed a relatively intuitive solution approach. Problem Statement The task is to determine the maximum number of non-overlapping occurrences of string s2 within string s1. The strings are concatenated multiple times: s1 is repeated n1 times, and s2 is repeated n2 times. Example Input s1 = “abc”, s2 = “ac”, n1 = 4, n2 ... Read More

Lexicographically smallest string with period K possible by replacing ‘?’s from a given string

Vanshika Sood
Updated on 27-Aug-2023 11:24:27

377 Views

A string is a period of K if and only if it repeats itself every K characters. For example, the string "abcabcabc" is a period of 3, because it repeats itself every 3 characters. The string "abcabc?abc" is not a period of 3, because the character '?' does not repeat itself every 3 characters. Problem Statement Given a string "str" containing N lowercase characters and a positive integer K, the objective is to replace every occurrence of the character '?' within the string "str" with a lowercase alphabet such that the resulting string forms a period of length ... Read More

Lexicographically largest string possible by repeatedly appending first character of two given strings

Vanshika Sood
Updated on 27-Aug-2023 10:07:19

369 Views

Lexicographic ordering refers to a method of comparing sequences of elements, akin to the ordering of words in a dictionary. The comparison process involves evaluating the first element of each sequence. If the first element of the first sequence is considered smaller than the first element of the second sequence, the first sequence is considered lexicographically less than the second sequence. Conversely, if the first element of the first sequence is deemed larger than the first element of the second sequence, the first sequence is lexicographically greater than the second sequence. Problem Statement The objective is to generate ... Read More

Advertisements