Skip to content

Commit fdc7c0b

Browse files
authored
Create tcs_question-1(Luminous Jewels-Polishing Necklace).txt
1 parent 0265bee commit fdc7c0b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Problem : Luminous Jewels - Polishing Necklace
2+
Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Necklaces require polishing the jewels.
3+
Operationally, all jewels of the same colour can be polished in one sitting. Cost of polishing increases with every sitting. Your task is to minimize the cost of polishing the necklace, given following conditions
4+
1. Jewels can only be removed for polishing from either end of the necklace (i.e. head or tail) 2. Cost of polishing = Sitting Number * Colour Value of the Luminous Jewel 3. The necklace is represented as a String and each character of the string is a Luminous Jewel 4. Similar character is the same Luminous Jewel which has same Colour Value
5+
Colour Value for different Jewels named from a to z are 1 to 26 respectively. For e.g. a = 1, b = 2, ... z = 26.
6+
Input Format:
7+
First line starts with T, number of test cases. Each test case T contains a necklace (N).
8+
Output Format:
9+
Print the minimum cost of polishing the necklace.
10+
Constraints:
11+
1<=T<=100
12+
1<=|N|<=500, N will only contain lower case alphabets ('a'-'z').
13+
Sample Input and Output
14+
SNo. Input Output
15+
1 aba 5
16+
2 abaacde 38
17+

0 commit comments

Comments
 (0)