Check if characters of a given string can be rearranged to form a palindrome | C # Implementation of the above approach ; bitvector to store the record of which character appear odd and even number of times ; Driver Code
using System ; public class GFG { static bool canFormPalindrome ( string a ) { int bitvector = 0 , mask = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { int x = a [ i ] - ' a ' ; mask = 1 << x ; bitvector = bitvector ^ mask ; } return ( bitvector & ( bitvector - 1 ) ) == 0 ; } static public void Main ( ) { if ( canFormPalindrome ( " geeksforgeeks " ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }