摘要: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2017-07-19 18:34 immjc 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: All letters in hexadec 阅读全文
posted @ 2017-07-19 18:18 immjc 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: 给定两个只含有数字字符串,将字符串中的数字和返回一个字符串。并且要求不能使用整数类库 阅读全文
posted @ 2017-07-19 17:06 immjc 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 将一个有序的数组转换为一棵高度平衡的二叉树。这道题像中序遍历的逆过程。所以先找到数组中中间位置的值作为树 阅读全文
posted @ 2017-07-19 16:34 immjc 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath betwee 阅读全文
posted @ 2017-07-19 16:13 immjc 阅读(131) 评论(0) 推荐(0) 编辑