{"id":"86ad6848-39b5-4e45-a2ec-95f1612f5c31","name":"Interleaving Of Two Strings","description":"1. You are given three strings - s1, s2 and s3.\r\n2. You have to find whether s3 is formed by interleaving of s1 and s2.\r\n3. s3 is interleaving if it contains all characters of s1 and s2, and order of all characters in individual string is preserved.","inputFormat":"String s1\r\nString s2\r\nString s3","outputFormat":"true/false","constraints":"1 <= s1.length() <= 100\r\n1 <= s2.length() <= 100\r\n1 <= s3.length() <= 200","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static boolean solution(String s1, String s2, String s3) {\r\n // write your code here\r\n\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String s1 = scn.nextLine();\r\n String s2 = scn.nextLine();\r\n String s3 = scn.nextLine();\r\n System.out.println(solution(s1, s2, s3));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aabcc\r\ndbbca\r\naadbbcbcac","sampleOutput":"true\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"45f5107e-dc61-4d72-8d1f-77252cce8180","name":"Interleaving Of Two Strings","slug":"interleaving-of-two-strings","type":1}],"next":{"id":"a0616ee1-bed0-46fb-ae8c-ccf3ffa2d5fd","name":"Maximum Length Of Repeated Subarray","type":1,"slug":"maximum-length-of-repeated-subarray"},"prev":{"id":"0565ef75-6d57-441e-979e-94ffeff63c46","name":"Frog Jump","type":1,"slug":"frog-jump"}}}

Interleaving Of Two Strings

1. You are given three strings - s1, s2 and s3. 2. You have to find whether s3 is formed by interleaving of s1 and s2. 3. s3 is interleaving if it contains all characters of s1 and s2, and order of all characters in individual string is preserved.

{"id":"86ad6848-39b5-4e45-a2ec-95f1612f5c31","name":"Interleaving Of Two Strings","description":"1. You are given three strings - s1, s2 and s3.\r\n2. You have to find whether s3 is formed by interleaving of s1 and s2.\r\n3. s3 is interleaving if it contains all characters of s1 and s2, and order of all characters in individual string is preserved.","inputFormat":"String s1\r\nString s2\r\nString s3","outputFormat":"true/false","constraints":"1 <= s1.length() <= 100\r\n1 <= s2.length() <= 100\r\n1 <= s3.length() <= 200","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static boolean solution(String s1, String s2, String s3) {\r\n // write your code here\r\n\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String s1 = scn.nextLine();\r\n String s2 = scn.nextLine();\r\n String s3 = scn.nextLine();\r\n System.out.println(solution(s1, s2, s3));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aabcc\r\ndbbca\r\naadbbcbcac","sampleOutput":"true\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"45f5107e-dc61-4d72-8d1f-77252cce8180","name":"Interleaving Of Two Strings","slug":"interleaving-of-two-strings","type":1}],"next":{"id":"a0616ee1-bed0-46fb-ae8c-ccf3ffa2d5fd","name":"Maximum Length Of Repeated Subarray","type":1,"slug":"maximum-length-of-repeated-subarray"},"prev":{"id":"0565ef75-6d57-441e-979e-94ffeff63c46","name":"Frog Jump","type":1,"slug":"frog-jump"}}}
plane

Editor


Loading...

Interleaving Of Two Strings

medium

1. You are given three strings - s1, s2 and s3. 2. You have to find whether s3 is formed by interleaving of s1 and s2. 3. s3 is interleaving if it contains all characters of s1 and s2, and order of all characters in individual string is preserved.

Constraints

1 <= s1.length() <= 100 1 <= s2.length() <= 100 1 <= s3.length() <= 200

Format

Input

String s1 String s2 String s3

Output

true/false

Example

Sample Input

aabcc dbbca aadbbcbcac

Sample Output

true

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode