Walmart interview experience ?
I love learning about technology and sharing that with others
I have recently attended the walmart interview for the support role. This role is more inclined towards the support role, where the interviewer wants to know whether you can work with tools like Grafana, Splunk or similar logging tools. He also wants to understand whether you will be able to write SQL Query or not .
So now I will discuss all the questions that were asked.
Java:
Apart from the below mentioned questions,
- Questions were asked on javascript, such as what is closure. How you will disable the back button in the browser if we don't want the user to go to the previous page.
I will be explaining each of the question in detail also but right now I just wanted to log this.
1.Find the number of occurrences of the word. String str="How are you , how does it happened";
//in this question we can create a hashmap with the each word as key and then we can keep the count in the value with that we will be able to get the count of the each word
below mentioned is just the prototype code not the actual solution but i think you guys can write your own solution
public static void countWordOccurences(String s) {
HashMap<String,Integer> map=new HashMap<>();
String array[]=str.split("");
foreach(String s: array) {
if(map.containsKey(s)) {
//increase the count of
int currentValue=map.get(s);
map.put(s,++currentValue);
}
else {
// give the value as 1
map.put(s,1);
}
}
for(Map.Entry() singleMapEntry: map.entrySet() ) {
System.out.println( singleMapEntry.getKey() + " " singleMapEntry.getValue()) ;
}
}
Questions :
- What will be the time complexity
- What will be the space complexity
- What will happend if the key size in hashmap is bigger.
So Lets understand how time complexity works
function add(num1, num2) {
let total = num1 + num2;
return total;
};
in the above mentioned code the time complexity O(1) how , since the operation what is happening does not depend on the input size, what ever the input will be addition will occur only once there the complexity is Big O(1)
- Second example of the O(n) loops are example of O(n) , if we have to perform some operation for each value of the input that the time complexity will be O(n),
Example sum of all elements of the array.
Third example O(n2) in case of nested for loop there is a possiblty that the complexity is O(n2) since for each of the element there will be n operations means operation occur n2 times.
Log(n) when there is half the iteration in each of the input then it is considered as log n in case of binary search. search space is reduced to half.
How to Sort the array in place. ?
[0,0,0,1,0,1,0,1]
Solution : this solution i was not able to solve during the interview but later after half and hour i was able to solve this problem.
Create two pointer first and last and then if value is 0 assign it to first pointer and if value is 1 assign it to last pointer and then increment and decrement respectively.
//sort an arraty with 0 and 1
public class test {
public static void main(String[] args) {
int arr[] = { 0, 0, 0, 1, 0, 1, 0, 1 };
int first = 0;
int last = arr.length - 1;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 0) {
arr[first] = 0;
++first;
} else {
arr[last] = 1;
--last;
}
}
for (int i : arr) {
System.out.print(i + " ");
}
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ SQL: Employee employee deptId joining_date 1 20 01-04-2021 10:10:00 2 30 01-03-2020 11:10:00 3 40 01-04-2021 21:10:00 4 40 06-04-2021 18:18:00
Department depId dpt_name 10 English Dept 20 Science Dept 30 Maths Dept 40 Engineering Dept
1.The depart_name which doesn't have employee.
>
select dpt_name from Department where depId NOT IN (select deptId from Employee)
Number of employees in each department with department Name.
Select dpt_name from Department where depId IN ( select depId from Employee);
- Depart_name which has more than 1 employee.
What will be the output ?
Tab1 Tab2 colA colB 1 1 1 1 1 1
select tab1.colA,tab2.colB from tab1 LEFT OUTER JOIN tab2 ON tab1.colA=tab2.colB
NOT IN --> alternative SELECT (IF, )
1 1 1 1

