Amazon Hackon Interview Experience
Last Updated :
03 Oct, 2023
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;
}
|
T.C= O(1)
S.C=O(1)
Keep reading ! Keep loving ! Keep sharing !
Happy Coding 🙂
PS: This is my first article on GFG.
Share your thoughts in the comments
Please Login to comment...