• Leetcode 746. Min Cost Climbing Stairs

    时间:2022-07-07 03:38:02

    思路:动态规划。classSolution{//不能对cost数组进行写操作,因为JAVA中参数是引用publicintminCostClimbingStairs(int[]cost){intcost_0=cost[0],cost_1=cost[1];for(inti=2;i<cost.len...

  • LeetCode "473. Matchsticks to Square"

    时间:2022-07-05 22:58:36

    AtrickierDFS,withalittlebitcomplexrecursionparamtweak,andwhat'smoreimportantispruningstrategies..oryourcodewillTLE.classSolution{boolgo(vector<bool...

  • [LeetCode] 6. ZigZag Conversion 之字型转换字符串

    时间:2022-07-05 07:06:41

    Thestring "PAYPALISHIRING" iswritteninazigzagpatternonagivennumberofrowslikethis:(youmaywanttodisplaythispatterninafixedfontforbetterlegibility)PAHNAP...

  • [LeetCode] 72. Edit Distance 编辑距离

    时间:2022-07-05 01:01:39

    Giventwowords word1 and word2,findtheminimumnumberofstepsrequiredtoconvert word1 to word2.(eachoperationiscountedas1step.)Youhavethefollowing3operatio...

  • Leetcode之二分法专题-240. 搜索二维矩阵 II(Search a 2D Matrix II)

    时间:2022-07-03 19:12:10

    Leetcode之二分法专题-240.搜索二维矩阵II(Searcha2DMatrixII)编写一个高效的算法来搜索 m x n 矩阵matrix中的一个目标值target。该矩阵具有以下特性:每行的元素从左到右升序排列。每列的元素从上到下升序排列。示例:现有矩阵matrix如下:[[1,4,7,1...

  • 【LeetCode】240. Search a 2D Matrix II

    时间:2022-07-03 19:11:58

    Searcha2DMatrixIIWriteanefficientalgorithmthatsearchesforavalueinan m x n matrix.Thismatrixhasthefollowingproperties:Integersineachrowaresortedinascen...

  • 88. Merge Sorted Array【leetcode】算法,java将两个有序数组合并到一个数组中

    时间:2022-07-03 15:42:06

    88.MergeSortedArrayGiventwosortedintegerarrays nums1 and nums2,merge nums2 into nums1 asonesortedarray.Note:Youmayassumethat nums1 hasenoughspace(size...

  • leetCode 88.Merge Sorted Array (合并排序数组) 解题思路和方法

    时间:2022-07-03 15:47:06

    Giventwosortedintegerarrays nums1 and nums2,merge nums2 into nums1 asonesortedarray.Note:Youmayassumethat nums1 hasenoughspace(sizethatisgreaterorequa...

  • leetcode 88--Merge Sorted Array 数组 合并 双指针

    时间:2022-07-03 15:42:00

    Giventwosortedintegerarraysnums1andnums2,mergenums2intonums1asonesortedarray.Note:Youmayassumethatnums1hasenoughspace(sizethatisgreaterorequaltom+n)to...

  • 560. Subarray Sum Equals K leetcode

    时间:2022-07-02 13:24:26

    这道题,BF时间复杂度O(n^2)publicstaticintsubarraySum(int[]nums,intk){long[][]map=newlong[nums.length+1][nums.length+1];long[]odd=newlong[nums.length+1];long[]e...

  • LeetCode--002--两数相加(java版)

    时间:2022-07-02 10:03:46

    给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。您可以假设除了数字0之外,这两个数都不会以0 开头。示例:输入:(2->4->3)+(5...

  • Leetcode: Bomb Enemy

    时间:2022-07-02 01:32:27

    Givena2Dgrid,eachcelliseitherawall'W',anenemy'E'orempty'0'(thenumberzero),returnthemaximumenemiesyoucankillusingonebomb.Thebombkillsalltheenemiesinthe...

  • Leetcode_num13_Climbing Stairs

    时间:2022-07-02 01:33:29

    称号:Youareclimbingastaircase.Ittakes n stepstoreachtothetop.Eachtimeyoucaneitherclimb1or2steps.Inhowmanydistinctwayscanyouclimbtothetop?非常easy的思路。由于一次能...

  • Java [Leetcode 226]Invert Binary Tree

    时间:2022-07-01 15:05:48

    题目描述:Invertabinarytree.4/\27/\/\1369to4/\72/\/\9631解题思路:我只想说递归大法好。代码如下:/***Definitionforabinarytreenode.*publicclassTreeNode{*intval;*TreeNodeleft;*Tr...

  • LeetCode 226 Invert Binary Tree 解题报告

    时间:2022-07-01 15:05:12

    题目要求Invertabinarytree.题目分析及思路给定一棵二叉树,要求每一层的结点逆序。可以使用递归的思想将左右子树互换。python代码#Definitionforabinarytreenode.#classTreeNode:#   def__init__(self,x):#     se...

  • LeetCode (226):Invert Binary Tree 递归实现

    时间:2022-07-01 15:05:06

    Invertabinarytree.4/\27/\/\1369to4/\72/\/\9631Trivia:Thisproblemwasinspiredby thisoriginaltweet by MaxHowell:Google:90%ofourengineersusethesoftwareyou...

  • leetcode 226 Invert Binary Tree 翻转二叉树

    时间:2022-07-01 15:05:42

    大牛没有能做出来的题,我们要好好做一做Invertabinarytree.4/\27/\/\1369to4/\72/\/\9631Trivia:ThisproblemwasinspiredbythisoriginaltweetbyMaxHowell:Google:90%ofourengineersu...

  • Leetcode 226 Invert Binary Tree python

    时间:2022-07-01 15:05:36

    题目:Invertabinarytree.翻转二叉树。递归,每次对节点的左右节点调用invertTree函数,直到叶节点。python中也没有swap函数,当然你可以写一个,不过python中可以通过:a,b=b,a交换两个变量的值classSolution(object):definvertTre...

  • Leetcode 226. Invert Binary Tree

    时间:2022-07-01 15:05:30

    Invertabinarytree.4/\27/\/\1369to4/\72/\/\9631使用递归的trivalsolutionclassSolution(object):definvertTree(self,root):""":typeroot:TreeNode:rtype:TreeNode""...

  • (medium)LeetCode 221.Maximal Square

    时间:2022-07-01 00:44:18

    Givena2Dbinarymatrixfilledwith0'sand1's,findthelargestsquarecontainingall1'sandreturnitsarea.Forexample,giventhefollowingmatrix:10100101111111110010Re...