{"id":"e29c194e-4613-40d9-a442-b8a3a26d6746","name":"Satisfiability Of Equality Equation","description":"You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: x==y or x!=y. Here x and y represents lowercase letters. ","inputFormat":"First line contains an integer denoting the number of equation\r\nEach of next n line contains an equation of form \"x==y\" or \"x!=y\"","outputFormat":"print true if all equations can be satisfied else print false.","constraints":"1 &lt;= equations.length &lt;= 100000\r\nequations[i].length == 4","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n void equationsPossible(vector<string> &arr)\n {\n }\n \n int main(){\n \n int n;\n cin>>n;\n vector<string> arr(n);\n for (int i = 0; i < n; i++) {\n cin>>arr[i];\n }\n \n equationsPossible(arr);\n }"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int n = Integer.parseInt(br.readLine());\r\n\r\n String[] arr = new String[n];\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = br.readLine();\r\n }\r\n\r\n System.out.println(equationsPossible(arr));\r\n }\r\n\r\n public static boolean equationsPossible(String[] equations) {\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"2\r\nb==c\r\nc!=b","sampleOutput":"false\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":"7e07fddf-83bd-421e-848f-118f1f29541c","name":"Graphs For Intermediate","slug":"graphs-for-intermediate-493","type":0},{"id":"11b0b8e0-be52-456f-9283-1bd2a8a52ac9","name":"Satisfiability Of Equality Equation","slug":"satisfiability-of-equality-equation","type":1}],"next":{"id":"8bb8aca2-b557-4766-a533-7dc3a8035e05","name":"Satisfiability of Equality Equatio Medium MCQ","type":0,"slug":"satisfiability-of-equality-equatio-medium-mcq"},"prev":{"id":"f6b9b770-7699-4f02-9db6-c2683c992e48","name":"Mother vertex","type":3,"slug":"mother-vertex"}}}

Satisfiability Of Equality Equation

You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: x==y or x!=y. Here x and y represents lowercase letters.

{"id":"e29c194e-4613-40d9-a442-b8a3a26d6746","name":"Satisfiability Of Equality Equation","description":"You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: x==y or x!=y. Here x and y represents lowercase letters. ","inputFormat":"First line contains an integer denoting the number of equation\r\nEach of next n line contains an equation of form \"x==y\" or \"x!=y\"","outputFormat":"print true if all equations can be satisfied else print false.","constraints":"1 &lt;= equations.length &lt;= 100000\r\nequations[i].length == 4","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n void equationsPossible(vector<string> &arr)\n {\n }\n \n int main(){\n \n int n;\n cin>>n;\n vector<string> arr(n);\n for (int i = 0; i < n; i++) {\n cin>>arr[i];\n }\n \n equationsPossible(arr);\n }"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int n = Integer.parseInt(br.readLine());\r\n\r\n String[] arr = new String[n];\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = br.readLine();\r\n }\r\n\r\n System.out.println(equationsPossible(arr));\r\n }\r\n\r\n public static boolean equationsPossible(String[] equations) {\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"2\r\nb==c\r\nc!=b","sampleOutput":"false\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":"7e07fddf-83bd-421e-848f-118f1f29541c","name":"Graphs For Intermediate","slug":"graphs-for-intermediate-493","type":0},{"id":"11b0b8e0-be52-456f-9283-1bd2a8a52ac9","name":"Satisfiability Of Equality Equation","slug":"satisfiability-of-equality-equation","type":1}],"next":{"id":"8bb8aca2-b557-4766-a533-7dc3a8035e05","name":"Satisfiability of Equality Equatio Medium MCQ","type":0,"slug":"satisfiability-of-equality-equatio-medium-mcq"},"prev":{"id":"f6b9b770-7699-4f02-9db6-c2683c992e48","name":"Mother vertex","type":3,"slug":"mother-vertex"}}}
plane

Editor


Loading...

Satisfiability Of Equality Equation

easy

You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: x==y or x!=y. Here x and y represents lowercase letters.

Constraints

1 <= equations.length <= 100000 equations[i].length == 4

Format

Input

First line contains an integer denoting the number of equation Each of next n line contains an equation of form "x==y" or "x!=y"

Output

print true if all equations can be satisfied else print false.

Example

Sample Input

2 b==c c!=b

Sample Output

false

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode