摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina 阅读全文
posted @ 2018-12-19 19:14 fatttcat 阅读(79) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is d 阅读全文
posted @ 2018-12-19 18:43 fatttcat 阅读(77) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list in O(n log n) time using constant space complexity. Example 1: Example 2: divide and conquer + merge sort,先找中点,断开,再merge time: O(nl 阅读全文
posted @ 2018-12-19 18:17 fatttcat 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2018-12-19 17:53 fatttcat 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文
posted @ 2018-12-19 16:28 fatttcat 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: In 阅读全文
posted @ 2018-12-19 15:35 fatttcat 阅读(81) 评论(0) 推荐(0) 编辑
摘要: sort & comparator 各种排序方法总结 bit manipulation A summary: how to use bit manipulation to solve problems 阅读全文
posted @ 2018-12-19 14:57 fatttcat 阅读(100) 评论(0) 推荐(0) 编辑
摘要: In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permu 阅读全文
posted @ 2018-12-19 14:52 fatttcat 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w 阅读全文
posted @ 2018-12-19 14:25 fatttcat 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w 阅读全文
posted @ 2018-12-19 13:51 fatttcat 阅读(105) 评论(0) 推荐(0) 编辑
摘要: You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id. 阅读全文
posted @ 2018-12-19 13:19 fatttcat 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Suppose an array sorted in ascending order 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]). F 阅读全文
posted @ 2018-12-19 12:40 fatttcat 阅读(89) 评论(0) 推荐(0) 编辑
摘要: Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-white 阅读全文
posted @ 2018-12-19 12:09 fatttcat 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proport 阅读全文
posted @ 2018-12-19 10:07 fatttcat 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100 阅读全文
posted @ 2018-12-19 05:12 fatttcat 阅读(88) 评论(0) 推荐(0) 编辑
摘要: The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it retu 阅读全文
posted @ 2018-12-19 04:43 fatttcat 阅读(133) 评论(0) 推荐(0) 编辑
摘要: The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it retu 阅读全文
posted @ 2018-12-19 04:09 fatttcat 阅读(155) 评论(0) 推荐(0) 编辑