https://leetcode.com/problems/ransom-note/

public class Solution {
public boolean canConstruct(String ransomNote, String magazine) {
char[] chRan = ransomNote.toCharArray();
char[] chMag = magazine.toCharArray();
Arrays.sort(chRan);
Arrays.sort(chMag);
int j = 0;
for (int i=0; i<chRan.length; i++) {
for (; j<chMag.length; j++) {
if (chMag[j] > chRan[i]) {
return false;
}
if (chMag[j] == chRan[i]) {
break;
}
}
if (j < chMag.length) {
j++;
}
else {
return false;
}
}
return true;
}
}

ransom-note的更多相关文章

  1. [LeetCode] Ransom Note 赎金条

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

  2. leetcode 383. Ransom Note

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

  3. 383. Ransom Note

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

  4. leetcode修炼之路——383. Ransom Note

    题目是这样的 Given
 an 
arbitrary
 ransom
 note
 string 
and 
another 
string 
containing 
letters from
 a ...

  5. 14. leetcode 383. Ransom Note

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

  6. Ransom Note(383)

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

  7. [Swift]LeetCode383. 赎金信 | Ransom Note

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

  8. [LeetCode&Python] Problem 383. Ransom Note

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

  9. leetcode之Ransom Note

    题目描述: 
Given
 an 
arbitrary
 ransom
 note
 string 
and 
another 
string 
containing 
letters from
 a ...

  10. Java [Leetcode 383]Ransom Note

    题目描述: Given
 an 
arbitrary
 ransom
 note
 string 
and 
another 
string 
containing 
letters from
 al ...

随机推荐

  1. 使用GIT进行源码管理——GUI客户端

    很多人对GIT GUI客户端是非常不屑一顾的,但我非常喜欢GUI的方便快捷,也不用记忆冗杂的命令,本文简单的介绍了几种免费的Windows下的GIT客户端,方便大家使用. Git for Window ...

  2. 基于ONVIF协议的摄像头开发总结

    <什么是ONVIF协议>     2008年5月,由安讯士(AXIS)联合博世(BOSCH)及索尼(SONY)公司三方宣布携手共同成立一个国际开放型网络视频产品标准网络接口开发论坛,取名为 ...

  3. 时间插件datetimepicker

    相关datetimepicker用法查看官网http://eonasdan.github.io/bootstrap-datetimepicker/ {% load staticfiles %} < ...

  4. PHP的钩子实现解析

    钩子是编程里一个常见的概念,非常的重要.它使得系统变得非常容易拓展(而不用理解其内部的实现机理,这样可以减少很多工作量).只要有一个钩子样本,能很容易仿照第一个钩子快速的编写第二个钩子,这里对钩子进行 ...

  5. 王彪-20162321《程序设计与数据结构2nd》-第十一周学习总结与实验报告

    邻接矩阵实现 例图 分析 变量 需要一个链表来保存数据-即保存结点 需要一个二维数组来保存每个变得权值,有则填入具体数值,没有则用0 定义一个保存边个数的值 函数方法 得到图中边的个数 得到结点的数据 ...

  6. hdu 3397 线段树

    题意: Change operations:0 a b change all characters into '0's in [a , b]1 a b change all characters in ...

  7. 监控 Linux 系统的 7 个命令行工具

    监控 Linux 系统的 7 个命令行工具: " 深入 关于Linux最棒的一件事之一是你能深入操作系统,来探索它是如何工作的,并寻找机会来微调性能或诊断问题.这里有一些基本的命令行工具,让 ...

  8. bzoj 1176: [Balkan2007]Mokia&&2683: 简单题 -- cdq分治

    2683: 简单题 Time Limit: 50 Sec  Memory Limit: 128 MB Description 你有一个N*N的棋盘,每个格子内有一个整数,初始时的时候全部为0,现在需要 ...

  9. VC++ 设置控件显示文本的前景色、背景色以及字体

    在每个控件开始绘制之前,都会向其父窗口发送WM_CTLCOLOR通告消息,在该消息的处理函数中,可以设置控件显示文本的前景色.背景色以及字体.该消息处理函数还要求返回一个画刷的句柄,用于在控件具体的绘 ...

  10. ROS知识(16)----如何编译时自动链接同一个工作空间的其他包的头文件(包含message,srv,action自动生成的头文件)

    catkin_make编译时,往往需要自动链接同一个工作空间的其他包的头文件.否则会出现类似如下的错误: /home/xx/xx_ws/srcA_package/src/db.hpp:13:26: f ...