摘要: 题目: The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out 阅读全文
posted @ 2019-04-14 16:36 silentteller 阅读(232) 评论(0) 推荐(0)
摘要: 题目: Find the sum of all left leaves in a given binary tree. Example: 分析: 给定一颗二叉树,求左叶子节点的和。 重点在于如何判断左叶子节点,如果一个节点的left存在,且left的left和right都为空,那么我们就可以将这个节 阅读全文
posted @ 2019-04-14 15:51 silentteller 阅读(131) 评论(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 阅读全文
posted @ 2019-04-14 15:38 silentteller 阅读(258) 评论(0) 推荐(0)
摘要: 题目: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, ca 阅读全文
posted @ 2019-04-14 15:22 silentteller 阅读(298) 评论(0) 推荐(0)
摘要: 题目: There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) afte 阅读全文
posted @ 2019-04-11 01:07 silentteller 阅读(274) 评论(0) 推荐(0)
摘要: 题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would hav 阅读全文
posted @ 2019-04-11 00:59 silentteller 阅读(198) 评论(0) 推荐(0)
摘要: 总结一下平时常用的vector的用法。 初始化 int a[3] = {10, 20, 30}; vector<int> v1; //{} vector<int> v2(3); //{0, 0, 0} vector<int> v3 {1, 2, 3, 4, 5}; //vector<int> v3 阅读全文
posted @ 2019-03-29 13:32 silentteller 阅读(473) 评论(0) 推荐(0)
摘要: 题目: Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar o 阅读全文
posted @ 2019-03-15 18:40 silentteller 阅读(338) 评论(0) 推荐(0)
摘要: 题目: Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 分析: 分 阅读全文
posted @ 2019-03-02 00:12 silentteller 阅读(285) 评论(0) 推荐(0)
摘要: 题目: Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make 阅读全文
posted @ 2019-01-05 14:04 silentteller 阅读(146) 评论(0) 推荐(0)