Siemens Limited interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Siemens Limited
upvote
share-icon
4 rounds | 8 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 Months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

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.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

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.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration120 Minutes
Interview date21 Jun 2021
Coding problem2

This was an online MCQ + coding round where we had 1 hour to solve the MCQ's and another 1 hour to solve 2 coding
questions. The MCQ's were related to both General and Technical Aptitude.

1. Count Inversions

Moderate
40m average time
55% success
0/80
Asked in companies
MicrosoftAdobeSamsung R&D Institute

For a given integer array/list 'ARR' of size 'N' containing all distinct values, find the total number of 'Inversions' that may exist.

An inversion is defined for a pair of integers in the array/list when the following two conditions are met.

A pair ('ARR[i]', 'ARR[j]') is said to be an inversion when:

1. 'ARR[i] > 'ARR[j]' 
2. 'i' < 'j'

Where 'i' and 'j' denote the indices ranging from [0, 'N').
Problem approach

Approach (Using Merge Sort) :

1) The idea is similar to merge sort, divide the array into two equal or almost equal halves in each step until the base
case is reached.

2 )Create a function merge that counts the number of inversions when two halves of the array are merged, create two
indices i and j, i is the index for the first half, and j is an index of the second half. if a[i] is greater than a[j], then there
are (mid – i) inversions.

3) Create a recursive function to divide the array into halves and find the answer by summing the number of
inversions is the first half, the number of inversion in the second half and the number of inversions by merging the
two.

4) The base case of recursion is when there is only one element in the given half.

5) Print the answer


TC : O(N*log(N)), where N=size of the array.
SC : O(N)

Try solving now

2. Maximum Subarray Sum

Moderate
35m average time
81% success
0/80
Asked in companies
HCL TechnologiesInformaticaSamsung

You are given an array 'arr' of length 'n', consisting of integers.


A subarray is a contiguous segment of an array. In other words, a subarray can be formed by removing 0 or more integers from the beginning and 0 or more integers from the end of an array.


Find the sum of the subarray (including empty subarray) having maximum sum among all subarrays.


The sum of an empty subarray is 0.


Example :
Input: 'arr' = [1, 2, 7, -4, 3, 2, -10, 9, 1]

Output: 11

Explanation: The subarray yielding the maximum sum is [1, 2, 7, -4, 3, 2].
Problem approach

Approach (Using Kadane's Algo) :

1) Declare a variable ‘maxSum’ and initialize it with ‘minimum integer’

2) Declare a variable ‘localSum’ and initialize it with ‘0’

3) Declare 3 counter variables as ‘start’ , ‘end’ , ‘newStart’ as 0, 0, 0

4) Run a loop from i = 0 to N
4.1) Add a current element to ‘localSum’

4.2) If 'localSum' is greater than 'maxSum'
Update ‘maxSum’ with 'localSum', update start with ‘newStart’ and end with loop counter ‘i’

4.3) If 'localSum' is equal to ‘maxSum’ and the difference between ‘end’ and ‘start’ is less than the
difference between ‘newStart’ and ‘i’
Update start with ‘newStart’ and end with ‘i’

4.4) If 'localSum' is below ‘0’
Update ‘localSum’ as 0 and set ‘newStart' as ‘i’ + 1

5) Return the part of the array starting from ‘start’ and ending at ‘end’


TC : O(N), where N=size of the array
SC : O(N), we need a final array to store the result maximum subarray.

Try solving now
02
Round
Easy
Video Call
Duration50 Minutes
Interview date21 Jun 2021
Coding problem3

This round had fairly easy coding questions compared to all the rounds and the interviewer was also quite friendly. The interview started with me giving my introduction and then the interview asked me some more questions related to my academics and projects and then finally he switched to the coding questions.

1. Transpose of a Matrix

Easy
15m average time
80% success
0/40
Asked in companies
OracleZSPolicyBazaar.com

You are given a matrix ‘MAT’. Print and return the transpose of the matrix. The transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of a matrix A[][] is obtained by changing A[i][j] to A[j][i].

For example:
Let matrix be : 
1 2
3 4

Then transpose of the matrix will be: 
1 3
2 4
Problem approach

Approach :

1) Declare2-dimensional array t to store the transpose of the matrix. This array will have the reversed dimensions as
of the original matrix.

2) The next step is to loop through the original array and to convert its rows to the columns of matrix t.
2.1) Declare 2 variables i and j.
2.2) Set both i,j=0
2.3) Repeat until i2.3.1) Repeat until j2.3.2) t[i][j] = p[j][i]
2.3.3) j=j+1
2.4) i=i+1

3) The last step is to display the elements of the transposed matrix t.


TC : O(N*M), where N=number of rows and M=number of columns in the matrix.
SC : O(N*M)


//Pseudo Code :

void transpose(int p[][n], int t[][m])
{
for(int i=0; ifor(int j=0; jt[i][j] = p[j][i];
for(int i=0; i{
for(int j=0; jcout<cout<}
}

Try solving now

2. Middle Of Linked List

Easy
20m average time
80% success
0/40
Asked in companies
NoBrokerIBMHCL Technologies

Given a singly linked list of 'N' nodes. The objective is to determine the middle node of a singly linked list. However, if the list has an even number of nodes, we return the second middle node.

Note:
1. If the list is empty, the function immediately returns None because there is no middle node to find.
2. If the list has only one node, then the only node in the list is trivially the middle node, and the function returns that node.
Problem approach

Approach :

1) If the head is NULL, we simply return HEAD.

2) If there is only one element in the linked list, we simply return it as it is the midpoint.

3) Otherwise, we initialise 2 pointers ‘fast’ and ‘slow’ both poiniting to head initially.

4) We traverse the linked list until fast is the last element or fast is beyond the linked list i.e it points to NULL.

5) In each iteration, the ‘fast’ pointer jumps 2 times faster as compared to ‘slow’ pointer.

6) Finally, once the loop terminates, ‘slow’ pointer will be pointing to the middle element of the linked list, hence we
return the ‘slow’ pointer.


TC : O(N), where ‘N’ denotes the number of elements in the given Linked list.
SC : O(1)

Try solving now

3. Remove character

Easy
0/40
Asked in companies
Expedia GroupThought WorksHewlett Packard Enterprise

For a given string(str) and a character X, write a function to remove all the occurrences of X from the given string and return it.

The input string will remain unchanged if the given character(X) doesn't exist in the input string.

Problem approach

Approach :

1) We create an empty string that will store our final result. We will return it at the end.

2) We iterate from 0 to the length of the string. Say, our loop variable is i. We can then access the ith character as
input[i]

3) If the ith character equals the character c i.e input[i] == c, then we skip this character and do nothing.

4) Else we need to append the character to the output string.

5) We finally return the output string.


TC : O(N), where N=length of the string
SC : O(N)

Try solving now
03
Round
Medium
Video Call
Duration60 Minutes
Interview date21 Jun 2021
Coding problem3

This round had 2 decent coding questions , the first one was related to Dynamic Programming and the second one was of Sorting. I explained the approaches of both the questions with appropriate complexity analysis and then coded them in a production ready manner. This was followed by the interviewer asking me an interesting puzzle to check my overall aptitude.
So, be prepared for puzzles as well while preparing for interviews.

1. Subset Sum Equal To K

Moderate
30m average time
65% success
0/80
Asked in companies
DunzoHCL TechnologiesDeutsche Bank

You are given an array/list ‘ARR’ of ‘N’ positive integers and an integer ‘K’. Your task is to check if there exists a subset in ‘ARR’ with a sum equal to ‘K’.

Note: Return true if there exists a subset with sum equal to ‘K’. Otherwise, return false.

For Example :
If ‘ARR’ is {1,2,3,4} and ‘K’ = 4, then there exists 2 subsets with sum = 4. These are {1,3} and {4}. Hence, return true.
Problem approach

Approach (Using DP) : 

1) Create a boolean 2D array/list ‘DP’ of size (‘N+1’)*(‘K+1’) i.e. ‘DP[N+1][K+1]’.

2) If ‘K’ is equal to 0, then the answer should be ‘true’. Hence, run a loop from 0 to ‘N’ (say iterator = ‘i’):
‘DP[i][0]’ = true.

3) If ‘K’ is not zero but ‘ARR’ is empty then the answer should be ‘false’. Hence, run a loop from 1 to ‘K’ (say iterator = ‘i’):
‘DP[0][i]’ = false.

4) To fill the ‘DP’ table, run a loop from 1 to ‘N’ (say iterator = ‘i’):
4.1) Run a loop from 1 to ‘K’ (say iterator = ‘j’):
‘DP[i][j]’ = ‘DP[i-1][j]’.

4.2) If ‘j’ is greater than equal to ‘ARR[i-1]’:
‘DP[i][j]’ = ‘DP[i][j]’ OR ‘DP[i-1][j - ARR[i-1]]’.

5) Finally, return ‘DP[N][K]’.


TC : O(N*K), where N = size of the array and K = required sum
SC : O(N*K)

Try solving now

2. Overlapping Intervals

Easy
24m average time
0/40
Asked in companies
SprinklrAdobeAmazon

You have been given the start and end times of 'N' intervals. Write a function to check if any two intervals overlap with each other.

Note :
If an interval ends at time T and another interval starts at the same time, they are not considered overlapping intervals.
Problem approach

Approach (Using Sorting) : 

1) Sort the list of intervals first on the basis of their start time and then iterate through the array.

2) If the start time of an interval is less than the end of the previous interval, then there is an overlap and we can return true.

3) If we iterate through the entire array without finding an overlap, we can return false.


TC : O(N * logN), where N = total number of intervals.
SC : O(N)

Try solving now

3. Puzzle

8 balls problem : You are provided with 8 identical balls and a measuring instrument. 7 of the eight balls are equal in weight and one of the eight given balls is defective and weighs less. The task is to find the defective ball in exactly two measurements.

Problem approach

Approach : 

Step 1: Divide the balls into three categories(C1, C2 and C3).
1) Let C1 consist of balls B1, B2 and B3.
2) Let C2 consist of balls B4, B5 and B6.
3) Let C3 consist of balls B7 and B8.

Step 2 : Put C1 on one side of the weighing machine and C2 on the other.
This can give rise to 3 conditions:
1) Condition 1: C1 equals C2
2) Condition 2: C1 < C2
3) Condition 3: C1 > C2 

Now let’s analyse the three conditions to find the defective ball:

Condition 1 : If C1 is equal C2, then C3 has the defective ball. Now measure the weights of ball B7 and B8.
i) If B7 < B8, B7 is defective
ii) If B7 > B8, B8 is defective.

Condition 2 : If C1 < C2, then C1 has the defective ball. Now measure the weights of ball B1 and B2.
i) If B1 equals B2, B3 is defective.
ii) If B1 < B2, B1 is defective.
iii) If B1 > B2, B2 is defective.

Condition 3 : If C1 > C2, then C2 has the defective ball. Now measure the weights of ball B4 and B5.
i) If B4 equals B5, B6 is defective.
ii) If B4 < B5, B4 is defective.
iii) If B4 > B5, B5 is defective.

04
Round
Easy
HR Round
Duration30 Minutes
Interview date21 Jun 2021
Coding problem0

This was a Technical Cum HR round where I was first asked some basic OOPS related concepts and then we discussed about my expectations from the company , learnings and growth in the forthcomig years. I would suggest be honest and try to communicate your thoughts properly in these type of rounds to maximise your chances of getting selected.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is recursion?

Choose another skill to practice
Similar interview experiences
SDE - 1
1 rounds | 3 problems
Interviewed by Siemens Limited
2803 views
0 comments
0 upvotes
SDE - 1
4 rounds | 11 problems
Interviewed by Siemens Limited
1274 views
0 comments
0 upvotes
SDE - 1
3 rounds | 3 problems
Interviewed by Siemens Limited
0 views
0 comments
0 upvotes
SDE - 1
2 rounds | 5 problems
Interviewed by Siemens Limited
1473 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
114579 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
57825 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
34961 views
7 comments
0 upvotes