pratik-choudhari / AlgoCode

Welcome everyone!🌟 Here you can solve problems, build scrappers and much more💻
https://github.com/pratik-choudhari/AlgoCode
MIT License
131 stars 166 forks source link

Can we sort ? #305

Closed PulkitPansari13 closed 3 years ago

PulkitPansari13 commented 3 years ago

Feature ✅

Description

Given an array A with n integers return True if it is possible to sort the array in increasing order by swapping the i-th element A[i] with the (i+k)-th element A[i+k] else return False. You may perform the operation any number of times.

Input format

n k A1 A2 A3 ......An

Example

input : 6 1 2 4 1 3 5 8 output: True

input: 6 2 4 2 7 1 3 6 output: False

input: 4 2 4 7 1 3 output: True

In sample 1, we can always swap adjacent elements and we will get sorted array In sample 2, no swapping will lead to a sorted array In sample 3, we can swap 1st and 3rd element as well as 2nd and 4th element

Checklist:

Contributors are supposed to mention their coding language while asking for assignment

raj2729 commented 3 years ago

Hi @pratik-choudhari , I would like to do this code in Java . Could you please assign me for the same ?

sarthak-21 commented 3 years ago

I would like to do this code in C. May I?

raj2729 commented 3 years ago

Hi @pratik-choudhari , I would like to do this code in Java . Could you please assign me for the same ?

I have added the implementation for the required problem in Java and made a pull request . If any more changes are to be made , please do let me know .Thank you !

Isha2208 commented 3 years ago

Hey, I would like to contribute in C/C++ language. Can you assign it to me

KompuDan commented 3 years ago

hi, can i contribute with this? i would use python

pratik-choudhari commented 3 years ago

@KompuDan You are assigned to 2 issues, it's the max limit for this repo.

anshika0207 commented 3 years ago

@pratik-choudhari can you assign this to me? I can code in python3