今天的字符类还比较简单 package y2019.Algorithm.str.easy; import java.util.HashMap; import java.util.Map; import java.util.Stack; /** * @ClassName IsValid * @Description 20. Valid Parentheses * * Given a string containing just the characters '(', ')', '{', '}',…
起因: 最近在练习解析验证码,看到了这个网站的验证码比较简单,于是就拿来解析一下攒攒经验值,并无任何冒犯之意... 验证码所在网页: https://www.w3cschool.cn/checkmphone?type=findpwd 验证码地址: https://www.w3cschool.cn/scode 1. 分析规律 打开这个页面: https://www.w3cschool.cn/scode,不断的按F5刷新观察,可以发现,虽然每次字符内容.位置会变化,但是字体的样式是一直不变的,对于这…
LeetCode:颜色分类[75] 题目描述 给定一个包含红色.白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色.白色.蓝色顺序排列. 此题中,我们使用整数 0. 1 和 2 分别表示红色.白色和蓝色. 注意:不能使用代码库中的排序函数来解决这道题. 示例: 输入: [2,0,2,1,1,0] 输出: [0,0,1,1,2,2] 进阶: 一个直观的解决方案是使用计数排序的两趟扫描算法.首先,迭代计算出0.1 和 2 元素的个数,然后按照0.1.2的排序,…
这是悦乐书的第361次更新,第388篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第223题(顺位题号是942).给定仅包含I(增加)或D(减少)的字符串S,令N = S.length. 返回元素值范围为[0,1,-,N]的整型数组A,使得对于所有i = 0,-,N-1: 如果S[i] =='I',那么A[i] < A[i + 1]. 如果S[i] =='D',那么A[i] > A[i + 1]. 例如: 输入:"IDID" 输出:[0,4,1…
leetcode - 39. Combination Sum - Medium descrition Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from…
终于刷完了leetcode的前250道题的easy篇.好吧,其实也就60多道题,但是其中的套路还是值得被记录的. 至于全部code,请移步github,题目大部分采用python3,小部分使用C,如有问题和建议,欢迎指正. String 有一个string库,可以返回各种string的汇总,很值得用. 当题目中需要实现字符串替代的时候,python中有一个自带的translate()函数可以实现这个功能,具体可见Python3字符串替换replace(),translate(),re.sub()…
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. Leetcode 65. 有效数字 Leetcode 65. Valid Number 在线提交: Leetcode https://leetcode.com/problems/valid-number/ 类似问题 - PAT 1014_牛客网 https://www.nowcoder.com/pat/6/pro…
索引:[LeetCode] Leetcode 题解索引 (C++/Java/Python/Sql) Github: https://github.com/illuz/leetcode 038. Count and Say (Easy) 链接: 题目:https://leetcode.com/problems/Count-and-Say/ 代码(github):https://github.com/illuz/leetcode 题意: 数数.第一个是 1,第二个是数前一个数:1 个 1,就是 11…
75. 颜色分类 75. Sort Colors 题目描述 给定一个包含红色.白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色.白色.蓝色顺序排列. 此题中,我们使用整数 0. 1 和 2 分别表示红色.白色和蓝色. 注意: 不能使用代码库中的排序函数来解决这道题. 每日一算法2019/6/2Day 30LeetCode75. Sort Colors 示例: 输入: [2,0,2,1,1,0] 输出: [0,0,1,1,2,2] 进阶: 一个直观的解决方…
leetcode - 48. Rotate Image - Medium descrition You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix direct…
leetcode - 35. Search Insert Position - Easy descrition Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the arr…
leetcode - 31. Next Permutation - Medium descrition Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible…
package y2019.Algorithm.LinkedList.medium; import y2019.Algorithm.LinkedList.ListNode; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.LinkedList.medium * @ClassName: AddTwoNumbers * @Author: xiaof * @Description: TODO 2. Add Two Numbers…
这几天一直再想这样刷题真的有必要么,这种单纯的刷题刷得到尽头么??? 这种出题的的题目是无限的随便百度,要多少题有多少题,那么我这一直刷的意义在哪里??? 最近一直苦苦思考,不明所以,刷题刷得更多的感受是机械化的操作. 抽空看了以前乔布斯的演讲有点感受,经过几天的思考最终我想通了. 这里刷题是对自己思考方式的提炼,这种题写多了对自己编码的思维方式有所提升这个是无形的. 其次我没必要去这么刷题,因为题目无限,时间有限,所以应该做的是去品味每一道题,思考如果以后遇到同类的题,我应该从一个什么样的角度…
第950题,这题我是真的没想到居然会说使用队列去做,大神的答案,拿过来瞻仰一下 package y2019.Algorithm.array; import java.util.HashMap; import java.util.Map; /** * @ClassName Exist * @Description TODO 79. Word Search * * Given a 2D board and a word, find if the word exists in the grid. *…
我被这些题整哭了,你呢??? 日了狗啊...... 好难啊.... 按照这个样子搞,不用找工作了,回家放牛去....... package y2019.Algorithm.divideandconquer.medium; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.divideandconquer.medium * @ClassName: FindKthLargest * @Author: xiaof * @Descr…
package y2019.Algorithm.array.medium; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array.medium * @ClassName: SortColors * @Author: xiaof * @Description: TODO 75. Sort Colors * Given an array with n objects colored red, white or blue,…
package y2019.Algorithm.array.medium; import java.util.Arrays; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array.medium * @ClassName: ProductExceptSelf * @Author: xiaof * @Description: TODo 238. Product of Array Except Self * Given a…
package y2019.Algorithm.array.medium; import java.util.ArrayList; import java.util.List; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array.medium * @ClassName: PancakeSort * @Author: xiaof * @Description: TODO 969. Pancake Sorting *…
package y2019.Algorithm.array.medium; /** * @ClassName UniquePathsWithObstacles * @Description TODO 63. Unique Paths II * * A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). * The robot can only move eit…
数组类,简单级别完结.... 不容易啊,基本都是靠百度答案.... 希望做过之后后面可以自己复习,自己学会这个解法 package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * @ClassName: CanPlaceFlowers * @Author: xiaof * @Description: TODO 605. Can Place Flowers * S…
真的感觉有点难... 这还是简单级别... 我也是醉了 package y2019.Algorithm.array; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * @ClassName: AddToArrayForm * @Author: xiao…
package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * @ClassName: IsOneBitCharacter * @Author: xiaof * @Description: TODO 717. 1-bit and 2-bit Characters * We have two special characters. The first charac…
package y2019.Algorithm.array; /** * @ClassName FindUnsortedSubarray * @Description TODO 581. Shortest Unsorted Continuous Subarray * * Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending…
package y2019.Algorithm.array; import java.util.HashSet; import java.util.Set; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * @ClassName: FairCandySwap * @Author: xiaof * @Description: TODO 888. Fair Candy Swap * * Alice and Bob…
package y2019.Algorithm.str.hard; import java.util.Stack; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.str.hard * @ClassName: LongestValidParentheses * @Author: xiaof * @Description: 32. Longest Valid Parentheses * * Given a string co…
package y2019.Algorithm.array.medium; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array.medium * @ClassName: Trap * @Author: xiaof * @Description: TODO 42. Trapping Rain Water * Given n non-negative integers representing an elevation…
package y2019.Algorithm.array.medium; import java.util.*; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array.medium * @ClassName: CombinationSum * @Author: xiaof * @Description: TODO 39. Combination Sum * Given a set of candidate numb…
package y2019.Algorithm.array.hard; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array.hard * @ClassName: MaximalRectangle * @Author: xiaof * @Description: TODO 85. Maximal Rectangle * Given a 2D binary matrix filled with 0's and 1's,…
package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * @ClassName: MatrixReshape * @Author: xiaof * @Description: TODO 566. Reshape the Matrix * * In MATLAB, there is a very useful function called 'reshape…