Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
This was an online coding round where we had 2 questions to solve under 90 minutes . Both the questions were of easy to medium difficulty .
Approach :
1) Convert all 0's to -1's .
2) Now , the questions boils down to finding the number of subarrays with sum=0
3) This is a very standard problem which can be solved in O(N) using Hashing .
4) Maintain a Hash Map which keeps a track of all the prefix sums encountered so far
5) Maintain an answer variable and at each step do : ans+=map[prefixSum]
6) Finally return ans
1. The integers x,y and z might not be distinct , but they should be present at different locations in the array i.e if a[i] = x, a[j] = y and a[k] = z, then i,j and k should be pairwise distinct.
2. The integers a,b and c can be present in any order in the given array.
Approach :
1) I solved it in O(N^2) approach .
2) Sort the array
3) Initially map all the elements of the array to their index in a Hash Map or a Hash Set
4) Now , run 2 for loops and for every x^2 + y^2 ,check if there exists a z^2 s.t x^2+y^2=z^2 and the index of z^2 is different than both the indices of x and y
I was asked to solve 3 preety basic DSA questions in this round and discuss their respective time complexities and then we moved onto OOPS where the interviewer asked me some questions related to JAVA as well as C as I had mentioned both of them in my Resume . At the end , I was asked to write a simple SQL query to join two tables . Overall this round was preety intense and I tried to give my best .
String 'S' is NOT case sensitive.
Let S = “c1 O$d@eeD o1c”.
If we ignore the special characters, whitespaces and convert all uppercase letters to lowercase, we get S = “c1odeedo1c”, which is a palindrome. Hence, the given string is also a palindrome.
Approach 1 :
1) Initialise a string named rev with the given string .
2) Reverse the string rev.
3) Now, if s is a palindrome then we would have rev==s , return true if rev==s and false otherwise
TC : O(N) where N=length of the string
SC : O(1)
Approach 2(Using Two Pointers) :
1) Keep pointer i=0 and j=n-1 where n=length of the string
2) Run a loop till i<=j and check if s[i]==s[j] for the condition of palindrome
3) If at any point s[i]!=s[j] then simply return false from the loop
4) Else return true after the end of the loop.
TC : O(N)
SC : O(1)
Fn = F(n-1) + F(n-2)
Approach :
Using Recursion :
1) Create a recursive function (int fib(int n) ) which takes the number of terms n of the Fibonacci Series
2) Base Case : if(n<=1) return n;
3) Recurrence Relation : fib(n)=fib(n-1)+fib(n-2)
4) Optimise the above code using memoisation i.e., if(dp[n]!=0)return dp[n] and fianlly store the answer into dp[n]
5) Traverse the dp array and print the output.
TC : O(n)
SC : O(n)
Without using Recursion :
1) Maintain two variables a=0,b=1
2) Print a and b , the first two terms of the Fibonacci Series
3) Traverse the loop from 2 to n and make c=a+b , a=b b=c
4) Print c at every step from 2 to n .
TC : O(n)
SC : O(1)
Approach 1 (Without using Sieve of Eratosthenes) :
1) For every number from 2 to n check if is prime or not .
2) The check prime function which checks if a number is prime or not can be implemented in O(N^1/2) complexity by running a loop from i= 2 toi= N^1/2 and then checking if N%i==0 or not , if N%i==0 simply return false else return true
TC : O(N^3/2)
SC : O(1)
Approach 2 (Using Sieve of Eratosthenes) :
1) Initilialise a boolean prime array of size n+1 where prime[i] denotes if i is a prime number or not.
2) Run a loop from i=2 to i=N^1/2.
3) For every i if prime[i] is true, again run a loop from j=i to j<=n where j increases by i every time (j+=i) , this loops marks all the multiples of i as false in the prime array
4) Finally output the prime array where prime[i]==true.
TC : O(N*log(log(N)))
SC : O(N)
What is Garbage collector in JAVA?
Answer :
1) Garbage Collection in Java is a process by which the programs perform memory management automatically.
2) The Garbage Collector(GC) finds the unused objects and deletes them to reclaim the memory.
3) In Java, dynamic memory allocation of objects is achieved using the new operator that uses some memory and the memory remains allocated until there are references for the use of the object.
4) When there are no references to an object, it is assumed to be no longer needed, and the memory, occupied by the object can be reclaimed.
5) There is no explicit need to destroy an object as Java handles the de-allocation automatically.
The technique that accomplishes this is known as Garbage Collection. Programs that do not de-allocate memory can eventually crash when there is no memory left in the system to allocate. These programs are said to have memory leaks.
Garbage collection in Java happens automatically during the lifetime of the program, eliminating the need to de- allocate memory and thereby avoiding memory leaks.
In C language, it is the programmer’s responsibility to de-allocate memory allocated dynamically using free() function.
This is where Java memory management leads.
What is Static variable in C ?
Answer :
1) Static variables are initialized only once.
2) The compiler persists with the variable till the end of the program.
3) Static variables can be defined inside or outside the function.
4) They are local to the block.
5) The default value of static variables is zero.
6) The static variables are alive till the execution of the program.
Here is the syntax of static variables in C language,
static datatype variable_name = value;
Here,
datatype − The datatype of variable like int, char, float etc.
variable_name − This is the name of variable given by user.
value − Any value to initialize the variable. By default, it is zero.
Explain Singleton Class in Java
Answer :
1) In object-oriented programming, a singleton class is a class that can have only one object (an instance of the class) at a time.
2) After first time, if we try to instantiate the Singleton class, the new variable also points to the first instance created.
3) So whatever modifications we do to any variable inside the class through any instance, it affects the variable of the single instance created and is visible if we access that variable through any variable of that class type defined.
The key points while defining class as singleton class are :
1) Make constructor private.
2) Write a static method that has return type object of this singleton class. Here, the concept of Lazy initialization is used to write this static method.
Write a query that joins two tables A and B having common attribute ID and selects records(ID_NAME) that have matching ID values in both tables .
SELECT A.ID_Name, B.ID_Name
FROM A
INNER JOIN B ON A.ID=B.ID;
This was a typical HR round with some standard Behavioral questions like my interests, weaknesses, strengths, family background, are you willing to relocate or travel , why Amdocs, CEO of Amdocs etc.
Why do you want to work at amdocs?
Answer :
a) It is an IT company that caters to the telecommunication domain. The business involved in the telecommunication domain is interesting and can widen your chances of switching into various fields be it in software, hardware or networking profiles. Also, Amdocs carries a good brand name in its domain.
b) Amdocs employees get to enjoy a positive and happy work environment.
c) It is truly an employee friendly organisation.I say this because Amdocs policies are employee oriented above anything else.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you select an element by class name in CSS?