# data[].attributes.body
Linked_list 15 concepts

# data[].attributes.body
//Priyanshu Kumar

ques:-

Find the maximum and minimum element in an array

Code:-

public class pp {

public static int[] maxminNumber(int arr[],int size){
                int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
          for(int i=0;i<arr.length;i++){
            if(arr[i]>max){
                min = max;
                max=arr[i];
            }
            else if(arr[i]<min && arr[i]!=max){
                min=arr[i];
            }
        }
        return new int[] {max,min}
       }
    public static void main(String[] args) {
        int myArray[]={4,5,6,7,1,3};
        for(int i=0;i<myArray.length;i++){
            System.out.print(myArray[i]+" ");
        }
        int [] rp = maxminNumber(myArray, myArray.length);
        System.out.println("Maximum number is"+rp[0]);
        System.out.println("Minimum number is"+rp[1]);
    }
}

# data[].attributes.body
class Solution(object):
    def findDuplicate(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        x = nums[0]
        y = nums[0]
        while True:
            x = nums[x]
            y = nums[nums[y]]
            if x == y:
                break
        x = nums[0]
        while x != y:
            x = nums[x]
            y = nums[y]
        return y

# data[].attributes.body
// Aniket Raj

class Solution {

public:

// Function to return the count of number of elements in union of two arrays.

int doUnion(vector<int> arr1, vector<int> arr2) {

// code here

int n1 = arr1.size(), n2 = arr2.size();

unordered_set<int> st;

for(int i = 0 ; i < n1 ; i++) st.insert(arr1[i]);

for(int i = 0 ; i < n2 ; i++) st.insert(arr2[i]);

return st.size();

}

};

# data[].attributes.body
HashSet<Integer> set = new HashSet<>();
        for(int i =0; i<n; i++)
        {
            set.add(a[i]);
        }
        for(int i =0; i<m; i++)
        {
            set.add(b[i]);
        }
        return set.size();

# data[].attributes.body
//Ashutosh singh class Solution {

class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int i = 0;
        for(int j = 0; j < nums.size(); j++){
            if(nums[j]  != 0){
                swap(nums[j],nums[i]);
                    i++;
            }
        }
    }
};

# data[].attributes.body
for(int i =0; i<arr.len; i++){

if(arr[i] != 0){

arr_new[j]= arr[i];

j++;

}

}

for(int i =j; i<arr.len; i++){

arr_new[i] = 0;

}

//Avi

# data[].attributes.body
static iny moveZeroes(int []arr){

int n = arr.length, int j=0;

for(int i=0; i<n; i++){

if(arr[i]!=0){

int temp = arr[i];

arr[i] = arr[j];

arr[j] = temp;

j++;

}

}

# data[].attributes.body
class Solution {
public:
// Arslan
    void moveZeroes(vector<int>& nums) {
        /*int i  = 0;
        int n = nums.size();
        for(int j = 0; j <n;j++){
            if(nums[j] != 0){
                swap(nums[i] , nums[j]);
                i++;
            }

        }
       */
       vector<int>arr;
       int n = nums.size();
       int j = 0;
       for(int i =0; i <n;i++){
        if(nums[i] != 0){
            swap(nums[i] , nums[j]);
            arr.push_back(nums[i]);
            j++;
        }
       }
    }
};

# data[].attributes.body
class Solution { public void moveZeroes(int[] nums) { int i = 0; int size = nums.length; for (int j = 0; j < size; j++) { if (nums[j] != 0) { // Swap nums[i] and nums[j] int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; i++; } } } }

# data[].attributes.body
// Aniket Raj
void moveZeroes(vector<int>& nums) {
        int n = nums.size();
        int i = 0;
        while(i < n && nums[i] != 0) i++;
        int j = i+1;
        if(j >= n) return;
        while(j != n) {
            if(nums[i] == 0 && nums[j] != 0) {
                swap(nums[i], nums[j]);
                i++;
                j++;
            } else if(nums[i] != 0) i++;
            else j++;
        }
    }

# data[].attributes.body
class Solution(object):
    def moveZeroes(self, nums):
        """
        :type nums: List[int]
        :rtype: None Do not return anything, modify nums in-place instead.
        """
        n = len(nums)
        i, j = 0, 0
        while i < n:
            if nums[i] != 0:
                nums[i], nums[j] = nums[j], nums[i]
                j += 1
            i += 1

# data[].attributes.body
for(int i =0;i<n;i++)

{

if(arr[i]!=0)

{

arr1[j] = arr[i];

j++;

}

}

for(int i = j;i<n;i++)

{

arr1[i] = 0;

}

//harsh kumar

# data[].attributes.body
//Pawan Kumar Singhclass Solution { public void moveZeroes(int[] nums) { int k=0; for(int i=0;i<nums.length;i++) { if(nums[i]!=0) { nums[k]=nums[i]; k++; } } for(int i=k;i<nums.length;i++) { nums[i]=0; } /* Using bubbe sort int numOfZeroes = 0; int n = nums.length; for (int i=0; i<nums.length; i++){ if (nums[i] == 0) numOfZeroes++; } for (int i = 0; i < numOfZeroes; i++) { for (int j = 0; j < n-1-i; j++) { if (nums[j] == 0){ int temp = nums[j]; nums[j] = nums[j+1]; nums[j+1] = temp; } } } */ } }

# data[].attributes.body
//ASHUTOHS SINGH class Solution { public: void moveZeroes(vector<int>& nums) { int i = 0; for(int j = 0; j < nums.size(); j++){ if(nums[j] != 0){ swap(nums[j],nums[i]); i++; } } } };

# data[].attributes.body
class Solution { public: // Arslan void moveZeroes(vector& nums) { /*int i = 0; int n = nums.size(); for(int j = 0; j arr; int n = nums.size(); int j = 0; for(int i =0; i

# data[].attributes.body
// Yasir

public static void pushZeroes(int arr[],int n) {

int k=0;

for(int i=0; i<n; i++) {

if(arr[i]!=0) {

arr[k++]=arr[i];

}

}

while(count<n) {

arr[k++]==0;

}

}

# data[].attributes.body
//Kumar Aman
 int s = -1;
        int e = -1;
        for(int i = 0; i < nums.size(); i++){
            if(nums[i] == 0 && s == -1){
                s = i;
                e = i;
            }
            else if(nums[i] != 0 && s != -1){
                swap(nums[i], nums[s]);
                s++;
                e++;
            }
            else if(nums[i] == 0){
                e++;
            }
        }

# data[].attributes.body
// Azmi
public void moveZeroes(int[] nums) {
      int j=0;
      for(inti=0;i<nums.length;i++){
           if(nums[i]!=0){
               int temp = nums[i];
               nums[i] = nums[j];
               nums[j] = temp;
               j++;
            }
        }
    }

# data[].attributes.body
//Ashutosh Singh

class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int n = nums.size();
        int k = 0;
        for(int i =0;i<n;i++){
            if(nums[i] != 0){
                nums[k] = nums[i];
                k++;
            }
        }
        for(int i=k;i<n;i++){
            nums[i]=0;
        }
    }
};

# data[].attributes.body
//Gungun Singh

class Solution { public void moveZeroes(int[] nums) { int j=0; for(int i=0; i<nums.length;i++){ if(nums[i] != 0){ int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; j++; } } } }

# data[].attributes.body
//Manish Kumar
class Solution {
    public void moveZeroes(int[] nums)
    {
        int k=0;
        for(int i=0;i<nums.length;i++)
        {
            if(nums[i]!=0)
            {
                nums[k]=nums[i];
                k++;
            }
        }

         for(int i=k;i<nums.length;i++)
         {
             nums[i]=0;
         }


         //Using Bubble Sort
         /*
        int n = nums.length;
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - 1 - i; j++) {
                if (nums[j] == 0) {
                    int temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = temp;
                }
            }
        }
        */
    }
}