Ask Question
10 June, 16:54

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!

+2
Answers (1)
  1. 10 June, 18:32
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers