Samsung Research Institute Noida, India, Interview Experience

Problem Statement
First round was coding round of 3 hours with following question.
It was on samsung own software SCS
Given-
1). number of test cases
each case as-
->size of matrix in rows and columns, starting location and length of the measuring instrument
->2-d Grid with numbers from 0 to 7 and each number represents as following-
0- no pipe
1- opens from up, left, right, bottom
2- opens from up, bottom
3- opens from left, right
4- up, right
5- down, right
6- down, left
7- up, left
from starting location, find how many pipes you can measure with the given instrument.
Note : If length of measuring instrument is shorter then length of connected pipes, take length of instrument.
Test cases:
2
5 6 2 1 3
0 0 5 3 6 0
0 0 2 0 2 0
3 3 1 3 7 0
0 0 0 0 0 0
0 0 0 0 0 0
5 6 2 2 6
3 0 0 0 0 3
2 0 0 0 0 6
1 3 1 1 3 1
2 0 2 0 0 2
0 0 4 3 1 1
OUTPUT:
1# 5
2# 15
CODE:
'''
#include<bits/stdc++.h>
using namespace std;
int mat[51][51];
int depth[51][51];
int visited[51][51];
int N,M,x,y,L;
struct Node{
int a,b,d;
Node(int a1,int b1,int d1){
a=a1;b=b1;d=d1;
}
};
bool s1(int i,int j)
{
if(i>=0 && i<N && j>=0 && j<M && visited[i][j]==0 && (mat[i][j]==1 || mat[i][j]==3 || mat[i][j]==6 || mat[i][j]==7))
return(true);
return(false);
}
bool s2(int i,int j)
{
if(i>=0 && i<N && j>=0 && j<M && visited[i][j]==0 && (mat[i][j]==1 || mat[i][j]==2 || mat[i][j]==4 || mat[i][j]==7))
return(true);
return(false);
}
bool s3(int i,int j)
{
if(i>=0 && i<N && j>=0 && j<M && visited[i][j]==0 && (mat[i][j]==1 || mat[i][j]==3 || mat[i][j]==4 || mat[i][j]==5))
return(true);
return(false);
}
bool s4(int i,int j)
{
if(i>=0 && i<N && j>=0 && j<M && visited[i][j]==0 && (mat[i][j]==1 || mat[i][j]==2 || mat[i][j]==6 || mat[i][j]==5))
return(true);
return(false);
}
void bfs(int x1,int y1,int d)
{
vector q;
Node temp(x1,y1,d);
q.insert(q.begin(),temp);
while(q.size()>0){
temp=q[q.size()-1];q.pop_back();
int i=temp.a;
int j=temp.b;
int c=temp.d;
depth[i][j]=min(depth[i][j],c);
visited[i][j]=1;
if(mat[i][j]==1 || mat[i][j]==3 || mat[i][j]==6 || mat[i][j]==7){
if(s3(i,j-1)){
Node t(i,j-1,c+1);
q.insert(q.begin(),t);
}
}
if(mat[i][j]==1 || mat[i][j]==3 || mat[i][j]==4 || mat[i][j]==5){
if(s1(i,j+1)){
Node t(i,j+1,c+1);
q.insert(q.begin(),t);
}
}
if(mat[i][j]==1 || mat[i][j]==2 || mat[i][j]==4 || mat[i][j]==7){
if(s4(i-1,j)){
Node t(i-1,j,c+1);
q.insert(q.begin(),t);
}
}
if(mat[i][j]==1 || mat[i][j]==2 || mat[i][j]==6 || mat[i][j]==5){
if(s2(i+1,j)){
Node t(i+1,j,c+1);
q.insert(q.begin(),t);
}
}
}
}
int main()
{
int T,t=1;
cin>>T;
while(T--){
cin>>N>>M;
cin>>x>>y;
cin>>L;
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
cin>>mat[i][j];
visited[i][j]=0;
depth[i][j]=1000;
}
}
if(mat[x][y]!=0)
bfs(x,y,1);
int cnt=0;
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
if(depth[i][j]<=L)cnt++;
}
}
cout<<"#"<<t++<<" "<<cnt<<"\n";
}
}

'''
After clearing the coding round there were 1 technical interview round and 1 HR round more.
Technical- It was purely Java based and some simple DSA questions.
HR- Simple puzzle of unit cubes and find colored unit cube with at least one side painted like that.
and some behavioural questions

Comments (2)