The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number …
标签:LeetCode
326. 3的幂
一、题目原型: 给定一个整数,写一个函数来判断它是否是 3 的幂次方。 二、示例剖析: 输入: 27 输出: true 输入: 0 输出: false 输入: 9 输出: true 输入: 45 输出: false 三、…
71. 简化路径-leetcode简化Unix路径算法的Java实现
我的LeetCode评论: https://leetcode-cn.com/problems/simplify-path/comments/31264 我的GitHub代码地址: https://github.com/g…
LeetCode 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1] , nums2 =…
LeetCode653. Two Sum IV - Input is a BST
The simplest solution for this question is probably get all the value out into an array and solve it just like…
[剑指offer] 序列化二叉树
本文首发于我的个人博客:尾尾部落 题目描述 请实现两个函数,分别用来序列化和反序列化二叉树 解题思路 对于序列化:使用前序遍历,递归的将二叉树的值转化为字符,并且在每次二叉树的结点不为空时,在转化val所得的字符之后添加…
806. Number of Lines To Write String
题目地址:https://leetcode.com/problems/number-of-lines-to-write-string/description/ 大意:给定一个字符串,让他们分行书写,每个字符串长度给定,当…
[剑指offer] 丑数
本文首发于我的个人博客:尾尾部落 题目描述 把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个…
Day2. Two Sum(1)
问题描述 Given an array of integers, return indices of the two numbers such that they add up to a specific target.…
[LeetCode][Search] 296. Best Meeting Point
Problem More LeetCode Discussions A group of two or more people wants to meet and minimize the total travel di…
LeetCode算法题-Next Greater Element I(Java实现)
这是悦乐书的第244次更新,第257篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第111题(顺位题号是496)。你有两个数组(没有重复)nums1和nums2,其中nums1的元素是num…
[LeetCode][DP] 265. Paint House II
Problem There are a row of n houses, each house can be painted with one of the k colors. The cost of painting …