- 博客(47)
- 收藏
- 关注
原创 15. 3Sum
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not contai...
2019-12-26 08:34:50
94
原创 350. Intersection of Two Arrays II
350. Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output: [2,2]Example 2:Input: nums1 = [4,9,...
2019-12-25 09:20:05
116
原创 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output: [2]Example 2:Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]Output: [9,4]...
2019-12-25 08:04:20
109
原创 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Input: “hello”Output: “holle”Example 2:Input: “leetcode”Output: “leotcede”Note:The vowels do...
2019-12-24 20:59:59
104
原创 80. Remove Duplicates from Sorted Array II
80. Remove Duplicates from Sorted Array IIGiven a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.Do not allocate extra space ...
2019-12-24 09:44:22
117
原创 287. Find the Duplicate Number
287. Find the Duplicate NumberGiven an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there i...
2019-09-18 07:03:50
82
原创 209. Minimum Size Subarray Sum
209. Minimum Size Subarray SumGiven an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 inste...
2019-09-18 03:38:45
75
原创 75. Sort Colors
75. Sort ColorsGiven an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we ...
2019-09-16 18:47:43
76
原创 3. Longest Substring Without Repeating Characters
3. Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer...
2019-09-16 09:29:17
76
原创 100. Same Tree
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1:...
2019-08-10 16:39:43
81
原创 202. Happy Number
202. Happy NumberWrite an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum...
2019-08-10 14:26:18
83
原创 38. Count and Say
38. Count and SayThe count-and-say sequence is the sequence of integers with the first five terms as following:1112112111112211 is read off as “one 1” or 11.11 is read off as ...
2019-08-03 20:09:59
85
原创 283. Move Zeroes
283. Move ZeroesGiven an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0...
2019-08-03 00:32:57
75
原创 746. Min Cost Climbing Stairs
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of t...
2019-07-26 14:14:39
80
原创 303. Range Sum Query - Immutable
303. Range Sum Query - ImmutableGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) ->...
2019-07-25 16:08:49
111
原创 198. House Robber
198. House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is t...
2019-07-25 15:00:45
88
原创 268. Missing Number
268. Missing NumberGiven an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.Example 1:Input: [3,0,1]Output: 2Example 2:Input: [9,6,4,...
2019-07-24 19:00:07
88
原创 219. Contains Duplicate II
219. Contains Duplicate IIGiven an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference bet...
2019-07-23 11:25:09
77
原创 217. Contains Duplicate
217. Contains DuplicateGiven an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return f...
2019-07-22 00:54:28
91
原创 70. Climbing Stairs
70. Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given ...
2019-07-15 17:34:05
76
转载 mysql多表
今日内容1. 多表查询2. 事务3. DCL多表查询:* 查询语法: select 列名列表 from 表名列表 where....* 准备sql # 创建部门表 CREATE TABLE dept( id INT PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(20) ); INSERT INTO dept (NA...
2019-06-01 00:48:07
138
转载 MYSQL约束
今日内容1. DQL:查询语句 1. 排序查询 2. 聚合函数 3. 分组查询 4. 分页查询2. 约束3. 多表之间的关系4. 范式5. 数据库的备份和还原DQL:查询语句1. 排序查询 * 语法:order by 子句 * order by 排序字段1 排序方式1 , 排序字段2 排序方式2... * 排序方式: * ASC:升序,默认的。 * D...
2019-05-31 23:58:11
324
转载 mysql基础
今日内容数据库的基本概念MySQL数据库软件安装卸载配置SQL数据库的基本概念1. 数据库的英文单词: DataBase 简称 : DB2. 什么数据库? * 用于存储和管理数据的仓库。3. 数据库的特点: 1. 持久化存储数据的。其实数据库就是一个文件系统 2. 方便存储和管理数据 3. 使用了统一的方式操作数据库 -- SQL4. 常见的...
2019-05-31 02:52:20
57
翻译 169. Majority Element
169. Majority ElementGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the ...
2019-05-29 01:58:08
66
原创 jdbc
一。概念JDBC:定义了操作所有关系型数据库的规则(接口)官方定义的一套操作所有关系型数据库的规则。各个数据库厂商去实现这套接口,提供数据库驱动jar包,真正执行的代码是驱动jar包中的实现类二。步骤1.导入驱动jar包2.注册驱动3.获取数据库连接对象connection4.定义sql5.获取执行sql语句对象statement6.执行sql,接受返回结果7.处理结果8.释...
2019-05-29 01:43:50
80
翻译 javaday17
collection类正向排序sort()使用 Collections 类的静态方法 sort() 可以对集合中的元素进行升序排序。这要求列表中的所有元素都必须实现 Comparable 接口,而且所有元素都必须是使用指定比较器可相互比较的。sort() 方法主要有如下两种重载形式。void sort(List list):根据元素的自然顺序对集合中的元素进行升序排序。void sor...
2019-05-27 02:43:51
199
原创 java day16
map该集合存储键值对,一对一对往里面存,而且要保证键的唯一性添加put(K key,V value)putAll(Map<? extends K, extends V>m)删除clear()判断containsValue(Object value)containsKey(Object key)isEmpty()获取get(Object key)size()...
2019-05-26 00:36:15
84
原创 167. Two Sum II - Input array is sorted
题目Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two number...
2019-05-20 02:33:50
64
原创 java day15
treeset可以对set集合中元素进行排序底层数据结构是二叉树保证元素唯一性的依据是compareTo方法return 0自然顺序让元素自身具备比较型,元素需要实现comparable接口,覆盖compareto方法,这种方式也称为元素的自然顺序第二种排序方式当元素自身不具备比较性时,或者具备的比较性不是所需要的,这时就需要让集合自身具备比较性。在集合初始化时就有了比较方式...
2019-05-19 18:54:32
71
原创 javaday14
为什么出现集合类用于存储对象长度可变可以存储不同类型的对象list:元素是有序的,元素可以重复,因为该集合体系有索引set:元素是无序的,元素不可以重复listsetarraylisthashsetlinkedlisttreesetvector共性方法1.add方法的参数类型是object,以便于接收任意类型的对象2.集合中存储的是对象的...
2019-05-18 17:35:03
78
原创 java day13
String字符串最大的特点是,一旦初始化就不可能被改变String s1="abc";//s1是个类类型变量,“abc"是一个对象String s2=new String("abc");s1和s2有什么区别?s1在内存中有一个对象,s2在内存中有2个对象System.out.println(s1==s2);//falseSystem.out.println(s1.equals(s...
2019-05-17 21:07:51
78
原创 java day11
进程和线程进程:是一个正在执行中的程序,每一个进程执行都有一个执行顺序,该顺序是一个执行路径,或者叫一个控制单元。线程:就是进程中一个独立的控制单元,线程在控制着进程的执行。一个进程中至少有一个线程。JAVA VM启动的时候会有一个进程java.exe该进程中至少有一个线程负责java程序的执行而且这个线程运行的代码存在于main方法中,该线程称之为主线程。扩展:其实更细节说明jvm...
2019-05-13 02:43:58
106
原创 java day10
异常在子父类覆盖中的体现1.子类在覆盖父类时,如果父类的方法抛出异常,那么子类的覆盖方法,只能抛出父类的异常或者该异常的子类。2.如果父类方法抛出多个异常,那么子类在覆盖该方法时,只能抛出父类异常的子集3.如果父类或者接口的方法中没有异常抛出,那么子类在覆盖方法时也不可以抛出异常,如果子类方法发生了异常,一必须要进行try处理,绝对不能抛。异常总结异常体系的特点异常体系中的所有类以及建...
2019-05-12 15:39:11
102
原创 java day09
内部类的访问规则1.内部类可以直接访问外部类中的成员,包括私有格式:外部类名.this2.外部类要访问内部类,必须要建立内部类对象访问格式Outer.inner in =new outer().new inner();3.当内部类在成员位置上,就可以被成员修饰符所修饰当内部类被static修饰后,只能访问外部类中的static成员,出现了访问局限。在外部其他类中,如何直接访问sta...
2019-05-10 16:19:36
69
翻译 122. Best Time to Buy and Sell Stock II
依旧是自己的做题记录和总结题目Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you li...
2019-05-10 02:09:06
134
原创 day08
多态多态的体现父类的引用指向了自己的子类对象父类的引用也可以接收自己的子类对象多态的前提必须是类与类之间有关系,要么继承,要么实现通常还有一个前提,存在覆盖多态的好处提高了程序的可扩展性多态的弊端提高了扩展性,但是只能使用父类的引用访问父类中的成员。多态的转型向上转型:animal a = new cat();a.eat();向下转型:想要调用猫特有的方法cat ...
2019-05-09 21:25:46
83
原创 day07
继承1.extends:java只支持单继承,不支持多继承java支持多层继承谁是谁的一种2.this代表本类对象的引用,super代表父类对象的引用聚集聚集:has a聚合:覆盖(重写)当子类出现和父类一模一样的函数时,当子类对象调用该函数,会运行子类函数的内容,如同父类的函数被覆盖一样。可以利用覆写提高程序的扩展性注意:1.子类覆盖父类,必须保证子类权限大于等于父类权...
2019-05-09 02:17:45
96
原创 java 设计模式
定义:解决一类问题最行之有效的方法,java中有23中设计模式单例设计模式解决一个类在内存中只存在一个对象。想要保证对象唯一:1.为了避免其他程序过多建立该类对象,先禁止其他程序建立该类对象(将构造函数私有化)2.还为了让其他程序可以访问到该类对象,只好在本类中,自定义一个对象。(在类中创建一个本类对象)3.为了方便其他程序对自定义对象的访问,可以对外提供一些访问方式。(提供一个方法可...
2019-05-08 16:32:15
68
原创 java day06
1.javadoc类必须是public才能生成命令:javadoc -d 文件夹名 -author -version 代码名.java2.静态代码块随着类的加载而执行,只执行一次用于给类进行初始化3.Person p=new Person(“zhangsan”,20);都做了什么事1.因为new用到了person.class,所以会先找到Person.class文件并加载到内存中。...
2019-05-08 00:05:53
80
原创 java day03
其实只是一些个人的学习笔记。。。重载只与函数的参数个数和参数类型有关(参数是有顺序的),函数可以同名什么时候用定义的功能相同,但参与运算的未知内容不同内存结构栈内存:数据使用完毕,会自动释放堆内存:垃圾回收机制,数组用到数组定义:用一种类型数据的集合格式:元素类型[] 数组名=new 元素类型[元素个数或数组长度]数组是引用类型(基本/引用)int[] x=new...
2019-05-04 21:28:57
83
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人