随笔分类 -  Algorithms

摘要:// --- Directions // Given a string, return the character that is most // commonly used in the string. // --- Examples // maxChar("abcccccccd") === "c" // maxChar("apple 1231111") === "1" function m... 阅读全文
posted @ 2019-05-31 22:15 Zhentiw 阅读(189) 评论(0) 推荐(0) 编辑
摘要:How to calculate the area of polygon. For a triangle like: We can calculate the area: This approach is able to solve all simple polygon areas problem: 阅读全文
posted @ 2019-05-18 21:38 Zhentiw 阅读(311) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-05-16 01:30 Zhentiw 阅读(1) 评论(0) 推荐(0) 编辑
摘要:12's factors are: {1,2,3,4,6,12} 阅读全文
posted @ 2019-05-14 23:36 Zhentiw 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Given a number N, the output should be the all the prime numbers which is less than N. The solution is called Sieve of Eratosthenes: First of all, we 阅读全文
posted @ 2019-05-14 23:09 Zhentiw 阅读(315) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-05-12 04:55 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:125, how to conver to binary number? 阅读全文
posted @ 2019-05-10 21:50 Zhentiw 阅读(216) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。
posted @ 2019-05-07 03:03 Zhentiw 阅读(1) 评论(0) 推荐(0) 编辑
摘要:Asking you to implement the Math.pow method The navie implemenation can be: It takes O(N) time. Now if we want to improve it to O(logN) time. we can d 阅读全文
posted @ 2019-04-29 22:17 Zhentiw 阅读(217) 评论(0) 推荐(0) 编辑
摘要:For Fibonacci Sequence, the space complexity should be the O(logN), which is the height of tree. Check the source 阅读全文
posted @ 2019-04-29 01:18 Zhentiw 阅读(318) 评论(0) 推荐(0) 编辑
摘要:function Node(val) { return { val, left: null, right: null }; } function Tree() { return { root: null, addLeft(val, root) { const newNode = Node(val); root.lef... 阅读全文
posted @ 2019-04-11 21:24 Zhentiw 阅读(263) 评论(0) 推荐(0) 编辑
摘要:Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer 阅读全文
posted @ 2019-04-07 02:27 Zhentiw 阅读(354) 评论(0) 推荐(0) 编辑
摘要:You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be rep 阅读全文
posted @ 2019-04-06 22:02 Zhentiw 阅读(187) 评论(0) 推荐(0) 编辑
摘要:Assume we have two linked list, we want to find a point in each list, from which all the the nodes share the same value in both list. Then we call thi 阅读全文
posted @ 2019-04-03 17:25 Zhentiw 阅读(356) 评论(0) 推荐(0) 编辑
摘要:For the given tree, in order traverse is: visit left side root visit right side The successor is the one right next to the target: So, given the tree 阅读全文
posted @ 2019-04-02 16:33 Zhentiw 阅读(251) 评论(0) 推荐(0) 编辑
摘要:The solution for the problem can be divided into three cases: case 1: if the delete node is leaf node, then we can simply remove it case 2: if the del 阅读全文
posted @ 2019-04-01 16:45 Zhentiw 阅读(439) 评论(0) 推荐(0) 编辑
摘要:What is Binary Search Tree (BST) A binary tree in which for each node, value of all the nodes in left subtree is less or equal and value of all the no 阅读全文
posted @ 2019-04-01 04:36 Zhentiw 阅读(329) 评论(0) 推荐(0) 编辑
摘要:Algorithm or program to check for balanced parentheses in an expression using stack data structure. For example: The idea to solve the problem is: ope 阅读全文
posted @ 2019-03-30 23:34 Zhentiw 阅读(203) 评论(0) 推荐(0) 编辑
摘要:The idea to solve the problem is set five variable, first direction, we need to switch direction after we finish printing one row or one column. Then 阅读全文
posted @ 2019-03-28 03:23 Zhentiw 阅读(291) 评论(0) 推荐(0) 编辑
摘要:Give you set of meetings start time and end time, count how many meeting rooms needed. For example: We can use a memo table to store the at which time 阅读全文
posted @ 2019-03-27 02:03 Zhentiw 阅读(185) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示