Advertisement
haqon

389. Find the Difference (leetcode)

Aug 22nd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.33 KB | None | 0 0
  1. class Solution {
  2.     public char findTheDifference(String s, String t) {
  3.         int res = 0;
  4.         for(int i = 0; i < s.length(); i++){
  5.             res ^= (int) s.charAt(i);
  6.             res ^= (int) t.charAt(i);
  7.         }
  8.        
  9.          res ^= (int) t.charAt(s.length());
  10.        
  11.         return (char) res;
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement