element

剑指offer——栈与队列相关 Queue,Deque,Stack

不想你离开。 提交于 2020-05-04 05:15:25
剑指offer——栈的压入、弹出序列 剑指offer——用两个栈来实现队列 剑指offer——调整数组顺序使奇数位于偶数前面 使用队列时注意: 判断是否为空(获取但不删除) queue.peek() == null 区别于queue.element()为空时抛异常 添加元素: queue.offer() 满了时 返回false,而add()满了时,会报错 弹出元素: queue.poll() 为空时 返回null, 而remove()满了时,会抛异常 而且要注意:Queue是一个接口,不能直接使用它,而需要使用实现了它的类 参考: Java 集合深入理解(9):Queue 队列 Deque双端队列: Deque 是 Double ended queue (双端队列) 的缩写,读音和 deck 一样,蛋壳。 Deque 继承自 Queue ,直接实现了它的有 LinkedList, ArayDeque, ConcurrentLinkedDeque 等。 Deque 支持容量受限的双端队列,也支持大小不固定的。一般双端队列大小不确定。 Deque 接口定义了一些从头部和尾部访问元素的方法。比如分别在头部、尾部进行插入、删除、获取元素。和 Queue 类似,每个操作都有两种方法,一种在异常情况下直接抛出异常奔溃,另一种则不会抛异常,而是返回特殊的值,比如 false, null … 参考

算法与数据结构基础

帅比萌擦擦* 提交于 2020-05-04 04:55:50
Binary Search基础 应用于已排序的数据查找其中特定值,是折半查找最常的应用场景。相比线性查找(Linear Search),其时间复杂度减少到O(lgn)。算法基本框架如下: //704. Binary Search int search(vector< int >& nums, int target) { //nums为已排序数组 int i= 0 ,j=nums.size()- 1 ; while (i<= j){ int mid=(i+j)/ 2 ; if (nums[mid]==target) return mid; else if (nums[mid]>target) j=mid- 1 ; else i=mid+ 1 ; } return - 1 ; } 以上查找范围的上下限 i 和 j 代表 索引 ,算法过程可视化: Binary Search ,STL中有序区间函数upper_bound/lower_bound内用的查找方法即是折半查找。 相关LeetCode题: 704. Binary Search 题解 34. Find First and Last Position of Element in Sorted Array 题解 33. Search in Rotated Sorted Array 题解 528. Random Pick with

对spring的IOC和aop的学习总结

生来就可爱ヽ(ⅴ<●) 提交于 2020-05-04 04:50:23
Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。特点是面向接口编程,松耦合。 1:IOC(控制反转) 别名(DI:依赖注入) 首先来一段ioc的实现原来代码: 1 public class ClassPathXmlApplicationContext implements BeanFactory { 2 3 private Map<String , Object> beans = new HashMap<String, Object> (); 4 5 // IOC Inverse of Control DI Dependency Injection 6 public ClassPathXmlApplicationContext() throws Exception { 7 SAXBuilder sb= new SAXBuilder(); 8 // 解析xml配置文件 9 Document doc=sb.build( this .getClass().getClassLoader().getResourceAsStream("beans.xml" )); 10 Element root=doc.getRootElement(); // 获取根元素 11 List list=root.getChildren("bean"); // 根元素下的子元素 12

ZOJ 4124 2019 ACM山东省赛 L题

倾然丶 夕夏残阳落幕 提交于 2020-05-04 04:43:10
Median Time Limit: 1 Second Memory Limit: 65536 KB Recall the definition of the median of elements where is odd: sort these elements and the median is the -th largest element. In this problem, the exact value of each element is not given, but relations between some pair of elements are given. The -th relation can be described as , which indicates that the -th element is strictly larger than the -th element. For all , is it possible to assign values to each element so that all the relations are satisfied and the -th element is the median of the elements? Input There are multiple test cases. The

【433】COMP9024 复习

↘锁芯ラ 提交于 2020-05-04 03:34:04
目录: 01. Week01 - Lec02 - Revision and setting the scene 02. Week02 - Lec01 - Data structures - memory allocation 03. Week02 - Lec02 - Input - Output 04. Week03 - Lec01 - ADTs 05. Week03 - Lec02 - Dynamic memory allocation 06. Week04 - Lec01 - LinkedLists 07. Week06 - Lec01 - Heaps 08. Week06 - Lec02 - Priority Queues and Heap Sort 09. Week07 - Lec01 - Graphs 10. Week07 - Lec02 - Graph search 11. Week08 - Lec02 - Applications of Graph Search 12. Week09 - Lec01 - Weighted Graph Algorithms 13. Week09 - Lec02 - Binary Search Trees 14. Week10 - Lec01 - Splay Trees 01. Week01 - Lec02 - Revision and

[LeetCode] 891. Sum of Subsequence Widths 子序列宽度之和

[亡魂溺海] 提交于 2020-05-04 03:24:02
<br> Given an array of integers `A`, consider all non-empty subsequences of `A`. For any sequence S, let the width of S be the difference between the maximum and minimum element of S. Return the sum of the widths of all subsequences of A. As the answer may be very large, return the answer modulo 10^9 + 7. Example 1: Input: [2,1,3] Output: 6 Explanation: Subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3]. The corresponding widths are 0, 0, 0, 1, 1, 2, 2. The sum of these widths is 6. Note: 1 <= A.length <= 20000 1 <= A[i] <= 20000 <br> 这道题给了我们一个数组,并且定义了一种子序列的宽度,就是非空子序列中最大值和最小值的差值

Leetcode 446.等差数列划分II 子序列

喜你入骨 提交于 2020-05-04 03:23:46
等差数列划分II 子序列 如果一个数列至少有三个元素,并且任意两个相邻元素之差相同,则称该数列为等差数列。 例如,以下数列为等差数列: 1, 3, 5, 7, 9 7, 7, 7, 7 3, -1, -5, -9 以下数列不是等差数列。 1, 1, 2, 5, 7 数组 A 包含 N 个数,且索引从 0 开始。该数组 子序列 将划分为整数序列 (P 0 , P 1 , ..., P k ),P 与 Q 是整数且满足 0 ≤ P 0 < P 1 < ... < P k < N。 如果序列 A[P 0 ],A[P 1 ],...,A[P k-1 ],A[P k ] 是等差的,那么数组 A 的 子序列 (P0,P1,…,PK) 称为等差序列。值得注意的是,这意味着 k ≥ 2。 函数要返回数组 A 中所有等差子序列的个数。 输入包含 N 个整数。每个整数都在 -2 31 和 2 31 -1 之间,另外 0 ≤ N ≤ 1000。保证输出小于 2 31 -1。 示例: 输入: [2, 4, 6, 8, 10] 输出: 7 解释: 所有的等差子序列为: [2,4,6] [4,6,8] [6,8,10] [2,4,6,8] [4,6,8,10] [2,4,6,8,10] [2,6,10] Dynamic Programming [Accepted] Intuition To determine

jqgrid 单元格引入时间datepicker控件

南笙酒味 提交于 2020-05-04 02:02:01
简述原理:引入jquery-ui插件,设置好表格所需的字段变量以及字段属性 1、设置colName与colModel   colNames: ['过期时间'']   colModel:[{   name:'expiration',    index:'date',   width:90,    align:"center",   editable:true,    edittype:'text',    editrules:{required:true},   editoptions: {    size:10,    maxlengh:10,   dataInit:function(element){  $(element).datepicker({   closeText: '关闭',   prevText: '<上月',   nextText: '下月>',   currentText: '今天',   monthNames: ['一月','二月','三月','四月','五月','六月',   '七月','八月','九月','十月','十一月','十二月'],   dayNamesMin: ['日','一','二','三','四','五','六'],    weekHeader: '周',   dateFormat: 'yy-mm-dd',   firstDay: 1,  

强制等待&隐士等待&显示等待&元素定位方法封装

孤街醉人 提交于 2020-05-03 23:58:51
前言 问题 学习selenium的同学估计大多数都遇见过一个问题 明明页面已经精准的定位到了元素,但是执行脚本的时候却经常报错没找到元素。其实原因很简单,就是脚本执行的速度很快,而浏览器加载页面的时候由于网速,css渲染,JS等各种原因导致页面加载缓慢,所以当脚本执行到定位一个元素的代码时,页面还未加载出这个元素,进而导致代码报错。那么有没有办法解决这种问题呢?of course,如果解决不了还叫自动化嘛 我们先看下面的一个用例(百度首页输入“linux超”关键词,点击“百度一下”, 在搜索结果中找到我的博客地址并点击进入我的博客)我们不使用任何等待方法 """ ------------------------------------ @Time : 2019/7/4 12:34 @Auth : linux超 @File : nowait.py @IDE : PyCharm @Motto: Real warriors,dare to face the bleak warning,dare to face the incisive error! @QQ : 28174043@qq.com @GROUP: 878565760 ------------------------------------ """ import time from selenium import

阅读java.util.concurrent.PriorityBlockingQueue源码Note

前提是你 提交于 2020-05-03 23:34:25
java.util.concurrent.BlockingQueue 在Queue的基础增加额外的功能:遍历队列时,若无元素则阻塞等待;插入元素时,无额外的空间则等待空间释放。 其方法可分为四种形式:根据对相同操作(对操作不能立即满足)的不同处理结果来分为以下四种 抛出异常 返回特定值,不同的方法返回的值不同 阻塞,直到条件满足 阻塞一段时间,而后再放弃 Summary of BlockingQueue methods Throws exception Special value Blocks Times out Insert { @link #add add(e)} { @link #offer offer(e)} { @link #put put(e)} { @link #offer(Object, long, TimeUnit) offer(e, time, unit)} Remove { @link #remove remove()} {@link #poll poll()} {@link #take take()} {@link #poll(long, TimeUnit) poll(time, unit)} Examine {@link #element element()} {@link #peek peek()} not applicable not