383. Ransom Note#1(Done)

原创 2017年01月03日 11:59:28

Solution#1

public class Solution {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] table = new int[26];
        // char[] mc = magezine.toCharArray();
        for (char c : magazine.toCharArray()) {
            table[c - 'a']++;
        }
        for (char c : ransomNote.toCharArray()) {
            if (--table[c - 'a'] < 0)
                return false;
        }
        return true;
    }
}

Problem#1

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

[LeetCode-383]Ransom Note(java)

Given
 an 
arbitrary
 ransom
 note
 string 
and 
another 
string 
containing 
letters from
 all 
the...

leetcode 383. Ransom Note

1. 题目分析  题目描述: Given an arbitrary ransom note string and another string containing letters from all...

LeetCode 383. Ransom Note

题目 : Given an arbitrary ransom note string and another string containing letters from all the magaz...

[leetcode]383. Ransom Note

题目链接题目描述 Given an arbitrary ransom note string and another string containing letters from all the ...
  • zsensei
  • zsensei
  • 2017年07月12日 16:43
  • 79

462. Minimum Moves to Equal Array Elements II\520. Detect Capital\383. Ransom Note

Minimum Moves to Equal Array Elements II 题目描述 代码实现462. Minimum Moves to Equal Array Elements II题目描述G...

LeetCode-383. Ransom Note (Java)

Given an arbitrary ransom note string and another string containing letters from all the magazines, ...
  • NOadu
  • NOadu
  • 2017年06月20日 16:25
  • 121

383. Ransom Note

Given an arbitrary ransom note string and another string containing letters from all the magazines, ...

LeetCode 383. Ransom Note 解题报告

LeetCode 383. Ransom Note 解题报告

383. Ransom Note [easy] (Python)

题目链接https://leetcode.com/problems/ransom-note/题目原文> Given
 an 
arbitrary
 ransom
 note
 string 
and ...

[LeetCode]383. Ransom Note(赎金票据)

383. Ransom NoteGiven an arbitrary ransom note string and another string containing letters from all...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:383. Ransom Note#1(Done)
举报原因:
原因补充:

(最多只允许输入30个字)