Saturday, 8 July 2017

Amazon

There are Many Efficient Solutions Than this

Amazon - First Round -1
*******************

Count the number of duplicate Elements  present in the array 

Sample Input:
10
1 2 2 4 4 5 5 6 6 10
 Sample Output:
4

Explanation :
2 present twice count is incremented
4 present twice count is incremented
5 present twice count is incremented
6 present twice count is incremented


#include <stdio.h>
#include <limits.h>
int main() {
    int n,max=0,hash[1000]={0},count=0;
    scanf("%d",&n);
    int arr[n],i;   
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        hash[arr[i]]++;       // the values are stored in the hash table
        if(arr[i]>max)
        {
            max = arr[i];   // for finding the max value of array
        }
    }
    for(i=0;i<=max;i++)
    {
        if(hash[i]>1)    //if a number present more than once 
         count++;
    }
    printf("%d",count);
    return 0;
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Amazon- First Round -2
*****************

Given two arrays merge and sort the arrays

Sample Input:
5                            --->size of the array
2 4 6 8 10              ---->Elements of array 1
1 3 5 7 9                ---->Elements of array 2

Sample Output:

1 2 3 4 5 6 7 8 9 10 


// The vector is similar to the array
// push_back() is used to insert the value into the vector
// size() is used to find the length of the array


#include<bits/stdc++.h>
using namespace std;
#define lli long long int

vector<lli> mergeArray(vector<lli> a,vector<lli> b)
{
      vector<lli> res;

      lli size1=a.size(),size2=b.size();
      lli i=0,j=0;

        while((i<size1)&&(j<size2))
        {
                if(a[i]<b[j])
                {
                        res.push_back(a[i]);
                        i++;               // if smallest element the values are pushed into this
                      
                }
                else
                {   
                        res.push_back(b[j]);
                         j++;                 // if largest element the values are pushed into this
                       
                }
        }
        while(i<size1)
        {
           res.push_back(a[i]); // in some Testcases only these two conditions needed
            i++;   
        }
        while(j<size2)
        {
            res.push_back(b[j]);
            j++;
        }
        return res;
}
        int main()
        {
                vector<lli> a,b;
                lli n;
                cin>>n;
                for(lli i=0;i<n;i++)
                {
                        lli k;
                        cin>>k;
                        a.push_back(k);                //Reading the first array
                }
                for(lli i=0;i<n;i++)
                {
                        lli k;
                        cin>>k;
                        b.push_back(k);             //Reading the second  array
                }
                vector<lli> res=mergeArray(a,b);
                       n+=n;                           //The vectors are  passed to the function
               
                for(lli i=0;i<n;i++)
                     {
                           cout<<res[i]<<" ";
                      }
        }




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Amazon Second Round - 1
*****************
Even numbers at Even Positions and Odd numbers at odd numbers at Positions if Exceeds the array is Untouched
http://www.crazyforcode.com/rearrange-array-even-numbers-odd-numbers/


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Amazon Second Round - 2
*******************

Given a string Count the number of unequalities and make as Palindrome
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Amazon Third Round - 1
*****************

 Search in the array:
                        http://www.geeksforgeeks.org/efficient-search-in-an-array-where-difference-between-adjacent-is-1/


 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Amazon Third Round - 2
*****************

Sort the array:
                            http://www.geeksforgeeks.org/sort-an-array-of-0s-1s-and-2s/   

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Amazon - Fourth Round
*****************
  •  Testing     --->An application sends an automatic Birthday wishes Write test case for that
  • Troubleshooting ---> An ecommerce Website Located in 14 countries Example(an website is located in many countries In one country alone in one Account book is not downloading troubleshoot that)
  • Linux Comands
  • Dbms (SQL Querries)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




Amazon - Fifth Round
*****************
  •  Project                                      
                                    If  Web (HTML, CSS ,JAVA ,JAVASRIPT ,SERVLET , DBMS)
  •  Testing 
  •  Troubleshooting
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


No comments:

Post a Comment

Troubleshooting in SQL

1. SSRS Error  Round () need to be done in  SQL itself  2. Default Date In SSRS  Start Date =CDate(Format(DateAdd("d",-50,Now()), ...