自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 问答 (1)
  • 收藏
  • 关注

原创 Leetcode Weekly Contest 191

1464.Maximum Product of Two Elements in an ArrayGiven the array of integersnums, you will choose two different indicesiandjof that array.Return the maximum value of(nums[i]-1)*(nums[j]-1).Example 1:Input: nums = [3,4,5,2]Output: 12 Explana...

2020-06-07 10:25:54 202

原创 剑指Offer Day5

Problem 1:输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。如果是则输出Yes,否则输出No。假设输入的数组的任意两个数字都互不相同。public class Solution { public boolean VerifySquenceOfBST(int [] sequence) { if(sequence.length == 0) ...

2020-05-30 08:56:41 101

原创 Leetcode Weekly Contest 190

1455.Check If a Word Occurs As a Prefix of Any Word in a SentenceGiven asentencethat consists of some words separated by asingle space, and asearchWord.You have to check ifsearchWordis a prefix of any word insentence.Returnthe index of the w...

2020-05-29 09:05:21 180

原创 Leetcode Dynamic Programming 动态规划(1)

746.Min Cost Climbing StairsOn a staircase, thei-th step has some non-negative costcost[i]assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find mi...

2020-04-13 12:27:02 119

原创 Leetcode Graph

1387.Sort Integers by The Power ValueThe power of an integerxis defined as the number of steps needed to transformxinto1using the following steps:ifxis even thenx = x / 2 ifxis odd th...

2020-03-31 12:41:11 142

原创 Leetcode Backtracking 回溯法

1079.Letter Tile PossibilitiesYou have a set oftiles, where each tile has one lettertiles[i]printed on it. Return the number of possible non-empty sequences of letters you can make.Example 1:...

2020-03-26 00:18:01 129

原创 Leetcode Recursion递归问题

938.Range Sum of BSTGiven therootnode of a binary search tree, return the sum of values of all nodes with value betweenLandR(inclusive).The binary search tree is guaranteed to have unique v...

2020-03-25 14:44:44 151

原创 剑指Offer Day10

问题一:请实现一个函数用来匹配包括'.'和'*'的正则表达式。模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配public class Solution { public boolean ...

2020-03-18 01:57:01 60

原创 剑指Offer Day9

问题一:孩子们的游戏 :每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此。HF作为牛客的资深元老,自然也准备了一些小游戏。其中,有个游戏是这样的:首先,让小朋友们围成一个大圈。然后,他随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m-1的那个小朋友要出列唱首歌,然后可以在礼品箱中任意的挑选礼物,并且不再回到圈中,从他的下一个小朋友开始,继续0...m-1报数...

2020-03-17 20:52:46 79

原创 剑指Offer Day08

Problem 1:小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100。但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数)。没多久,他就得到另一组连续正数和为100的序列:18,19,20,21,22。现在把问题交给你,你能不能也很快的找出所有和为S的连续正数序列? Good Luck!输出描述:输出所有和为...

2020-03-14 00:00:24 57

原创 剑指Offer Day7

Problem 1:题目描述在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。 即输出P%1000000007输入描述:题目保证输入的数组中没有的相同的数字数据范围:对于%50的数据,size<=10^4对于%75的数据,size<=10^...

2020-03-13 02:27:16 80

原创 剑指offer Day6

Problem 1:求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1、10、11、12、13因此共出现6次,但是对于后面问题他就没辙了。ACMer希望你们帮帮他,并把问题更加普遍化,可以很快的求出任意非负整数区间中1出现的次数(从1 到 n 中1出现的次数).Hint:The ones' number on un...

2020-03-10 20:52:31 71

原创 剑指offer Day5

Problem 1:题目描述输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。输入描述:输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。1. Recursion(166ms)func(a,b,c)=a(func(b,c))+ e...

2020-03-09 23:47:15 90

原创 Reading notes : java.util.Collection

statement !!! all the contents below excerpt from "Introduction to Java Programming, Comprehensive Version 10th edition"The Java Collections FrameworkCollection Interface methodimport j...

2020-03-07 15:20:11 285

原创 剑指Offer Day4

Problem 1:操作给定的二叉树,将其变换为源二叉树的镜像.输入描述:二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ 11 9...

2020-03-05 11:30:30 171

原创 剑指练习Day3

Problem 1:输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。public class Solution { public void reOrderArray(int [] array){ int len = array.length; ...

2020-03-04 00:35:44 77

原创 Fibonacci Problems

Problem1:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。import java.util.ArrayList;public class Solution ...

2020-03-02 21:31:31 134

原创 search Array

Problem 1: 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。1. Search target from the bottom-left elements of array (same as from top-right elements)...

2020-03-02 01:56:33 135

转载 the differences between the Heap memory and the String Constant Pool

Heap MemoryThe heap memory is a run time data area from which the memory for all java class instances and arrays is allocated. The heap is created when the JVM starts up and may increase or decreas...

2020-02-29 21:17:33 84

原创 Rounding methods( Math.ceil(), Math.floor(x), Math.rint(x), Math.round() ) in the Math Class

Rounding methodsThe java.lang.Math.ceil(double a) returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical inte...

2020-02-29 21:13:00 94

原创 String, StringBuffer, StringBuilder

Package java.lang.*StringTheStringclass represents character strings. All string literals in Java programs, such as"abc", are implemented as instances of this class.Strings are constant; ...

2020-02-29 19:54:40 112

原创 leetcode Array problems 561,1351,1010,1018

561. Array Partition IGiven an array of2nintegers, your task is to group these integers intonpairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from...

2020-02-19 00:31:00 97

原创 leetcode Array problem 905, 977, 830

905. Sort Array By ParityGiven an arrayAof non-negative integers, return an array consisting of all the even elements ofA, followed by all the odd elements ofA.You may return any answer array ...

2020-02-16 20:52:54 103

原创 leetcode array problems 1252, 1304, 121

1252. Cells with Odd Values in a MatrixGivennandmwhich are the dimensions of a matrix initialized by zeros and given an arrayindiceswhereindices[i] = [ri, ci]. For each pair of[ri, ci]you h...

2020-02-14 23:57:23 183

原创 solutions&reflection Array problems 1313, 1266, 118

1313. Decompress Run-Length Encoded ListDescription:We are given a listnumsof integers representing a list compressed with run-length encoding.Consider each adjacent pairof elements[a, b] = ...

2020-02-13 16:51:55 131

转载 01背包问题

问题假定背包的最大容量为W,N件物品,每件物品都有自己的价值vi和重量wi,将物品放入背包中使得背包内物品的总价值value最大。背包问题wiki可以想象这样一个场景——小偷在屋子里偷东西,他带着一只背包。屋子里物品数量有限——每件物品都具有一定的重量和价值——珠宝重量轻但价值高,桌子重但价值低。最重要的是小偷背包容量有限。很明显,他不能把桌子分成两份或者带走珠宝的3/4。对于一件物品...

2018-09-09 16:15:04 292

转载 HDU2050---折线分割平面

折线分割平面Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25016    Accepted Submission(s): 17000Problem Description我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们...

2018-04-24 07:27:38 424

原创 HDU---2084树塔

问题分析:    1.数据存储:二维数组data[maxn][maxn]存储树塔数据,dp[maxn][maxn]用来存储从某点出发的各个路径中的最优值    2.分析思路:树塔树塔问题自顶向下分析,自底向上计算。首先对倒数第二层的数据按照自顶向下的分析方法,两两结合选出最优解,然后再自顶向上逐层决策,然后逐层递推求出最终结果。    得出动态方程:dp[i][j] = max(dp[i+1][j...

2018-04-23 23:48:01 339

原创 HDU2044----一只小蜜蜂

Problem Description有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。其中,蜂房的结构如下所示。Input输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0&lt;a&lt;b&lt;50)。Output对于每个测试实例,请输出蜜蜂从蜂房a爬到蜂房b的可能路线数,每个实例的输出占一行...

2018-04-20 16:32:14 200

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除