ransom-note

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;
}
}
上一篇:【Web技术】399- 浅谈前端代码加密


下一篇:一种简单有效的VBA源代码加密办法,支持64位宿主,适用于大部分VBA代码加密