Chitresh-code / DSA_Worksheet

Worksheet posting DSA problems every day for GNIOT Students to solve and create PR's.
MIT License
17 stars 32 forks source link

Cycle sort #11

Open kesh230 opened 1 year ago

kesh230 commented 1 year ago

Sorting increasing or decreasing order in O(n) time of complexity.

You are given a read-only array of N integers with values also in the range 1to N both inclusive. Each integer appears exactly once except A which appears twice and B which is missing. The task is to find the repeating and missing numbers A and B where A repeats twice and B is missing.

Input Format The first line contains integer, n, the size of array arr[] The second line contains n space-separated integers arr[i].

Constraints 1<=n<=1000 -10000 <= arr[i] <= 10000, 0<=i<=n

Output Format The output contains two space-separated integers where the first number is the number that appears twice and the second integer is the number that is missing

Sample Input 0

5
3 1 2 5 3

Sample Output 0 3 4

kesh230 commented 1 year ago

can you plz assign this @Chitresh-code

Chitresh-code commented 1 year ago

Write the problem statement properly with the following info:

Do that and I'll assign it to you Happy hacking!

kesh230 commented 1 year ago

You are given a read-only array of N integers with values also in the range 1to N both inclusive. Each integer appears exactly once except A which appears twice and B which is missing. The task is to find the repeating and missing numbers A and B where A repeats twice and B is missing.

Input Format The first line contains integer , n, the size of array arr[] The second line contains n space separated integers arr[i].

Constraints 1<=n<=1000 -10000 <= arr[i] <= 10000, 0<=i<=n

Output Format The output contains two space separated integers where first number is the number which is appearing twice and second integer is the number which is missing

Sample Input 0 5 3 1 2 5 3

Sample Output 0 3 4

swarupsahu08 commented 1 year ago

@Chitresh-code Can you assign me this issue

Chitresh-code commented 1 year ago

@swarupsahu08 assigning this issue to you.

swarupsahu08 commented 1 year ago

@Chitresh-code Can I contribute this in java

Chitresh-code commented 1 year ago

@swarupsahu08 there's already a PR submitted for java, if their code is right your PR won't be merged.