# Samsung Software Competency Test (SWC) for Working professionals

**Samsung Software Competency test for Hiring in Samsung R&D teams – September 2019**

There are 2 types of SWC tests:

1. For Students

2. For Working Professionals

The difference between the 2 tests is that, for Students the results of the test case will be shown.

Whereas for working professionals, the test case results will be hidden. Which means there is no way you will know if your code worked or not.

Important points to be noted: (These will also be briefed to you by the HR before the exam, but knowing these points beforehand will help)

1. There will be 1 question which needs to solved in 4 hours time.

2. There will be 50 hidden test cases, all which needs to pass to get selected.

Yes, your code must pass all 50 test cases in order to pass the SWC test.

And for working professionals, you will not know if your code passed all the 50 test cases or not and your final submission will be taken into account.

Also, the HR conducting the test may ask you to stop the test if she sees your submission has passed all 50 test cases. That way you wont loose you chance of getting selected.

3. Submissions are capped to 10. You cannot submit your code more than 10 times. But you can compile and test multiple times within the SWC software or use Eclipse and Visual Studio to compile and test your code.

4. One sample test case will be provided with inputs and the expected output.

5. We are not allowed to use any library functions such as ArrayList, Stack, Queue, Map, Set etc. STL are not allowed. We have to complete our code using just arrays. We cannot import any package. The only package that be will be imported is java.util.Scanner for taking inputs.

6. Input must be taken only using Scanner. BufferedReader is also not allowed in Java.

7. Allowed languages are C, C++ and Java only. Python, C# is not allowed.

8. We can attempt the SWC test for a maximum of 3 times in ones life. So do not waste your attempt if you are serious about joining in Samsung R&D.

For working professionals: To attend this test, we need to score above the cutoff in any of the Samsung Hiring Challenges hosted on various coding platforms such as HackerEarth, Codechef etc. The challenge in the coding platforms is just a gateway to this SWC test. This SWC test is the main component in the hiring process. As per HR, 65% of the hiring process is complete if you pass this SWC test. This is for hiring in Samsung R&D teams.

**Question**:

**Input**: Given T test cases.

For each test cases, k is given. k is the number of ingredients.

Following k, there are k lines. Each line has 3 numbers. They represent protein, fat and carbohydrate content in the kth ingredient.

Following these k lines, 3 lines are given. Each line has 3 numbers. They represent protein, fat and carbohydrate. For these 3 targets, we need to find out the ingredients to be added to exactly match the target.

**Output**: for the 3 lines in each test case, print space separated numbers denoting the ingredients to be added to get the exact match.

The ingredients must be printed in the sorted order. If there are many combinations, print the one which minimum number of ingredients.

**Sample input/output:**

1 //testcases

5 // 5 ingredients

1 2 3 //1st ingredient

4 5 6 //2nd ..

7 8 9

9 18 12

5 7 9 //5th ingredient

5 7 9 //1st target

11 13 15 //2nd target

52 14 3 // 3rd target

Expected output:

5

2 3

-1

Note: -1, when no combination(s) found

**My approach**: I used a greedy approach.

First, I added all the P F C values in each ingredient and stored it in a 2D array called sum along with its index(ingredient number).

sum[k][2]

6 1

15 2

24 3

39 4

21 5

Then I added the P F C values in each target and stored it in a variable sumTarget.

sumTarget[3]

21

39

69

Now I sorted the sum array in descending order along with the ingredient numbers. Note we cannot used sort functions. Therefore, learning the sorting algorithsm is very helpful. In my case, i implemented quick sort.

sorted sum[k][2]

39 4

23 3

21 5

15 2

6 1

I defined a total variable which kept adding the numbers from the sorted sum array. If the total is less than sumTarget, then add the next number. If it is greater than subtract the number added and iterate to add the next number.

Continue this process until you find a match. That is if sumTarget is equal to total. Once it is equal also check if the corresponding P F C values are summing to the right target values. If yes then print the ingredients. If no ingredients match the target then print zero.

Though i passed the sample test cases, unfortunately i could not clear the test.

**Analysis after the exam:** I implemented quick sort in order to sort the sum array. This turned out to be the wrong decision. The below input may print different outputs based on my program.

Lets assume my sorted array along with the ingredient numbers is as follows:

24 4

13 3

13 5

13 2

6 0

7 1

for sumTarget = 37, my algorithm will choose ingredients 4 and 3. Based on different sorting algorithms, we could choose 4, 5 or 4, 2.

What i did not find in the question was, if there are more than one possible combination of ingredients which combination must we print ?

(Maybe the ones with least ingredient number? )

Maybe i should have sorted the ingredients numbers also if the sum values are same to get the least ingredient number as the answer like this:

24 4

13 2

13 3

13 5

6 0

7 1

Now, my algorithm would have choosen 4 and 2. Also i should have collected a list of all possible combinations and choosen the one which has the lowest number ingredient. (Though i could not clearly find this in the question)

I took 3.5 hours to write the entire working code for this. I wasted my last 30 minutes wihout thinking of various scenarios like the above. Hence, use your entire 4 hours to optimise your code till the end. If any submission passes, the HR will inform you within a few minutes.

Good luck to everyone attending this test.

## Recommended Posts:

- Samsung Software - Competency Test (Samsung R&D Bangalore) Experience > 1 yrs
- Samsung Software Competency Test 2018
- Samsung Competency Test 25 Aug 19
- Technical Test Patterns of Samsung, Microsoft, Deloitte, etc
- Samsung Interview Experience | On-campus 2019 for Samsung Research Institute, Delhi
- Samsung Interview Experience | Set 10 (On-Campus for Samsung Research Institute, Noida)
- Samsung Interview Experience | Set 8 (On-Campus for Samsung Research Institute, Noida)
- Samsung Interview Experience | On-campus for Samsung Research Institute,Bangalore
- Samsung Interview Experience | (On-Campus for Samsung Research Institute, Noida)
- Samsung Interview Experience | Set 9 (On-Campus for Samsung Research Institute, Noida)
- Samsung Interview Experience | Set 3 (Samsung Research Institute, Bangalore)
- Samsung Interview Experience | Set 6 (For Internship at Samsung Research Institute)
- Samsung Interview Experience | Set 4 (Samsung Research Institute, Delhi)
- Samsung Interview Experience | Set 7 (On-Campus for Samsung Research Institute)
- Samsung Interview Experience | On-campus for Samsung R&D, Bangalore

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.