Skip to content

Latest commit

 

History

History
78 lines (59 loc) · 2.07 KB

File metadata and controls

78 lines (59 loc) · 2.07 KB

Problem 1

Playing With Beads
There are N people in a group labeled from 1 to N. People are connected to each other via threads in the following manner:
The person with label number K is connected to all the persons with label J such that exactly divides K. Beads can be passed through the threads. If a person P has a bead, in how many ways can the bead be passed in the network of threads so that it returns to the same person within X moves or less? MOVE: Passing the bead from one person to the other.

Input Specification:
Input1: N, denoting the number of people.
Input2: P, label of the person having the bead.
Input3: X, maximum number of moves that can be made.


Test Case 1


Input :
3
2
2

Output:
1



Test Case 2


Input :
3
2
4

Output:
3


Problem 2

Arrangement
Given an array of size n, write a function to rearrange the numbers of the array in such a way that even and odd numbers are arranged alternatively in increasing order.


Test Case 1


Input :
5
9 12 23 8 5

Output:
5 8 9 12 23



Test Case 2


Input :
5
47 49 36 98 90

Output:
36 47 90 4 98



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

kiranpalsingh