Practice
Resources
Interview Guides
All Problems
Fast Track Courses
Community
Blog
Interview Preparation Kit
Video Courses
Contests
Online IDE
New
Online C++ Compiler
Online C Compiler
Online Python Compiler
Online Java Compiler
Online JavaScript Compiler
Free Mock
Powered By
Free Mock Assessment
Take popular mock tests for free with real life interview questions from top tech companies
Explore Mock Tests
Powered By
Mock Interview
Pair up with a peer like you and practise with hand-picked questions
Explore Mock Interviews
Events
New
Scaler
Please enter 3 or more characters
Experience Scaler
Experience Scaler
Profile
Settings
Help Requests
Profile
Settings
Help Requests
Login to experience InterviewBit
Sign in
Experience Scaler
Experience Scaler
Profile
Settings
Help Requests
Profile
Settings
Help Requests
Login to experience InterviewBit
Sign in
Practice
Improve your coding skills with our resources
Resources
Experience learning
Interview Guides
All Problems
Fast Track Courses
Community
Blog
Interview Preparation Kit
Video Courses
Contests
Compete in popular contests with top coders
Online IDE
Checkout our improved IDE
Online C++ Compiler
Online C Compiler
Online Python Compiler
Online Java Compiler
Online JavaScript Compiler
Free Mock
Assess yourself and prepare for interviews
Free Mock Assessment
Mock Interview
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER
Join Interviewbit
Get free unlimited access to our resources to help you prepare for your next tech interview
Sign Up or Login to get Started
Continue with Google
OR continue using other options
Are you sure you want to Exit?
You will not able to continue using resources without logging in.
Yes, Exit
No
Problem Discussion
Post a comment
This thread is for people who have not yet solved the problem. Please do not post solutions here.
S
sachit-gupta-0521901
9 months ago
Simple C++ solution using 2 for loop
1
Reply
D
dakshchhabra158_75aa
9 months ago
Easy O(1) memory and O(n) soution using cycles
1
Reply
S
shubham-choudhary_95
9 months ago
Why? NEED OF MODULO
1
Reply
C
chittudi-anil
11 months ago
CPP Easy solution A[i] = x+(y%n)*n;
4
Reply
S
shubham-sawlani
12 months ago
C++| O(N) O(1) space | DSU kind of concept arranging numbers which form a cycle
0
Reply
R
raghav-mahajan_172
about 1 year ago
No brainer solution
2
Reply
R
roy-darnell
over 1 year ago
Question is wrong
1
Reply
A
ashutosh-samantaray
almost 2 years ago
Solution is tricky, but lacks
1
Reply
H
haifeng-zhu
over 2 years ago
N in range [0, 2 ^ 31] with O(1) extra space
0
Reply
S
shashank-kumar_980
over 2 years ago
JAVA solution with T.C. = O(N) simple explanition + code
0
Reply
1
19uics013_vikash-yad
almost 3 years ago
Usingstlerase o(N)
0
Reply
I
iec2019100_c9cb36e22
almost 3 years ago
0(1) space solution
0
Reply
B
batul-bohra_317
almost 3 years ago
Good explanation https://www.quora.com/How-can-I-rearrange-a-given-array-so-that-
9
Reply
A
aditya-biswakarma
almost 3 years ago
No Extra Memeory C++
0
Reply
A
abhinav-kumar_179
almost 3 years ago
Easy C++ Solution 4 lines
6
Reply
J
jay-kishan
over 3 years ago
N * N does not overflow for a signed integer
2
Reply
A
akshat-dhiman_949
over 3 years ago
Approach To this Problem
0
Reply
S
sangram-jagadale
almost 4 years ago
Giving wrong answer - Me
0
Reply
A
atul-tripathi_616
almost 4 years ago
Python solution using pure maths
0
Reply
S
santanu-panda
almost 4 years ago
Python solution working in VS Code but not in Interviewbit's submission
0
Reply
H
hari-kishan_449
almost 4 years ago
Easy Hashing via unordered_map
0
Reply
F
freiman_e374219d98d5
about 4 years ago
Simple C++ - Recursive Solution
3
Reply
A
Achal_Parikh
about 4 years ago
Why my O(n) solution is accepted?
4
Reply
V
vikaskumareinstein
over 4 years ago
Confused with the IDE
0
Reply
T
tanmay-khabia
over 4 years ago
Iterative approach to the problem C++
0
Reply
A
adityaraghav26012001
over 4 years ago
Yet another very long solution which doesn't even pass all test cases ( fucking overflows )
0
Reply
A
ashish-kumar-singh_5
over 4 years ago
Submit & Run as Custom Test shows different answers
0
Reply
A
adarsh-agarwal_407
over 4 years ago
Rearrange Array-> https://youtu.be/XAbG2Bjs6NA
0
Reply
G
GranD_MasteR
over 4 years ago
Getting right answer on test with custom input but for the same test case gives wrong answer while submitting code
0
Reply
Post a comment
This thread is for people who have solved the problem. You may discuss your solutions here.
G
gopal_rander
9 months ago
Just Swapping! No manipulation of numbers
0
Reply
D
dvishal485
over 1 year ago
Solution using bit manipulation
0
Reply
I
indraneel1nallam
over 2 years ago
Geeksforgeeks O(1) space and O(n) time complexity python solution
0
Reply
R
ravjot-singh
over 2 years ago
Very easy C++ solution 4 lines of code
1
Reply
V
vikas-gupta_882
almost 3 years ago
Solved in O(N) time complexity with O(1) space complexity
0
Reply
S
s4r7h4k
almost 3 years ago
Simple C++ Bit Manipulation Solution - O(1) Space, O(N) Time
0
Reply
M
mijaguuk_b289da37f0c
over 3 years ago
Novel Java approach
0
Reply
S
sarvagya-gate-air-15
over 3 years ago
Recursive logic
0
Reply
A
ashish-manglani
almost 4 years ago
My vvip solution for future me (50 minutes of effort)
0
Reply
A
akash-reddy_312
almost 4 years ago
Commented Solution - O(1) space, O(n) time. Classic solution
0
Reply
A
ayushyadav935_665c0e
almost 4 years ago
Simple solution using hashing(C++)
0
Reply
D
digantachauduri06
almost 4 years ago
Even declaring a very large array worked!
2
Reply
S
shivam-jaiswal_138
almost 4 years ago
C++ solution using while loop
0
Reply
A
atharv-rustagi
almost 4 years ago
C++ 4 lines; O(n) time, O(1) space solution
2
Reply
R
rupeshdoneriya2000_8
almost 4 years ago
Please tell me the space complexity of my code
0
Reply
S
shivdeep-singh-bais
about 4 years ago
A real O(n) time and O(1) memory solution😂
0
Reply
H
hvthakur07_5faa0f14e
about 4 years ago
My simple java solution
0
Reply
P
prakash-ranjan_261
about 4 years ago
Java Hashmap solution O(1) space
0
Reply
N
nitin-grover
about 4 years ago
Very simple c++ sol
1
Reply
H
harshit-bhatt_846
about 4 years ago
Python 0(1) space encoding approach
0
Reply
L
lnn_pe8eoz
about 4 years ago
Very Simplest C++ Solution
1
Reply
S
shobhit-gupta_921
about 4 years ago
SuperEasy Solution To Understand
0
Reply
S
suryanshprabhat
over 4 years ago
2 lines Java Solution using ArrayList replaceAll() method
0
Reply
S
shriram-raghuvanshi
over 4 years ago
4 line code with A*n+B (A = Number to replace at A[i]and B = Old number at A[i]) ;)
0
Reply
S
sureshkumar-t
over 4 years ago
Another O(n) time and O(1) space approach
0
Reply
D
dvij-kalaria
over 4 years ago
O(1) space complexity and O(n) time complexity simple solution
0
Reply
T
TLE
almost 5 years ago
Easy C++ solution in O(1) space and in O(N) time
0
Reply
S
sumit-verma_761
almost 5 years ago
Mine approach is little different but easy to get: O(1)space
0
Reply
P
parmar-adarsh
almost 5 years ago
Why does this show wrong output
0
Reply
Click here to start solving coding interview questions
Join Interviewbit
Get free unlimited access to our resources to help you prepare for your next tech interview
Sign Up or Login to get Started
Continue with Google
OR continue using other options
Join Interviewbit
Get free unlimited access to our resources to help you prepare for your next tech interview
Sign Up or Login to get Started
Continue with Google
OR continue using other options
Unlock the complete InterviewBit
experience for free
Sign Up Using
Or use email
1 Million +
Strong Tech Community
500 +
Questions to Practice
100 +
Expert Interview Guides
Free Mock Assessment
Powered By
Fill up the details for personalised experience.
Phone Number
*
OTP will be sent to this number for verification
+1
*
Type to search
+1
No results found
Phone Number
Change Number
Graduation Year
*
Graduation Year
*
Type to search
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
No results found
*
Enter the expected year of graduation if you're student
Current Employer
Company Name
Type to search
No results found
College you graduated from
College/University Name
Type to search
No results found
Job Title
Job Title
Type to search
Engineering Leadership
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Co-founder
SDET
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer
Security Leadership
Database Administrator
Data Analyst
Data Engineer
Non Coder
Other
No results found
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account?
Log in
Free Mock Assessment
Powered By
Instructions from Interviewbit
Start Test