Open In App

Amazon Hackon Interview Experience

Last Updated : 03 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Quiz Round:

There were 20 Questions based on C, C++, Java, and Data Structures and algo. Questions were MCQ-based and some patterns were like finding a missing code or something like that.

Level -Easy

Coding Round:

In this round, the total problems were 2. Out of which 1 problem was based on string and the other was based on basic Math.

Problem 1: Find the first non-repeating char from a given string.

Solution link : https://www.geeksforgeeks.org/given-a-string-find-its-first-non-repeating-character/

Problem 2: Find the difference between the maximum lcm formed by any pairs from an array and the maximum gcd that can be formed by any pairs.

Solution link :

C++




#include <iostream>
using namespace std;
long long max_lcm_gcd_diff(long long n){
  long long max_gcd_pair=n/2;
  long long max_lcm_pair=n*(n-1);
  return max_lcm_pair-max_gcd_pair;
int main() {
    long long n;
      cin>>n;
      long long res=max_lcm_gcd_diff(n);
        
    cout << res<<endl;
    return 0;
}
//programmed by Nazim Qureshi :)Happy Coding


T.C= O(1)

S.C=O(1)

Keep reading ! Keep loving ! Keep sharing !

Happy Coding 🙂

PS: This is my first article on GFG.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads