Samsung Interview Questions asked in Samsung 3 Hour Test | Set 3

1.You are given old touch smartphone numbers having dial pad and calculator app. 

Aim: The goal is to type a number on the dial pad. 

But as the phone is old, some of the numbers and some operations can't be touched. 
For eg. 2,3,5,9 keys are not responding, i.e you cannot use them 
But you can always make a number using other numbers and operations in Calculator. There could be multiple ways of making a number 

Calculator have 1-9 and +,-,*,/,= as operations. Once you have made the number in Calculator you can copy the number and use it. 

You have to find the minimum number of touches required to obtain a number. 


#Input:# 
There will be multiple Test cases.Each test case will consist of 4 lines 
1) The first line will consist of N, M, O
N: no of keys working in Dialpad (out of 0,1,2,3,4,5,6,7,8,9) 
M:types of operations supported (+,-,*,/) 
O: Max no of touches allowed 

2) second line of input contains the digits that are working e.g 0,2,3,4,6. 
3) Third line contains the valued describing operations, 1(+),2(-),3(*),4(/) 

4) fourth line contains the number that we want to make . 

#Output:# 
Output contains 1 line printing the number of touches required to make the number 


#Sample Test Case:# 
1 // No of test cases 
5 3 5 // N ,M, O 
1 2 4 6 0 // digits that are working (total number of digits = N), 
1 2 3 // describing operations allowed (1--> '+', 2--> '-', 3--> '*' , 4--> '/' )(total number is equals to M) 
5 // number we want to make 


Answer 3 
How 4? 1+4=, "=" is also counted as a touch 



2nd Sample Case 
3 // No of Test cases 
6 4 5 // N ,M, O 
1 2 4 6 9 8 // digits that are working (total number of digits = N), 
1 2 3 4 // describing operations allowed (1--> +, 2--> -, 3--> , 4-->/) 
91 // number we want to make 
6 2 4 // 2nd test case 
0 1 3 5 7 9 
1 2 4 // +, -, / allowed here 
28 
5 2 10 
1 2 6 7 8 
2 3 // -, allowed 
981 

#Output:# 
2 // 91 can be made by directly entering 91 as 1,9 digits are working, so only 2 operations 
5// 35-7=, other ways are 1+3*7= 
9//62*16-11= 


Order of computation will be followed as symbols entered if + comes, it will be computed first 


One more example: let's say 1,4,6,7,8,9 works and +,-,* works. 
2,3,5 and / doesn't work. 
If you have to type 18-> 2 operations. (Each touch is considered an operation),br> If you have to type 5 -> '1+4=' that requires 4 operations. There could be other ways to make '5'.


2. There is one spaceship. X and Y co-odinate of source of spaceship and destination spaceship is given. There are N number of warmholes each warmhole has 5 values.
First 2 values are starting co-ordinate of warmhole and after that value no. 3 and 4 represents ending co-ordinate of warmhole and last 5th value is represents cost to pass through this warmhole. Now these warmholes are bi-direction.
Now the to go from (x1,y1) to (x2,y2) is abs(x1-x2)+abs(y1-y2).
The main problem here is to find minimum distance to reach spaceship from source to destination co-ordinate using any number of warm-hole. It is ok if you wont use any warmhole.
Solution:
You can make graph which contain edge between all points and put cost of that edge. Now apply dijstra algorithm to find minimum distace between source to destination co-ordinate of spaceship.
Here the main catch is that the cost to pass through warmhole can be zero so you have to take care while making graph matrix.

Comments

  1. Hey,

    Thank you for sharing the questions. Can you kindly share the solution to the 2nd problem.

    How could you create an adjacency list for 2d points? is it using -> Point adj_list[10000][10000].

    Also could you help me with this problem: https://sharecode.io/section/problemset/problem/2617

    ReplyDelete
    Replies
    1. #include
      using namespace std;
      #define i_max 2147483647
      int nw,sx,sy,dx,dy;//Source and destination co-ordinates
      int dist[1001][1001];
      bool set[1001][1001];
      class Wormhole{
      public:
      int x1,y1,x2,y2,cost;

      void get(){
      cin >> x1 >> y1 >> x2 >> y2 >> cost;
      }
      };
      Wormhole A[10];
      int row_mov[] = {1,-1,0,0};
      int col_mov[] = {0,0,1,-1};


      void initializeArrays(int m,int n){
      //Filling array with 1s
      for(int i=0;idx || j>dy){
      return false;
      }
      return true;
      }

      int findMinCost(){
      initializeArrays(dx+1,dy+1);
      //Run dijkstra
      dist[sx][sy] = 0;//Distance from source to source is 0
      //set[sx][sy] = true;//We have reached source

      for(int i=1;i<=dx*dy;i++){
      int row=-1,col=-1;
      setMinRowCol(row,col);//Find min row,col that are unset and proceed with min_dist path

      if(row == -1 && col == -1){//If not found then break
      break;
      }
      if(row == dx && col == dy){//If we've reached destination, return the cost
      return dist[row][col];
      }

      set[row][col] = true;//Set the current row,col

      for(int j=0;j<4;j++)//Move in all 4 directions
      {
      int x = row + row_mov[j];
      int y = col + col_mov[j];

      if(isValid(x,y) && !set[x][y] && dist[x][y]>dist[row][col]+1)
      dist[x][y] = dist[row][col] + 1;
      }

      int w_entry = wormentry(row,col);//If worm entry is at row,col ,i.e., row = x1 & col = y1 then exit is at x2,y2
      if(w_entry!=-1)
      {
      int x = A[w_entry].x2;
      int y = A[w_entry].y2;

      if(!set[x][y] && dist[x][y]>dist[row][col]+A[w_entry].cost) //If cost of wormhole is minimum go through the wormhole
      dist[x][y] = dist[row][col]+A[w_entry].cost;
      }
      int w_exit = wormexit(row,col);//If worm exit is at row,col ,i.e., row = x2 & col = y2 then entry is at x1,y1
      if(w_exit!=-1)
      {
      int x = A[w_exit].x1;
      int y = A[w_exit].y1;

      if(!set[x][y] && dist[x][y]>dist[row][col]+A[w_exit].cost) //If cost of wormhole is minimum go through the wormhole
      dist[x][y] = dist[row][col]+A[w_exit].cost;
      }
      }
      return -1;
      }

      int main(){
      cin >> sx >> sy >> dx >> dy;//Scanning source and destination

      cin >> nw;//No of wormholes

      //Scanning wormholes info
      for(int i=0;i<nw;i++){
      A[i].get();
      }

      cout << findMinCost();
      return 0;
      }

      Delete
    2. Samsung Interview Questions Asked In Samsung 3 Hour Test >>>>> Download Now

      >>>>> Download Full

      Samsung Interview Questions Asked In Samsung 3 Hour Test >>>>> Download LINK

      >>>>> Download Now

      Samsung Interview Questions Asked In Samsung 3 Hour Test >>>>> Download Full

      >>>>> Download LINK SZ

      Delete
  2. Hello Thanks for sharing it, can you also please share the solutions of the given problem statement.

    ReplyDelete
    Replies
    1. You are brilliant enough to solve these questions in one go.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. For any kind of assistance in Samsung Interviews the link for all the solutions of questions asked previously – pastebin.com/u/ann8497
    I have prepared the solutions myself. The questions are verified and solved in the least complexity time.
    Hope it helps.

    ReplyDelete
  5. After a long time of searching for a recovery expert and platforms to help me recovering my funds, I finally meet a ethical hacker who helped me to recovery all i have lost to this broker site 24options worth $30 Thoushand USD, and I must say that he's a God sent, His help was quite outstanding from the handling of the case by the case manager to completion. I just want to say thank you onlineghosthacker247 for this rare opportunity to get my funds back when all hope seems lost due to the sea of scams out there. I totally recommed him and you can reach him on his email ( onlineghosthacker247 @ gmail . com) and thank me later .

    ReplyDelete
  6. After a long time of searching for a recovery expert and platforms to help me recovering my funds, I finally meet a ethical hacker who helped me to recovery all i have lost to this broker site 24options worth $30 Thoushand USD, and I must say that he's a God sent, His help was quite outstanding from the handling of the case by the case manager to completion. I just want to say thank you onlineghosthacker247 for this rare opportunity to get my funds back when all hope seems lost due to the sea of scams out there. I totally recommed him and you can reach him on his email ( onlineghosthacker247 @ gmail . com) and thank me later .

    ReplyDelete
  7. Samsung Interview Questions Asked In Samsung 3 Hour Test >>>>> Download Now

    >>>>> Download Full

    Samsung Interview Questions Asked In Samsung 3 Hour Test >>>>> Download LINK

    >>>>> Download Now

    Samsung Interview Questions Asked In Samsung 3 Hour Test >>>>> Download Full

    >>>>> Download LINK nf

    ReplyDelete

Post a Comment