摘要: Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node. Example Given 1->2->3->4, and node 3. r 阅读全文
posted @ 2016-02-24 17:43 哥布林工程师 阅读(117) 评论(0) 推荐(0) 编辑
摘要: The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read o 阅读全文
posted @ 2016-02-24 17:31 哥布林工程师 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Count how many 1 in binary representation of a 32-bit integer. Example Given 32, return 1 Given 5, return 2 Given 1023, return 9 Challenge If the inte 阅读全文
posted @ 2016-02-24 13:59 哥布林工程师 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Cosine similarity is a measure of similarity between two vectors of an inner product space that measures the cosine of the angle between them. The cos 阅读全文
posted @ 2016-02-24 13:53 哥布林工程师 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Given a sorted (increasing order) array, Convert it to create a binary tree with minimal height. Example Given [1,2,3,4,5,6,7], return 4 / \ 2 6 / \ / 阅读全文
posted @ 2016-02-24 13:20 哥布林工程师 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Compare two strings A and B, determine whether A contains all of the characters in B. The characters in string A and B are all Upper Case letters. Exa 阅读全文
posted @ 2016-02-24 12:33 哥布林工程师 阅读(219) 评论(0) 推荐(0) 编辑
摘要: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2016-02-21 18:07 哥布林工程师 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the preorder traversal of its nodes' values. Example Given: 1 / \ 2 3 / \ 4 5 return [1,2,4,5,3]. Challenge Can you do it 阅读全文
posted @ 2016-02-21 17:56 哥布林工程师 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the postorder traversal of its nodes' values. Example Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Challenge Can 阅读全文
posted @ 2016-02-21 17:45 哥布林工程师 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return all root-to-leaf paths. 这道题主要利用一下java的一个特性,String是immutable的对象,不能修改,只能重新生成 /** * Definition of TreeNode: * public class Tr 阅读全文
posted @ 2016-02-21 11:41 哥布林工程师 阅读(151) 评论(0) 推荐(0) 编辑