给定一个二叉搜索树,编写一个函数 kthSmallest 来查找其中第 k 个最小的元素。 说明: 你可以假设 k 总是有效的,1 ≤ k ≤ 二叉搜索树元素个数。 输入: root = [3,1,4,null,2], …
分类:LeetCode
[LeetCode By Go 87]345. Reverse Vowels of a String
题目 Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s =…
[LeetCode By Go 2]617. Merge Two Binary Trees
题目 Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two …
LeetCode | Search for a Range
题目: Given a sorted array of integers, find the starting and ending position of a given target value. Your algo…
LeetCode | Roman to Integer
题目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999…
LeetCode No367. Valid Perfect Square(C++版)
题目难度:Easy 分类:查找 Given a positive integer num, write a function which returns True if num is a perfect square e…
LeetCode算法题-Degree of an Array(Java实现)
这是悦乐书的第294次更新,第312篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第162题(顺位题号是697)。给定一个由正整数组成的非空数组,该数组的度数被定义为任意元素出现次数最多的次…
750. Number Of Corner Rectangles
Medium 这个题觉得真的智商不行,室友说的方法真的蛮巧妙的. 我的思路就很狭窄,一直在想什么找到四个角,wtf…it hardly works. 室友的写法是找到竖条,然后n个竖条可以组成n * (n &…
2018-05-17 342. Power of Four
题意:给你一个数,判断该数是不是4的次幂( check whether it is a power of 4). 解题思路:是4的次幂的数依次是1,4,16,64,512… 转换成二进制就是 1:1 4:10…
[LeetCode By Go 60]543. Diameter of Binary Tree
题目 Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary t…
128. Longest Consecutive Sequence
欢迎fork and star:Nowcoder-Repository-github 128. Longest Consecutive Sequence 题目 Given an unsorted array of int…
140. Word Break II(hard)
欢迎fork and star:Nowcoder-Repository-github 140. Word Break II 题目: Given a non-empty string s and a dictionary …