Tip 1 : Must do Previously asked Interviews Questions.
Tip 2 : Prepare OS, DBMS, OOPs, Computer Networks well.
Tip 3 : Prepare well for one project mentioned in the resume, the interviewer may ask any question related to the project, especially about the networking part of the project.
Tip 1 : Have at least 2 good projects mentioned in your resume with a link
Tip 2 : Focus on skills, internships, projects, and experiences.
Tip 3 : Make it simple, crisp, and one page
This was an online test on the hackerrank platform. The test consists of 3 coding questions to be solved in 90 mins.



1) MapSum(): Ninja has to initialize the ‘MapSum’.
2) insert(‘KEY’, ‘VAL’): Ninja has to insert this key-value pair in this ‘MapSum’.
3) sum(‘PREFIX’): Ninja has to find the sum of all values whose prefix of the keys is equal to ‘PREFIX’
During insertion, In the ‘MapSum’ if a ‘KEY’ is already present in the ‘MapSum’ then replace it with the new one.
var MapSum = function() {
this.map={};
};
/**
* @param {string} key
* @param {number} val
* @return {void}
*/
MapSum.prototype.insert = function(key, val) {
this.map[key]=val;
};
/**
* @param {string} prefix
* @return {number}
*/
MapSum.prototype.sum = function(prefix) {
let count=0;
for (let t in this.map){
if(t.indexOf(prefix)==0){
count+=this.map[t];
}
}
return count;
};



If ‘S’ = “beaninjacoder” and ‘ROW’ = 4
Then the zig-zag pattern is:
b j r
e n a e
a i c d
n o
Therefore, we will print “bjrenaeaicdno”.
First I am creating the zigzag pattern and filling in the empty spaces with 0's and then I am just traversing the pattern to get the final answer.
So first I am filling all the rows in first column, then I am filling one row each for the next columns until I move up again to the 0th row and the process repeats.
class Solution {
public String convert(String s, int numRows) {
ArrayList > pattern = new ArrayList<>();
int pos = 0;
int i = 0, k = 0;
String ans = "";
while(pos< s.length()){
ArrayList arr = new ArrayList();
//forming the column where every row has an element
if(i==0){
for(; i= 0) //taking care of a case where num of rows = 2
i = i-2;
else
i = 0;
continue;
}
//forming the column where only one row has an element
for(int j = 0 ; j < numRows; ++j){
if(pos< s.length() && j == i){
arr.add(s.charAt(pos++));
--i;
}
else
arr.add('0');
}
// System.out.println(arr + " , " + i);
pattern.add(arr);
// System.out.println(pattern);
}
// System.out.println(pattern);
for(i = 0 ; i for(int j = 0 ; j< pattern.size() ; ++j){
if((pattern.get(j)).get(i) != '0')
ans = ans + (pattern.get(j)).get(i);
}
}
return ans;
}
}



Do not allocate extra space for another array. You need to do this by modifying the given input array in place with O(1) extra memory.
'n' = 5, 'arr' = [1 2 2 2 3].
The new array will be [1 2 3].
So our answer is 3.
Java Solution
class Solution {
public int removeDuplicates(int[] nums) {
int index =1 ;
for(int i=0;i if(nums[i]!=nums[i+1]){
nums[index++]=nums[i+1];
}
}
return index;
}
}
This was 1st technical round taken by the software engineer at American Express. Interviewer was very friendly, he started with his introduction and then asked me to introduce myself.



You can’t sell without buying first.
For the given array [ 2, 100, 150, 120],
The maximum profit can be achieved by buying the stock at minute 0 when its price is Rs. 2 and selling it at minute 2 when its price is Rs. 150.
So, the output will be 148.
class Solution:
def maxProfit(self, prices: List[int]) -> int:
cheap = prices[0]
res = 0
for i in range (1, len(prices)):
cheap = min(cheap, prices[i])
res = max(res, prices[i] - cheap)
return res
Because we set the "cheap" as 0-index value from prices, we have to iterate from 1-index to the end.



If the given array is {1,5,2}, the returned array should be {1,5,3}.
Input array can contain leading zeros, but the output array should not contain any leading zeros (even if the input array contains leading zeroes).
For Example:
If the given array is {0,2}, the returned array should be {3}.
C++ solution
class Solution {
public:
vector plusOne(vector& digits) {
reverse(digits.begin(),digits.end());
int carry=0;
for(int i=0;i if(digits[i]!=9){
digits[i]+=1;
break;
}
else if(digits[i]==9){
carry=1;
digits[i]=0;
}
}
if(digits[digits.size()-1]==0){
digits.push_back(1);
}
reverse(digits.begin(),digits.end());
return digits;
}
};
This was 2nd technical round taken by the senior software developer. Interviewer was very friendly and helped my whenever I strucked. He started with his introduction and then asked me to introduce myself.
He asked about my project work in detail
What are OOPs concepts and its pillar
Is java support multiple inheritance or not
what are acid properties
Write a SQL query to find the 2nd largest salary from employee table



An array c is a subarray of array d if c can be obtained from d by deletion of several elements from the beginning and several elements from the end.
For e.g.- The non-empty subarrays of an array [1,2,3] will be- [1],[2],[3],[1,2],[2,3],[1,2,3].
If arr = {-3,4,5}.
All the possible non-empty contiguous subarrays of “arr” are {-3}, {4}, {5}, {-3,4}, {4,5} and {-3,4,5}.
The product of these subarrays are -3, 4, 5, -12, 20 and -60 respectively.
The maximum product is 20. Hence, the answer is 20.
Can you solve this in linear time and constant space complexity?
C++ solution
class Solution {
public:
int maxProduct(vector& nums) {
long int maxi = INT_MIN,prod=1;
for(auto& num : nums){
prod*=num;
maxi = max(maxi,prod);
if(prod==0) prod=1;
}
prod=1;
for(int i=nums.size()-1;i>=0;i--){
prod*=nums[i];
maxi = max(maxi,prod);
if(prod==0) prod=1;
}
return maxi;
}
};

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?