摘要: Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element 阅读全文
posted @ 2017-09-13 18:59 Yancea 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt 阅读全文
posted @ 2017-09-13 18:23 Yancea 阅读(99) 评论(0) 推荐(0) 编辑
摘要: Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 阅读全文
posted @ 2017-09-12 23:35 Yancea 阅读(76) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文
posted @ 2017-09-12 16:11 Yancea 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. E 阅读全文
posted @ 2017-09-12 15:28 Yancea 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2017-09-12 15:11 Yancea 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g 阅读全文
posted @ 2017-09-12 14:23 Yancea 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2017-09-12 10:54 Yancea 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice ver 阅读全文
posted @ 2017-09-11 22:38 Yancea 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文
posted @ 2017-09-11 22:34 Yancea 阅读(123) 评论(0) 推荐(0) 编辑