
leetcode
weixin_36514613
这个作者很懒,什么都没留下…
展开
-
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 · 98 阅读 · 0 评论 -
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 · 117 阅读 · 0 评论 -
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 · 114 阅读 · 0 评论 -
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 · 109 阅读 · 0 评论 -
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 · 120 阅读 · 0 评论 -
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 · 87 阅读 · 0 评论 -
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 · 83 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 85 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 80 阅读 · 0 评论 -
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 · 78 阅读 · 0 评论 -
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 · 78 阅读 · 0 评论 -
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 · 83 阅读 · 0 评论 -
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 · 92 阅读 · 0 评论 -
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 · 77 阅读 · 0 评论 -
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 · 112 阅读 · 0 评论 -
java day03
其实只是一些个人的学习笔记。。。重载只与函数的参数个数和参数类型有关(参数是有顺序的),函数可以同名什么时候用定义的功能相同,但参与运算的未知内容不同内存结构栈内存:数据使用完毕,会自动释放堆内存:垃圾回收机制,数组用到数组定义:用一种类型数据的集合格式:元素类型[] 数组名=new 元素类型[元素个数或数组长度]数组是引用类型(基本/引用)int[] x=new...原创 2019-05-04 21:28:57 · 84 阅读 · 0 评论 -
leetcode 88. Merge Sorted Array
88. Merge Sorted Array只是记录做题过程和总结一下经验题目Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are...原创 2019-04-30 18:38:14 · 99 阅读 · 0 评论 -
196. Delete Duplicate Emails
196. Delete Duplicate EmailsWrite a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.±—±-----------------+| Id | Email ...原创 2019-04-30 21:25:57 · 240 阅读 · 0 评论 -
197. Rising Temperature
题目Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates.±--------±-----------------±-----------------+| Id(INT) | Re...原创 2019-04-30 21:39:19 · 86 阅读 · 0 评论 -
day07
继承1.extends:java只支持单继承,不支持多继承java支持多层继承谁是谁的一种2.this代表本类对象的引用,super代表父类对象的引用聚集聚集:has a聚合:覆盖(重写)当子类出现和父类一模一样的函数时,当子类对象调用该函数,会运行子类函数的内容,如同父类的函数被覆盖一样。可以利用覆写提高程序的扩展性注意:1.子类覆盖父类,必须保证子类权限大于等于父类权...原创 2019-05-09 02:17:45 · 97 阅读 · 0 评论 -
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 · 141 阅读 · 0 评论 -
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 · 65 阅读 · 0 评论 -
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 · 84 阅读 · 0 评论 -
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 · 87 阅读 · 0 评论 -
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 · 68 阅读 · 0 评论 -
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 · 79 阅读 · 0 评论 -
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 · 90 阅读 · 0 评论 -
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 · 91 阅读 · 0 评论 -
118. Pascal's Triangle
题目Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:...原创 2019-05-02 18:20:18 · 75 阅读 · 0 评论