Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

C++ string manipulation

Anne Seb answered on April 7, 2023 Popularity 9/10 Helpfulness 1/10

Contents


More Related Answers

  • string in cpp
  • C++ for loop string
  • declaring strings c++
  • c++ std string include
  • c++ string constructor
  • c_str in c++
  • string in C++
  • string c++
  • Output string in C++
  • string c++
  • string in c++
  • c++ write string
  • string class in c++
  • string interpolation c++
  • c++ string looping
  • how to access the element of string in c++
  • how to use + with strings
  • how to get a section of a string in c++
  • how to get string value in c++
  • c++ str
  • + operator on string in c++
  • string class cpp
  • How to write String in C++
  • what is a string called in c++
  • operators on strings c++

  • C++ string manipulation

    -1

    Ashish was copying from Rahit in the exam. So, Rahit told him to change the answers a little bit so that the examiner cannot find the fraud. But silly Ashish in the way started to change all the answers that were needed. He shuffled the letters in each word in a way where the maximum number of letters were misplaced.

    For a given word, find the maximum difference that Ashish can generate between his answer and Rahit’s answer.

    Suppose Rahit wrote “car” for an answer, Ashish can write “acr” with difference 2, or “arc” with differnece 3.

    Note That: The letters are all in lowercase.

    Input Format:

    First line containing an integer n, number of words.

    Then, n numbers of lines as the query words.

    Output:

    N number of lines with an integer each denoting possible maximum difference.

    Sample Input:

    4

    abababa

    bbj

    kj

    kk

    Sample Output:

    6

    2

    2

    0

    Code in C++ 

    Popularity 9/10 Helpfulness 1/10 Language cpp
    Tags: c++ string
    Link to this answer
    Share Copy Link
    Contributed on Apr 07 2023
    Anne Seb
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.