第一轮刷题解法: 1)如果长度为1,返回第一个字符串;如果存在空,返回空;否则长度递增,逐一比较,有不同则返回当前前缀。 class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: count_prefix = 1 i ...
分类:
编程语言 时间:
2021-06-02 19:01:16
阅读次数:
0
Leetcode 第243场周赛 前两题简单。 第三题一个模拟,容易边界处理不好。 第四题dp,卡精度。 第一题 https://leetcode-cn.com/problems/check-if-word-equals-summation-of-two-words/ 直接算就行。 class So ...
分类:
其他好文 时间:
2021-06-02 18:17:06
阅读次数:
0
JAVA 暴力(BFS): public final int[] findBall(int[][] grid) { int len = grid[0].length; int[] balls = new int[len]; for (int i = 0; i < balls.length; i++) ...
分类:
其他好文 时间:
2021-06-02 18:14:01
阅读次数:
0
227. 基本计算器 II Difficulty: ** 示例 1: 输入:s = "3+22" 输出:7 示例 2: 输入:s = " 3/2 " 输出:1 示例 3: 输入:s = " 3+5 / 2 " 输出:5 提示: 1 ? s.length ? 3 * 105 s 由整数和算符 ('+' ...
分类:
其他好文 时间:
2021-06-02 17:24:20
阅读次数:
0
题目 package whale.leetcode.simple; /** * @Author: WhaleFall541 * @Date: 2021/5/29 20:30 */ public class AddTwoSumLinkedList { public static class ListN ...
分类:
其他好文 时间:
2021-06-02 16:21:23
阅读次数:
0
160. 相交链表 Difficulty: 简单 编写一个程序,找到两个单链表相交的起始节点。 如下面的两个链表**:** 在节点 c1 开始相交。 示例 1: 输入:intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skip ...
分类:
其他好文 时间:
2021-06-02 16:01:26
阅读次数:
0
https://leetcode-cn.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/ 根据一棵树的中序遍历与后序遍历构造二叉树。 注意: 你可以假设树中没有重复的元素。 例如,给出 中序遍历 inor ...
分类:
其他好文 时间:
2021-06-02 15:25:05
阅读次数:
0
简介 忘不了, 这是华为面试官给我的面试题, 但是我没有在1分钟内做出来. 或许那个时候面试官本来就不想要一个人. 使用模拟的方法. 使用一个visited数组, 判断是否走到边界, 只有四个方向: j++ i++ j-- i-- 依次循环. code class Solution { public ...
分类:
编程语言 时间:
2021-06-02 14:55:47
阅读次数:
0
三步问题。有个小孩正在上楼梯,楼梯有n阶台阶,小孩一次可以上1阶、2阶或3阶。实现一种方法,计算小孩有多少种上楼梯的方式。结果可能很大,你需要对结果模1000000007。 示例1: 输入:n = 3 输出:4 说明: 有四种走法示例2: 输入:n = 5 输出:13提示: n范围在[1, 1000 ...
分类:
其他好文 时间:
2021-06-02 14:38:48
阅读次数:
0
package leetcode; import java.util.ArrayList; import java.util.List; public class demo_22 { public List<String> generateParenthesis(int n) { List<Stri ...
分类:
其他好文 时间:
2021-06-02 14:38:15
阅读次数:
0