
Asked in MediBuddy
Given an array of integers, rearrange the elements such that all odd numbers are placed on the left-hand side (LHS) and all even numbers are placed on the right-hand side (RHS).
Adeeb Zahin Farooqui
9mo
let ar = [1,2,3,4,5,6,7,8,9] let i=0,j=1,n=ar.length while(n-j > i) { if(ar[i]%2==0) { if(ar[n-j]%2!=0) { let temp = ar[i]; ar[i] = ar[n-j]; ar[n-j] = temp; j++; i++; }else { j++; } }else { i++; } }
Help your peers!
Add answer anonymously...
Top Software Engineer Interview Questions Asked at MediBuddy
Q. How do you check if a number is an integer?
Q. Given a sorted array nums, remove the duplicates in-place such that each element...read more
Q. How would you evaluate a BODMAS expression?
Interview Questions Asked to Software Engineer at Other Companies
Top Skill-Based Questions for MediBuddy Software Engineer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

