JavaScript版leetcode部分题目解答
leetcode
leetcode上的算法题目,个人觉得挺有趣的,用JavaScript写完解答后拿出来和大家分享一下,有兴趣的同学也可以给个star,后续会陆续更新…
Algorithm
| # | title | describe | difficulty | completion | recommend |
|---|---|---|---|---|---|
| 1 | tow sum | 两数之和 | easy | yes | yes |
| 2 | add two numbers | 两数相加 | medium | yes | yes |
| 7 | reverse integer | 整数反转 | easy | yes | . |
| 9 | palindrome number | 回文数 | easy | yes | . |
| 14 | longest common prefix | 最长公共前缀 | easy | yes | yes |
| 20 | valid parentheses | 有效的括号 | easy | yes | . |
| 35 | search insert position | 搜索插入位置 | easy | no | . |
| 53 | Maximum Subarray | 最大子序和 | easy | yes | yes |
| 66 | plus one | 加1 | easy | yes | . |
| 67 | add binary | 二进制求和 | easy | yes | . |
| 69 | sqrtx | x的平方根 | easy | yes | yes |
| 70 | climbing stairs | 爬楼梯 | easy | yes | yes |
| 83 | remove duplicates from sorted list | 删除排序链表中的重复元素 | easy | yes | yes |
| 94 | binary tree inorder traversal | 二叉树的中序遍历 | medium | yes | yes |
| 101 | symmetric tree | 对称二叉树 | easy | yes | . |
| 104 | maximum depth of binary tree | 二叉树的最大深度 | easy | yes | yes |
| 111 | minimum depth of binary tree | 二叉树的最小深度 | easy | yes | yes |
| 144 | binary tree preorder traversal | 二叉树的前序遍历 | medium | yes | yes |
| 145 | binary tree postorder traversal | 二叉树的后序遍历 | hard | yes | yes |
| 169 | majority element | 求众数 | easy | yes | . |
| 189 | rotate array | 旋转数组 | easy | yes | yes |
| 190 | reverse bits | 颠倒二进制位 | easy | yes | . |
| 191 | number of 1 bits | 位1的个数 | easy | yes | . |
| 215 | kth largest element in an array | 数组中的第K个最大元素 | medium | no | yes |
| 226 | invert binary tree | 翻转二叉树 | easy | yes | . |
| 257 | binary tree paths | 二叉树的所有路径 | easy | yes | . |
| 700 | search in a binary search tree | 二叉搜索树中的搜索 | easy | yes | . |
Database
| # | title | describe | difficulty | completion | recommend |
|---|---|---|---|---|---|
| 175 | combine two tables | 组合两个表 | easy | yes | . |
| 176 | second highest salary | 第二高薪 | easy | yes | . |
| 181 | employees earning more than their managers | 超过经理收入的员工 | easy | yes | . |
| 183 | customers who never order | 从不订购的客户 | easy | yes | . |