Given two integers N and K, the goal is to find the count of numbers such that they follow below conditions −Number=K Where count is the number of prime numbers less than or equal to Number.For ExampleInputN = 5, K = 2OutputCount of numbers < = N whose difference with the count of primes upto them is > = K are: 2ExplanationThe numbers that follow the conditions are: 5 ( 5−2>=2 ) and 4 ( 4−2>=2 )InputN = 10, K = 6OutputCount of numbers < = N whose difference with the count of primes upto them is > = K ... Read More
Given two numbers e and p. The goal is to count the number of ways in which we can divide e elements of a set into p partitions/subsets.For ExampleInpute=4 p=2OutputCount of number of ways to partition a set into k subsets are: 7ExplanationIf elements are: a b c d then ways to divide them into 2 partitions are: (a, b, c)−(d), (a, b)−(c, d), (a, b, c)−(d), (a)−(b, c, d), (a, c)−(b, d), (a, c, d)−(b), (a, b, d)−(c). Total 7 ways.Inpute=2 p=2OutputCount of number of ways to partition a set into k subsets are: 1ExplanationIf elements are: a b ... Read More
Given an array of positive numbers. Each element represents the maximum number of jumps that can be made from that index to reach the end of the array. The goal is to find the number of jumps that can be made from that element to reach the end. If arr[] is [ 1, 2, 3 ] then for 1 jumps can be 1, for 2 jumps can be 1 or 2 and for 3 jumps can be made 1, 2 or 3.For ExampleInputarr[] = {1, 2, 3}OutputCount of number of ways to jump to reach end are: 1 1 0ExplanationFor ... Read More
Given an integer num as input. The goal is to find the number of trailing zeroes in the binary representation of num using bitset.A bitset stores the bits 0s and 1s in it. It is an array of bits.For ExampleInputnum = 10OutputCount of number of trailing zeros in Binary representation of a number using Bitset are: 1ExplanationThe number 10 in binary is represented as 1010 so trailing zeroes in it is 1.Inputnum = 64OutputCount of number of trailing zeros in Binary representation of a number using Bitset are: 6ExplanationThe number 64 in binary is represented as 10000000 so trailing zeroes ... Read More
Given an integer num as input. The goal is to find the number of trailing zeroes in the product 11 X 22 X 33 X…X numnum.For ExampleInputnum=5OutputCount of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: 5ExplanationThe number of 2s and 5s in the product will be: 11 * 22* 33* 44* 55=11 * 22* 33* (22)4* 55. So total 10 2s and 5 5s, minimum is 5 so trailing zeroes will be 5.Inputnum=10OutputCount of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: 5ExplanationThe number of 2s and 5s in the product will be: 11 *22*33*44*55*66 *77*88*99*1010 = 11 *22*33*44*55*66 *77*88*99*(2*5)10. So ... Read More
Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName) values('Chris'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(StudentName) values('David'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(StudentName) values('Sam'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(StudentName) values('Mike'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will ... Read More
Given a string str[] containing lowercase alphabets only and an integer value k. The goal is to find the number of possible substrings of str that have exactly k distinct elements.For ExampleInputstr= ”pqr” k=2OutputCount of number of substrings with exactly k distinct characters are: 2ExplanationThe substrings having exactly 2 distinct elements are: “pq”, “qr”.Inputstr= ”stristr” k=4OutputCount of number of substrings with exactly k distinct characters are: 10ExplanationThe substrings having exactly 2 distinct elements are: “stri”, “tris”, “rist”, “istr”, “stris”, “trist”, “ristr”, “strist”, “tristr”, “stristr”.Approach used in the below program is as follows −In this approach we will an array array[26] ... Read More
The .NET centric applications are meant to windows operating system up till now, but now Microsoft has introduced a new cross-platform application called Mono which enables the execution of the application developed under the .NET platform in Linux environment by giving an impression in such a way that as if we are running Linux package rather than executing .exe file.MonoMono is an open-source utility that allows the developer to execute .NET centric applications on other platforms such as Mac or Linux as it provides an installation package for Windows platform to compile and execute .NET assemblies on Windows OS without ever ... Read More
Given an array arr[] containing positive numbers. The goal is to find subsets of elements of arr[] such that the median of values of the subset is also present in that set.For ExampleInputarr[] = { 1, 2, 3 }OutputCount of number of subsets whose median is also present in the same subset are: 4ExplanationThe sets with their medians in that same set are: [ 1 ], median is 1 [ 2 ], median is 2 [ 3 ], median is 3 [ 1, 2, 3 ], median is 2Inputarr[] = { 4, 6, 5 }OutputCount of number of subsets whose ... Read More
Given an array ar, containing positive numbers and an array GCD[] containing gcd values.The goal is to find the number of subsets of elements of arr[] that have gcd values as given in GCD[].For ExampleInputarr[] = {10, 5, 6, 3}, GCD[] = {2, 3, 5}OutputCount of number of subsets of a set with GCD equal to a given number are: 1 2 2ExplanationThe subsets with GCD equal to 2 is [ 10, 6 ]. Subsets with GCD equal to 3 is [ 3 ], [ 6, 3 ] Subsets with GCD equal to 5 is [ 5 ], [ 10, ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP