none
Logic to be Solved in C# RRS feed

  • Question

  • A millionaire from London bought a unique house which has many rooms, expensive items and many other automatic equipment. A journalist went to his house for interviewing him. He entered through the wrong door and came inside the house but he lost his path for entering the main room due the fact that there were many rooms and the house had a unique structure. He is now stuck inside the house. He goes from one room to another, but couldn't find the right door. He saw one automatic answering machine in a room and asked it about the way to go out. The machine replied that he will receive a word but he needs to make a proper pattern from that word. After entering the pattern in the machine, he will get the correct path from the machine. Using this way, he could come out of the house. A Word Pattern should now be made and if we start the word from the left letter to the right or from the right to left, then that word should be same. For making this type of pattern, he can add as many letters in the word at any place.

    You need to figure out, how many minimum number of characters he needs to add in the original word for making this type of a pattern.


    Input Format
    First line represents total number of characters in the word, which is of integer type N. 
    Second line represents a word, which is of string type containing alphabets and digits only which is case-sensitive.


    Constraints
    3<=N<=5000

    Output Format
    You need to print the desired minimum number of characters needed to add in the original word.


    Sample TestCase 1
    Input
    5
    Ab3bd
    Output
    2
    Explanation

    After adding two characters 'd' after 'A' and 'A' at the last of the given word, now the word will be "Adb3bdA", Hence the output will be 2.
    Saturday, July 20, 2019 3:49 AM

All replies


  • You need to figure out ... 


    You need to print ...


    So what's your question about this assignment?

    What part of it stumps you?

    Where's the code that you have written so far?

    Note that we don't do course assignments here, nor do we do custom programming
    on demand. We answer specific questions about particular issues, and offer 
    suggestions for further study or research.

    The more specific and focused your questions are, the more detailed will be the replies.

    - Wayne

    Saturday, July 20, 2019 9:49 AM
  • > Logic to be Solved in C#

    No, that's wrong. There's never logic to be solved in C# (or any other procedural language). First, you need to know the logic for solving the problem without using a computer. Once you know all the steps, you can then proceed to code them in a programming language such as C#. But you never start by saying "I have to solve this in C#". First you need to figure out how to solve it without C#, and then you can convert that knowledge into a C# program.


    Sunday, July 21, 2019 7:21 PM
    Moderator
  • Whoever wrote that question needs to go on a clear writing course. What the Hell does the millionaire from London have to do with it? Or the journalist? It looks like a problem that could be expressed in one or two short sentences, but instead we have to wade through all that nonsense about lots of rooms.

    I realise I'm not helping solve the problem , but like Wayne and Alberto have said, you need to have a go yourself first. We won't write the whole thing for you.

    Monday, July 22, 2019 12:41 AM