本题 题目链接 题目描述 我的题解 双指针 思路分析 因为该数组是递增数组,所以我们可以用双指针法。 声明指针left 和 right分别指向数组的头(数组下标为0)和尾(数组下标为length-1) 循环搜索:当两指针相遇时,结束循环 计算nums[left]和nums[right]的和 s 若s ...
分类:
其他好文 时间:
2020-07-28 14:05:28
阅读次数:
70
1.list和str类型相互转化nums=[‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘,‘7‘]str_nums="".join(nums)print(type(str_nums))print(str_nums)需要注意的是,该方法需要list中的元素为字符型,若是(数字),则不能使用如上的方法,会产生相应的错误:nums=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,1
分类:
编程语言 时间:
2020-07-27 10:03:10
阅读次数:
98
Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square? InputThe first line of input contains N, the number ...
分类:
其他好文 时间:
2020-07-27 09:42:59
阅读次数:
80
其实join函数就是字符串的函数,参数和插入的都要是字符串 所以:将s = '_'.join(args)变成s = '_'.join(str(args).strip()) ...
分类:
编程语言 时间:
2020-07-26 22:53:44
阅读次数:
72
如果需要对关联查询(inner join)做分组(group by),并且按照关联表(actor)中的某个列进行分组,那么通常采用关联表(actor)的标识列(actor_id)分组的效率比其他列更高: select actor.first_name,actor.last_name,count(*) ...
分类:
数据库 时间:
2020-07-26 19:33:13
阅读次数:
88
链接:https://leetcode-cn.com/problems/path-sum/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
分类:
其他好文 时间:
2020-07-26 19:00:19
阅读次数:
52
题目:传送门 方法一、递归 中序遍历:先遍历左子树,在遍历根节点,最后遍历右子树。比较经典的方法是递归。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeN ...
分类:
其他好文 时间:
2020-07-26 15:32:51
阅读次数:
67
快速排序的核心是先找到一个比较的基数,然后从左往右寻找比基数大的值,从右往左找到比基数小的值,最后交换数据 public static void quickSort(int left,int right,int[]arr){ // 获取最左边的索引和最右边的索引 int l=left; int r= ...
分类:
编程语言 时间:
2020-07-26 11:17:03
阅读次数:
91
#include <stdio.h> #include <graphics.h> #include <stdlib.h> #include <dos.h> /*引用的库函数*/ #define LEFT 0x4b00 #define RIGHT 0x4d00 #define DOWN 0x5000 ...
分类:
编程语言 时间:
2020-07-26 02:05:25
阅读次数:
127
test-align 设置元素内文本的对齐方式,该属性对块级元素设置有效 语法(justify 两端对齐) text-align: left right center justify ...
分类:
其他好文 时间:
2020-07-26 01:56:41
阅读次数:
62