Skip to content

Conversation

@makariyp
Copy link

@makariyp makariyp commented May 5, 2023

Intuition
To begin with, let's think about how to determine that a set of numbers is a palindrome? It's very simple: in a set of numbers, only one element may not have a pair, all the others must have a pair.

Approach
So I decided to override the add method in ArrayList and check if there is an item in the list that we want to add. If such an element already exists, we will delete it. If there are 1 or 0 elements left in the ArrayList at the end, then all the numbers that we added to it earlier are a palindrome

Intuition
To begin with, let's think about how to determine that a set of numbers is a palindrome? It's very simple: in a set of numbers, only one element may not have a pair, all the others must have a pair.

Approach
So I decided to override the add method in ArrayList and check if there is an item in the list that we want to add. If such an element already exists, we will delete it. If there are 1 or 0 elements left in the ArrayList at the end, then all the numbers that we added to it earlier are a palindrome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant