Sunday, September 4, 2016

Leetcode 389 Solution : Find the difference

Problem description is given in following link

https://leetcode.com/problems/find-the-difference/

Solution:

class Solution {
public:
    char findTheDifference(string s, string t) {
        int val = 0;
        for (int i=0;i<t.size();i++){
            val = val + t.at(i);
        }
       
        for (int i=0;i<s.size();i++){
            val = val - s.at(i);
        }
        return val;
    }
};

Status : Accepted

No comments:

Post a Comment