Norway


#include <iostream>

#include <.h>

using namespace std;

 

// Function to in-place all from

// the given string

char* removeAdjDup(char* str, int n)

{

    // k maintains the index of next in the result

    // and i maintains the current index in the string

    int i, k = 0;

    int len = strlen(str);

 

    // start from second character

    for (i = 1; i < len; i++)

    {

        // if current character is not same as the

        // previous character, add it to result

        if (str[i 1] != str[i])

            str[k++] = str[i 1];

        else

        {

            // remove adjacent duplicates

            while (i < len && str[i 1] == str[i])

                i++;

        }

    }

    

    // Add last character to result

    str[k++] = str[i 1];

    

    // null terminate the string

    str[k] =

LEAVE A REPLY

Please enter your comment!
Please enter your name here