본문 바로가기

leetcode3

[leetcode] 49.Group Anagrams 49.Group Anagrams 문제 Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ] Note: All inputs will be in lowercase. The order of your output does not matter. 풀이 Anagram 은 단어나 문장을 구성하고 있는 문자의 순서를 바꾸어 다른 단어나 문장을 만드는 놀이이다. 주어진 input에서 Anagram 인 것들만 모아주면 되는 문제이다. input이 모두 소문자이기 떄문에 대소문자를 .. 2020. 8. 24.
[leetcode] 240. Search a 2D Matrix II 240. Search a 2D Matrix II 문제 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers in each column are sorted in ascending from top to bottom. Example : Consider the following matrix: ] Given target = 5, return true. Given target = 20, return false. 풀이 주어진 matr.. 2020. 8. 23.
[leetcode] 876. Middle of the Linked List 876. Middle of the Linked List 문제 Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: .val = 3, ans.next.val = 4, ans.next.next.val = 5, and ans.next.next.next = NULL. Example 2: Input: [1,2,3,4,5,6] Output: Node 4 from this list (Serialization: [4,5,6]) Since the list has two mid.. 2020. 7. 29.