[OJ.leetcode] maximum-depth-of-binary-tree https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/ Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solut.. 더보기 [OJ.leetcode] add two numbers https://oj.leetcode.com/problems/add-two-numbers/ You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 /* 생각해야할 케이스 : 두 number의 길이가 다를 경우, carry 처리 발생한 Errors: 1)list pointer 처리 미숙 2)wh.. 더보기 [OJ.leetcode] search-in-rotated-sorted-array https://oj.leetcode.com/problems/search-in-rotated-sorted-array/ Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array. /* binary search를 응용하여 해결 가능. test case [4,5,6,7,8,1,2,3] .. 더보기 이전 1 2 3 4 5 6 7 8 ··· 44 다음