NumericalSequence
SRM 259 · 2005-08-22 · by Andrew_Lazarev
Problem Statement
A numerical sequence is called a palindrome if the reverse of the sequence is the same as the original. For example sequences {1, 2, 1}, {15, 78, 78, 15} and {112} are palindromes, but {1, 2, 2}, {15, 78, 87, 51} and {112, 2, 11} are not.
You will be given a
Constraints
- sequence will contain between 1 and 50 elements, inclusive.
- Each element of sequence will be between 1 and 10000, inclusive.
{15,78,78,15}
Returns: 0
The sequence is a palindrome already.
{1,1,1,3}
Returns: 2
We should replace two ones with 2 and afterwards replace 2 and 1 with 3.
{15,78,87,51}
Returns: 3
{3,23,21,23,42,39,63,76,13,13,13,32,12,42,26}
Returns: 8
{1}
Returns: 0
Submissions are judged against all 83 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class NumericalSequence with a public method int makePalindrome(vector<int> sequence) · 83 test cases · 2 s / 256 MB per case