All Tracks Algorithms String Algorithms Basics of String Manipulation Problem

Rotation
/

Algorithms, Brute Force, String Manipulation, easy

Problem
Editorial
Analytics

You are given two strings \(S\) and \(T\) of the same length \(N\). Your task is to convert the string \(S\) into \(T\) by doing some operations. In an operation, you can delete the first character of the string \(S\) and append any character at the end of the string. You are required to determine the minimum number of operations to convert \(S\) into \(T\).

Input format

  • First line: Single integer \(N\) denoting the length of the strings
  • Second line: String \(S\)
  • Third line: String \(T\)

Output format
Print a single integer that represents the answer to the question.

Constraints
\(1 \leq N \leq 10^3\)

Both strings consist of only lowercase alphabets.

SAMPLE INPUT
7
aaxaabc
aabcaax
SAMPLE OUTPUT
3
Explanation

After the \(1st\) operation \(S = axaabca\)
After the \(2nd\) operation \(S = xaabcaa\)
After the \(3rd\) operation \(S = aabcaax\)
After \(3rd\) operation \(S \) and \(T\) becomes same.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?