From 747563607292b4fc84452c4f45c2d0504531a171 Mon Sep 17 00:00:00 2001 From: Winson Huang Date: Tue, 18 Apr 2023 21:19:42 +0800 Subject: [PATCH] =?UTF-8?q?Update=200383.=E8=B5=8E=E9=87=91=E4=BF=A1.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为 Java 语言版本的代码添加长度判断 --- "problems/0383.\350\265\216\351\207\221\344\277\241.md" | 4 ++++ 1 file changed, 4 insertions(+) diff --git "a/problems/0383.\350\265\216\351\207\221\344\277\241.md" "b/problems/0383.\350\265\216\351\207\221\344\277\241.md" index d9a184b643..a3f87d4afa 100644 --- "a/problems/0383.\350\265\216\351\207\221\344\277\241.md" +++ "b/problems/0383.\350\265\216\351\207\221\344\277\241.md" @@ -117,6 +117,10 @@ Java: ```Java class Solution { public boolean canConstruct(String ransomNote, String magazine) { + // shortcut + if (ransomNote.length() > magazine.length()) { + return false; + } // 定义一个哈希映射数组 int[] record = new int[26];