순회2 [leetcode 234] Palindrome Linked List Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) time and O(1) space? 문제 풀이: 첨에 follow up을 무시하고 풀었다. 어떻게 거꾸로 돌지?해서 무시함 ㅇㅇ 첫 번째 방법(c++): 연결리스트를 모두 벡터에 집어넣고 전체 길이가 홀수/짝수일때를 나눠서 가운데부터 비교한다. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *n.. 2020. 10. 31. [leetcode 437] Path Sum III You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need to start or end at the root or a leaf, but it must go downwards (traveling only from parent nodes to child nodes). The tree has no more than 1,000 nodes and the values are in the range -1,000,000 to 1,000,000. Example: root = [10,5,-3,3,2,null,11,3,.. 2020. 10. 18. 이전 1 다음