category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

B - Caesar Cipher, easy, string, implementation

method 1 ```cpp string s, t; cin >> s >> t; for (int diff = 0; diff <= 25; diff++) { string ans; for (int i = 0; i < s.size(); i++) { char next_character = ((s[i] + diff - 'a') % 26 + 'a'); // important step ans.push_back(next_character); } if (ans == t) { cout << "Yes\n"; return; } } cout << "No\n"; return; ```
method 2 ```cpp string s, t; cin >> s >> t; int k = (s[0] - t[0]) % 26; if (k < 0) k += 26; for (int i = 0; i < s.size(); i++) { int u = ((int)s[i] - (int)t[i]) % 26; if (u < 0) u += 26; if (k != u) { cout << "No" << endl; return; } } cout << "Yes" << endl; ```