1 class Solution { 2 public int minArray(int[] numbers) { 3 int left = 0, right = numbers.length - 1; 4 while(left < right){ 5 int mid = (right - left ...
分类:
其他好文 时间:
2020-07-23 01:45:19
阅读次数:
72
##题面 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的: F(1)=1; F(2)=2; F(n)=F(n-1)+F(n-2)(n>=3); 所以,1,2,3,5,8,13……就是菲波那契数列。 在HDOJ上 ...
分类:
其他好文 时间:
2020-07-22 15:43:22
阅读次数:
61
可以想到,数组中会出现“断层”,直接遍历一次即可。不存在【1,2,3,4,5】旋转成【5,4,3,2,1】的情况。 暴力法(我感觉还行啊,为什么被叫暴力): class Solution { public int minArray(int[] numbers) { int n = numbers.l ...
分类:
编程语言 时间:
2020-07-22 11:13:53
阅读次数:
50
原作者:CodingCode 原链接:https://www.jianshu.com/p/ff1877c5864e git merge的三种操作merge, squash merge, 和rebase merge 举例来说: 假设在master分支的B点拉出一个新的分支dev,经过一段时间开发后: ...
分类:
其他好文 时间:
2020-07-21 22:33:40
阅读次数:
71
在转换的字符串中,存在null时,就会出现NameError: name ‘null’ is not defined这个错误。 解决办法:使用replace方法将null替换掉 注意:replace argument 2 must be str replace的两个参数都必须为字符串 str.rep ...
分类:
其他好文 时间:
2020-07-21 13:58:35
阅读次数:
67
from typing import List# 这道题很容易能够想到,只需要遍历两边列表就可以了# 两层循环class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: # 第一次遍历列表 for i ...
分类:
编程语言 时间:
2020-07-21 01:14:53
阅读次数:
97
\(DP\) 没有长度为奇数的回文串,必定满足没有长度为$3$的回文串 我们要避免$x,y,x$的情况 即$a[i]≠a[i+2]$ 根据这一规律,我们把序列拆成下标分别为奇数和偶数的两个序列分别处理 可以发现,一段$-1$的区间的可能性只与其两端的数是否相等有关,故可以预处理出$dp$数组。 $d ...
分类:
其他好文 时间:
2020-07-20 20:33:56
阅读次数:
84
题目要求 算法分析 可以用双指针法, 分别指向头尾元素,如果两元素的和大于目标,尾指针前移,如果小于目标,头指针后移,等于目标即可得答案 代码展示(C#) public class Solution { public int[] TwoSum(int[] numbers, int target) { ...
分类:
编程语言 时间:
2020-07-20 10:40:01
阅读次数:
55
package LeetCode_1060 /** * 1060. Missing Element in Sorted Array * (Prime) * Given a sorted array A of unique numbers, find the K-th missing number s ...
分类:
其他好文 时间:
2020-07-19 00:49:27
阅读次数:
93
#include<iostream> #include<algorithm> #include<cstdio> using namespace std; bool cmp(int a,int b){ return a>b; } void to_array(int n,int num []) { fo ...
分类:
其他好文 时间:
2020-07-18 11:39:12
阅读次数:
78