Count minimum swap to make string palindrome

  1. Take two-pointer where the first pointer track from the left side of a string and second pointer keep track from the right side of a string.
  2. Till the time we find the same character, keep moving the right pointer to one step left.
  3. If the same character not found then return -1.
  4. If the same character found then swap the right pointer’s character towards the right until it is not placed at its correct position in a string.
  5. Increase left pointer and repeat step 2.

--

--

--

Full Stack Programmer, love to solve problem’s during free time.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Magento2: how to get Attribute options

Putting my app on a diet: Android App Bundle to the rescue.

A voyage into the back-end

Composition of UIViewControllers and navigation between them (and not only)

Where to Start?

Full guide on how to buy FINT tokens, if you are new to crypto

How to Choose the Right Coding Language for Your Project.

AWS S3 Multipart File Upload: Our recent experience

AWS S3 Multipart File Upload: Our recent experience at Ideas2IT

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jaydeep

Jaydeep

Full Stack Programmer, love to solve problem’s during free time.

More from Medium

Leetcode 290. Word Pattern

Leetcode

Leetcode Problem : 525. Contiguous Array

Validate Binary Search Tree