LeetCode

LeetCode

[LeetCode] 242. Valid Anagram

두 문자열 s와 t가 주어지면 t가 s의 애너그램이면 참을 반환하고, 그렇지 않으면 거짓을 반환합니다. 애너그램은 다른 단어 또는 구의 글자를 재배열하여 만든 단어 또는 구문으로, 일반적으로 원래 글자를 모두 정확히 한 번 사용합니다. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: false 문제접근 해시맵을 이용해 접근하였습니다. 중요한것은 s와 t의 길이가 같지않으면 false라는 것입니다. 나머지는 map을 이해하고있다면 크게 어렵지 않습니다. public boolean isAnagram(String s, String t) { if (s.length() !..

LeetCode

[LeetCode] 383. Ransom Note

Ransom Note - LeetCode Can you solve this real interview question? Ransom Note - Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each letter in magazine can only be used once in ranso leetcode.com 두 문자열 ransomNote와 magazine이 주어졌을 때, magazine의 문자를 사용하여 ransomNote를 구성할 수 있으면 true를 반환하고 그렇지 않으면 false를 반환..

LeetCode

[LeetCode] 219. Contains Duplicate II

Contains Duplicate II - LeetCode Can you solve this real interview question? Contains Duplicate II - Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j)

LeetCode

[LeetCode] 1. Two Sum

Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not leetcode.com int 배열이 주어지고 target이 주어지면 2개의 조합으로 target이 되는 조합을 반환하는 문제입니다. Example 1: Input: nums = [2,7,11,15], target = 9..

Sol b
'LeetCode' 카테고리의 글 목록 (5 Page)