Leetcode Medium Javascript
文章平均质量分 86
RockPaperProgrammer
Github: https://github.com/didi0613
展开
-
69. Sqrt(x)
题目原意: Implement int sqrt(int x). Compute and return the square root of x. 实现int sqrt(int x). 计算并返回x的平方根。 Solution 1:初始想法,brute force 解题思路: 需要注意的是此题不用考虑非正数,加上题目标注返回值为int,因此只需要返回x的Mat原创 2016-07-02 06:31:58 · 263 阅读 · 0 评论 -
Binary Tree Preorder -JS
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive soluti原创 2016-06-17 07:34:43 · 261 阅读 · 0 评论 -
208. Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods. Note: You may assume that all inputs are consist of lowercase letters a-z. 题目原意: 实现字典树数据结构,包含插入,查找,前缀的方法。 注意: 可以假定所有输入由小写字原创 2016-07-03 15:22:33 · 270 阅读 · 0 评论 -
Binary Tree Inorder Traversal - JS
Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,3,2]. Note: Recursive solu原创 2016-06-17 12:57:45 · 237 阅读 · 0 评论 -
Permutations
Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1原创 2016-06-18 04:01:50 · 194 阅读 · 0 评论 -
Subsets
Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a solution is: [ [3], [1],原创 2016-06-18 06:55:15 · 148 阅读 · 0 评论 -
Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]原创 2016-06-18 07:23:04 · 186 阅读 · 0 评论