随笔分类 -  Leetcode

记录自己写leetcode的过程
摘要:Leetcode Google VIP Plus Dynamic Programming Medium Problems 276 Paint Fence Question: You are painting a fence of n posts with k different colors.You 阅读全文
posted @ 2021-04-11 16:07 BOTAK 阅读(139) 评论(0) 推荐(0)
摘要:leetcode(daily 11-8 ~ 11-14) leetcode 每日一题 11-8 122. 买卖股票的最佳时机 II class Solution { public int maxProfit(int[] prices) { // 贪心算法:只要今天买明天赚就买入 // profit用 阅读全文
posted @ 2020-11-16 10:22 BOTAK 阅读(82) 评论(0) 推荐(0)
摘要:Leetcode(Random-2) leetcode随机写5道题而已 没有别的意思 1093. 大样本统计 // 代码是错的 ,但是不知道哪里出错了 只通过了一半的用例 class Solution { public double[] sampleStats(int[] count) { // m 阅读全文
posted @ 2020-11-05 18:39 BOTAK 阅读(108) 评论(0) 推荐(0)
摘要:Leetcode (Random) Leetcode随意点开的题目解答 991. 坏了的计算器 class Solution { public int brokenCalc(int X, int Y) { // 定义结果 int res = 0; boolean flag = true; // 肯定 阅读全文
posted @ 2020-11-05 18:37 BOTAK 阅读(82) 评论(0) 推荐(0)
摘要:Leetcode(easy Tree) leetcode 简单的树的题目,记录一下自己的刷题过程 100. 相同的树 给定两个二叉树,编写一个函数来检验它们是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 /** * Definition for a binary tr 阅读全文
posted @ 2020-11-05 18:36 BOTAK 阅读(299) 评论(0) 推荐(0)
摘要:Leetcode(mystery) leetcode 迷题目 292. Nim 游戏 你和你的朋友,两个人一起玩 Nim 游戏: 桌子上有一堆石头。 你们轮流进行自己的回合,你作为先手。 每一回合,轮到的人拿掉 1 - 3 块石头。 拿掉最后一块石头的人就是获胜者。 j假设你们每一步都是最优解。请编 阅读全文
posted @ 2020-11-05 18:31 BOTAK 阅读(95) 评论(0) 推荐(0)
摘要:Leetcode(easy Double pointer) Leetcode 双指针简单题目 26 删除排序数组中的重复项 class Solution{ public int removeDuplicates(int[] nums){ // step代表慢指针 int step = 0; // 这 阅读全文
posted @ 2020-11-05 18:27 BOTAK 阅读(110) 评论(0) 推荐(0)
摘要:Leetcode easy ListNode Leetcode 简单链表题目 21 合并两个有序链表 题目:将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 /** * Definition for singly-linked list. * publ 阅读全文
posted @ 2020-11-05 18:26 BOTAK 阅读(173) 评论(0) 推荐(0)
摘要:Leetcode(easy Graph) leetcode 图的简单题目 997 找到小镇的法官 题解 这是一道关于图的基本知识的题目,入度与出度的使用。符合题目要求的人一定是出度为0,入度为N-1 class Solution{ public int findJudge(int N,int[][] 阅读全文
posted @ 2020-11-04 16:15 BOTAK 阅读(90) 评论(0) 推荐(0)
摘要:Leetcode(easy Bit) leetcode位运算的简单的题目总结 136 只出现一次的数字 题目:给定一个非空整数数组,除了某一个元素只出现一次之外,其余每个元素均出现了两次,找出那个只出现一次的元素。 说明:你的算法应该具有线性时间复杂度,而且尽量不使用额外空间 解题思路:用到了位运算 阅读全文
posted @ 2020-11-04 16:10 BOTAK 阅读(164) 评论(0) 推荐(0)
摘要:Leetcode(easy Greedy) leetcode 贪心算法的简单题目 122. 买卖股票的最佳时机 II 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。注意:你不能同时参与多笔交易 阅读全文
posted @ 2020-11-04 15:56 BOTAK 阅读(103) 评论(0) 推荐(0)
摘要:Leetcode (easy heap) leetcode 简单的堆题目总结 703 数据流中的第K大元素 class KthLargest{ int size; private PriorityQueue<Integer> q; public KthLargest(int k,int[] nums 阅读全文
posted @ 2020-11-04 15:52 BOTAK 阅读(86) 评论(0) 推荐(0)
摘要:Leetcode easy stack leetcode简单题目中的栈的全部题目 20 有效的括号 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。 注意空字符串可被认 阅读全文
posted @ 2020-11-04 13:30 BOTAK 阅读(149) 评论(0) 推荐(0)