lintcode 55. 比较字符串

难度:容易

1. Description

55. 比较字符串

2. Solution

  • c++
class Solution {
public:
    /**
     * @param A: A string
     * @param B: A string
     * @return: if string A contains all of the characters in B return true else return false
     */
    bool compareStrings(string &A, string &B) {
        // write your code here
        int ht_a[256]={0};
        int ht_b[256]={0};
        for(int i=0;i
  • python3
class Solution:
    """
    @param A: A string
    @param B: A string
    @return: if string A contains all of the characters in B return true else return false
    """
    def compareStrings(self, A, B):
        # write your code here
        ht_a = [0 for _ in range(256)]
        ht_b = [0 for _ in range(256)]
        for i in A:
            ht_a[ord(i)] += 1
        for i in B:
            ht_b[ord(i)] += 1
        for i in range(256):
            if ht_a[i]

3. Reference

  1. https://www.lintcode.com/problem/compare-strings/description

你可能感兴趣的:(lintcode 55. 比较字符串)