`{"id":"313fd97a-b558-49cc-9a56-287d414f2cfd","name":"Valid Anagram","description":"1. You are given two strings s1 and s2.\r\n2. You have to determine if s2 is an anagram of s1.","inputFormat":"Two strings s1 and s2","outputFormat":"true/false","constraints":"1 &lt;= length of string &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nbool isValidAnagram(string s,string t){\n//Write your code here \n}\n\nint main(){\n string s,t;\n cin >> s >> t;\n if(isValidAnagram(s,t)){\n cout << \"true\" << endl;\n }\n else{\n cout << \"false\" << endl;\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\t\r\n\tpublic static boolean solution(String s1, String s2){\r\n\t\t// write your code here\r\n\r\n\t\treturn false;\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1,s2));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"pepcoding\r\ncodingpep","sampleOutput":"true\r\n","questionVideo":"https://www.youtube.com/embed/m7kLirMTp04?end=94","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":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"fb852629-309d-4db8-969e-25f2c6b2063c","name":"Valid Anagram","slug":"valid-anagram","type":1}],"next":{"id":"19e81278-bc30-4fdd-b542-cef0509291e9","name":"Valid Anagram MCQ","type":0,"slug":"valid-anagram-mcq"},"prev":{"id":"dba08c68-b271-47de-a961-a732ffe3160f","name":"Find Anagram Mappings","type":3,"slug":"find-anagram-mappings"}}}`

# Valid Anagram

1. You are given two strings s1 and s2. 2. You have to determine if s2 is an anagram of s1.

`{"id":"313fd97a-b558-49cc-9a56-287d414f2cfd","name":"Valid Anagram","description":"1. You are given two strings s1 and s2.\r\n2. You have to determine if s2 is an anagram of s1.","inputFormat":"Two strings s1 and s2","outputFormat":"true/false","constraints":"1 &lt;= length of string &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nbool isValidAnagram(string s,string t){\n//Write your code here \n}\n\nint main(){\n string s,t;\n cin >> s >> t;\n if(isValidAnagram(s,t)){\n cout << \"true\" << endl;\n }\n else{\n cout << \"false\" << endl;\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\t\r\n\tpublic static boolean solution(String s1, String s2){\r\n\t\t// write your code here\r\n\r\n\t\treturn false;\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1,s2));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"pepcoding\r\ncodingpep","sampleOutput":"true\r\n","questionVideo":"https://www.youtube.com/embed/m7kLirMTp04?end=94","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":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"fb852629-309d-4db8-969e-25f2c6b2063c","name":"Valid Anagram","slug":"valid-anagram","type":1}],"next":{"id":"19e81278-bc30-4fdd-b542-cef0509291e9","name":"Valid Anagram MCQ","type":0,"slug":"valid-anagram-mcq"},"prev":{"id":"dba08c68-b271-47de-a961-a732ffe3160f","name":"Find Anagram Mappings","type":3,"slug":"find-anagram-mappings"}}}`

Editor

# Valid Anagram

easy

1. You are given two strings s1 and s2. 2. You have to determine if s2 is an anagram of s1.

## Constraints

1 <= length of string <= 10^5

## Format

### Input

Two strings s1 and s2

true/false

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}pepcoding codingpep```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}true ```

Question Video

Discussions

Show Discussion

Related Resources