Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 2.13 KB

File metadata and controls

61 lines (44 loc) · 2.13 KB

Problem 1

Number of Ways

There are N number of people living in a room. Your task is to determine the count of the total number of ways you can divide these people into two groups 1 and 2 such that it satisfies the following condition:
• Each group should have at least one member.
Note: The answer can be large so you must print modulo 10^9 + 7.

Consider N= 3 which means that there are 3 people in the room named A. B, and C.
According to the condition, these are the following ways:
• Group 1 can have A and B while Group 2 can have C
• Group 1 can have A and C while Group 2 can have B.
• Group 1 can have B and C while Group 2 can have A
• Group 1 can have C while Group 2 can have A and B.
• Group 1 can have B while Group 2 can have A and C. • Group 1 can have A while Group 2 can have B and C.

Thus, there are 6 ways in which people can be divided in a way that each group contains at least one of the members.


Test Case 1


Input:
3

Output :
6


Problem 2

Maximum Value Subarray
You are given an array arr of size N containing positive integers.
Let's define value of an array as the bitwise AND of all elements of that array. if there is just one element in the array then the value of the array is equal to the first element of the array.
For example value of array arr = (3.1) is 3 &1=1, where & denotes the bitwise AND operator.


Test Case 1


Input :
3

Output:
6



This file is created by Kiranpal Singh
For Data Structures and Algorithm snippets, click here

kiranpalsingh