Open In App

Samsung Interview Experience (On-Campus) 2022

Last Updated : 28 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Samsung semiconductors Bangalore first time visited our campus for embedded software internships in 2024 and also for placements for the 2023 batch the total time is 70 mins and exam selection is based on fast submission with all correct answers in this article I will share questions about it.

My experience in solving questions: Question 1 is a medium-level question that can be solved using dynamic programming, question 2 is an easy-to-level question we can solve by just using a normal array concept, and question 3 is a hard-level question we should not use extra space, and it’s based on tree and linked list concept.

Problem Statement 

Each cell of a matrix of size mxn contains strength. A robot needs strength to travel from the top left corner of the matrix to the bottom night comer. At any point of cannot drop to 0 or less. A cell contains D, positive or negative strength. Positive strength increases its strength by cell value, negative strength decreases its strength change in strength If the cell value is 0.

You are required to implement the following function: int Minimumstrength(int mat, int, int n):

The function accepts a 2-d matrix mat of ‘m’ rows and ‘n’ columns as its arguments. You are required to calculate the minimum til strength required by the robot to the top left corner to reach the destination l.e. the bottom right corner and return the same.

Assumption:

m> 1 and n>0.

A robot can only move either one cell down or right l.e., to cell (1+1,1) or cell (j+1) and it cannot move outside the matrix.

mat[0][0]=mat[m-1][n-1] = 0

Example:

Input:

mat:

0 1 -3
1 -5 0

Output:

3

Explanation:

Minimum strength to reach destination l.e. mat[1][2] from source i.e. mat[0][0] is 3 via path mat[0][0]-> mat[0][1]-> mat[0][2]> mat[1][2] such that it has p its journey.

Maximum Index Difference

Problem Statement: You are given a function,

int MaxIndexDiff(int arr, int n):

The function accepts an Integer array ‘arr of length ‘n’. Implement the function to find the maximum index difference j-k in ‘arr such that an Assumption: Array Index starts from 0 and n > 1. Note: If no such index Is found return -1.

Example:

Input:

arr: 30 2 3 27 22

Output:

3

Explanation:

The maximum Index difference will be 4(index of 22) 1(Index of 2),l.e. 3.

The custom input format for the above case:

5
30 2 3 27 22

(The first line represents the size of the array, and the second line represents the elements of the array)

Sample Input

arr: 3 4 42 30 1 21

Sample Output

5

The custom input format for the above case:

6
3 4 42 38 1 21

(The first line represents the size of the array, and the second line represents the elements of the array)

Problem Statement: A binary tree is represented by the following structure:

struct Treetode
int data;
struct TreeNode left; struct TreeNode* right;

Implement the following function: struct TreeNode Leaflist(struct TreeNode root);

The function accepts the root node of a binary tree ‘root’ as its argument. Implement the function to return a singly linked list of leaf nodes starting from the left-most leaf to the of the given binary tree.

Note: If the input tree is NULL(or None in the case of python), then return NULL(or None in the case of python).

Assumption: Do not allocate extra memory for the singly linked list

Consider the right pointers of leaf nodes of the binary tree as the next pointer for the singly linked list and the left pointers of leaf nodes of the binary tree remain the same

Example:

Input:

 

Output:

4->5->6-> 7

Explanation:

  • The leaf nodes of the given tree are 4, 5, 6, and 7 which form a singly linked list 4->5->6-> 7 starting from the leftmost leaf 4 to the rightmost leaf 7.
  • The custom input format for the above case: 234567
  • The first line represents the height of the tree, the second line represents the level order traversal of the given tree, in the second line – 1 represents an empty node)

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads