Sort 0 1 You have been given an integer array/list(ARR) of size N that contains only integers, 0 and 1. Write a function to sort this array/list. Think of a solution which scans the array/list only once and don't require use of an extra array/list. Note: You need to change in the given array/list itself. Hence, no ...

read more
AnswerBot
10mo
The function sorts an integer array containing only 0s and 1s in linear time complexity.Use two pointers, one starting from the beginning and the other from the end of the array.Swap the elements at t...
see more
CodingNinjas
author
2y
import java.util.Arrays;public class Solution { public static void sortZeroesAndOne(int[] arr) {int len=arr.length;int arr1[]=new int[len];int c=0;for (int i=0;i if(arr[i]!=0){arr1[c]=arr[i];c++;...
see more
CodingNinjas
author
2y
Space Complexity: Explanation: Time Complexity: Explanation:
Add answer anonymously...
Deloitte Java Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
55 L+

Reviews

5 L+

Interviews

2 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2023 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Hello, Guest
Contribute to help millions!
Write a review
Share interview
Contribute salary
Add office photos
Add office benefits