LeetCode的第一题,英文单词书中 Abandon 一般的存在,让我们来看一下题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. ...
分类:
编程语言 时间:
2020-05-31 11:10:15
阅读次数:
107
二叉搜索树 定义 二叉查找树(英语:Binary Search Tree),也称为二叉搜索树、有序二叉树(ordered binary tree)或排序二叉树(sorted binary tree),是指一棵空树或者具有下列性质的二叉树: 若任意节点的左子树不空,则左子树上所有节点的值均小于它的根节 ...
分类:
其他好文 时间:
2020-05-31 00:56:13
阅读次数:
52
这个异常遇到了才知道坑这么大,坑爹的方法。 private String[] otherUserFromArray = new String[]{“3”, “4”, “发放”}; List<String> userFromList = Arrays.asList(otherUserFromArray ...
分类:
编程语言 时间:
2020-05-30 09:12:01
阅读次数:
72
不断更新值和进位。 class Solution { public: int getSum(int a, int b) { return b == 0 ? a : getSum(a ^ b, ((unsigned int)a & b) << 1); } }; ...
分类:
其他好文 时间:
2020-05-30 01:24:53
阅读次数:
70
进阶解法1:排序双指针 class Solution { public: vector<int> intersect(vector<int>& nums1, vector<int>& nums2) { sort(nums1.begin(), nums1.end()); sort(nums2.begi ...
分类:
编程语言 时间:
2020-05-30 01:20:17
阅读次数:
70
A - Sorted Adjacent Differences 题意:给出一个长度为n的序列,要求将序列排序,使每两个数之差的绝对值按升序排列 做法:思维题,先sort排序,从中间开始取,往两边推,各取一个,排出来自然满足条件 代码: //去吧马里奥!把AC公主救回来! // ******** // ...
分类:
其他好文 时间:
2020-05-29 23:14:23
阅读次数:
70
A - Sorted Adjacent Differences 将这串数字按大小排序,找到中间那个做第一个,左一个右一个输出 int main() { int k,n,i,j,a[100010]; cin>>k; while(k--){ cin>>n; for(i=0;i<n;i++){ cin>> ...
分类:
其他好文 时间:
2020-05-29 22:56:58
阅读次数:
57
A - Sorted Adjacent Differences 题意:给定数组,对其排序,使其满足|a1?a2|≤|a2?a3|≤…≤|an?1?an|. 解题思路:先对数组进行排序,由最大值与最小值之差最大,次大值与次小值之差第二大,依次类推,将数组从中间开始输出. ac代码: #include< ...
分类:
其他好文 时间:
2020-05-29 21:21:37
阅读次数:
57
题目描述 leetcode - 2:https://leetcode-cn.com/problems/add-two-numbers/ 解题关键 C++ 链表 数据结构的定义和遍历 代码 /** * Definition for singly-linked list. * struct ListNo ...
分类:
其他好文 时间:
2020-05-29 09:15:52
阅读次数:
73
1.编写一个随机生成 10个 0(包括) 到 100 之间的随机正整数。 package work; import java.util.Arrays; import java.util.Random; import java.util.Scanner; public class one { publ ...
分类:
其他好文 时间:
2020-05-28 13:49:55
阅读次数:
51