Ask Question
19 February, 08:21

5. Write a program to remove any duplicate letters from a word and display the new word maintaining the original order. For example, bananas would become bans and bookkeeper would become bokepr. You may not use any special unique commands!

+5
Answers (1)
  1. 19 February, 11:31
    0
    word = input ('Enter a single word: ', 's');

    n = length (word);

    nodupWord = [];

    for i = 1:n

    dup = false;

    c = word (i);

    for j = 1:i-1

    if word (j) = = c

    dup = true;

    break;

    end

    end

    if ~dup

    nodupWord = [nodupWord, c]; %add the non-duplicate char to end

    end

    end

    disp (['Adjusted word: ', nodupWord])

    Explanation:

    The code is in Python.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “5. Write a program to remove any duplicate letters from a word and display the new word maintaining the original order. For example, ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers