Skip to content

Commit

Permalink
new questions are added
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjaspreetsingh committed Oct 15, 2018
1 parent f4fa35c commit 139844f
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ASSIGNMENTS/ACIIIproduct.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Program to find the product of ASCII values of characters in a string
Given a string str. The task is to find the product of ASCII values of characters in the string.

Examples:

Input : str = "IS"
Output : 6059
73 * 83 = 6059

Input : str = "GfG"
Output : 514182
Binary file added ASSIGNMENTS/BikeRace.pdf
Binary file not shown.
33 changes: 33 additions & 0 deletions ASSIGNMENTS/BirthdayParty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Chef has invited his friends on his birthday party. There are total N friends that are coming at his home. You are given the arriving and leaving time of each friend and Q queries. Each Query consists of an integer t, you have to output the number of friends that are present at time t at Chef's home.

Input
The first line contains T, the number of testcases.

The first line of each testcase contain two space separated integers N and Q, then follow N lines containing two space separated integers ai bi, the arriving and leaving time of ith friend respectively.

Next Q lines contains a single integer t asking the number of friends at Chef's house present at time t.

Output
For each query, output the required answer in a new line.

Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 100000
1 ≤ Q ≤ 100000
1 ≤ ai ≤ bi ≤ 100000
1 ≤ t ≤ max of all bi
Example
Input:
1
3 3
1 2
2 2
2 3
1
2
3

Output:
1
3
1
Binary file added ASSIGNMENTS/BirthdayTreat.pdf
Binary file not shown.
Binary file added ASSIGNMENTS/DiagonalBinaryTree.pdf
Binary file not shown.
20 changes: 20 additions & 0 deletions ASSIGNMENTS/LCM GCD.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
LCM of given array elements
Given an array of n numbers, find LCM of it.

Input : {1, 2, 8, 3}
Output : 24

Input : {2, 7, 3, 9, 4}
Output : 252


GCD of more than two (or array) numbers
Given an array of numbers, find GCD of the array elements. In a previous post we find GCD of two number.

Examples:

Input : arr[] = {1, 2, 3}
Output : 1

Input : arr[] = {2, 4, 6, 8}
Output : 2
10 changes: 10 additions & 0 deletions ASSIGNMENTS/LargestSubarrayPrime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Length of largest sub-array having primes strictly greater than non-primes
Given an array ‘arr’ of length ‘n’. The task is to find the largest contiguous sub-array having the count of prime numbers strictly greater than the count of non-prime numbers.

Examples:

Input: arr[] = {4, 7, 4, 7, 11, 5, 4, 4, 4, 5}
Output: 9

Input: arr[] = { 1, 9, 3, 4, 5, 6, 7, 8 }
Output: 5
13 changes: 13 additions & 0 deletions ASSIGNMENTS/SumDoublyLinkedList.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Sum of all nodes in a doubly linked list divisible by a given number K
Given a doubly linked list containing N nodes and given a number K. The task is to find the sum of all such nodes which are divisible by K.

Examples:

Input: List = 15 <=> 16 <=> 10 <=> 9 <=> 6 <=> 7 <=> 17
K = 3
Output: Sum = 30

Input: List = 5 <=> 3 <=> 6 <=> 8 <=> 4 <=> 1 <=> 2 <=> 9
K = 2
Output: Sum = 20
Approach: The idea is to traverse the doubly linked list and check the nodes one by one. If a node’s value is divisible by K then add that node value to sum otherwise continue this process while the end of the list is not reached.

0 comments on commit 139844f

Please sign in to comment.