自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(39)
  • 收藏
  • 关注

转载 Intro to Dynamic Programming 动态规划专题 [1]

1 动态规划简介动态规划在查找有很多重叠子问题的情况的最优解时有效。它将问题重新组合成子问题。为了避免多次解决这些子问题,它们的结果都逐渐被计算并被保存,从简单的问题直到整个问题都被解决。因此,动态规划保存递归时的结果,因而不会在解决同样的问题时花费时间。动态规划只能应用于有最优子结构的问题。最优子结构的意思是局部最优解能决定全局最优解(对有些问题这个要求并不能完全满足,故有时需要引入一定的近...

2019-08-28 00:59:56 219

转载 Java Map/Collections 的使用场景

原文链接:http://www.sergiy.ca/guide-to-selecting-appropriate-map-collection-in-java

2019-08-26 10:35:37 252

转载 Generics in Java, Java generics 的使用

Generics in Java, Java generics 的使用1 Introduction to genericsGenerics are a way to tell a compiler what type of object a collection can contain. The idea is to allow type (Integer, String, … etc an...

2019-08-26 10:29:26 429

原创 Leetcode 38. Count and Say Java解法

The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211is read off as"one 1"or11.11is read off ...

2019-08-24 23:19:18 198

原创 leetcode 70. Climbing Stairs Java解法,Amazon面试

You are climbing a stair case. It takesnsteps 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:Givennwill be a positive...

2019-08-22 10:39:58 196

原创 Leetcode 250. Count Univalue Subtrees 谷歌面试, Java解法详解

这是一道谷歌会考的题目Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.Example :Input: root = [5,1,5,5,5,null,5] ...

2019-08-22 10:19:58 386

原创 Java 简单Project 2, 学生数据库

任务描述实现:package com.company;import java.util.Scanner;public class Main { public static void main(String[] args) { // ask how many students we want to add System.out.prin...

2019-08-21 05:08:35 265

原创 狗家 Online Assessment

License Key Formatting Unique Email Addresses Fruit Into Baskets Odd Even Jump Maximum Area Serving Cake Min Days to Bloom Fill Matrix Compare Strings Largest Subarray Length K Decreasing Sub...

2019-08-08 23:57:26 402

原创 IntelliJ Idea, Java8 连接 MySQL 之方法Windows

1. 准备条件安装Java, 我的安装版本是Java 8.安装MySQL, 我的安装版本是 MySQL 8.0.15, 到官网下载安装即可,一路点默认的选项,下一步。安装完成后需要添加到PATH.还要在MySQL 额外下载一个connector, 根据自己安装的版本下载,我的是mysql-connector-java-8.0.15.jar。然后把connector 的jar...

2019-08-04 23:52:56 344

原创 Java 简单Project 1, 命令行程序

1. 命令行程序利用main函数可以接受参数 String[] args 这一特点。public static void main(String[] args)2. 任务描述写一个命令行程序,能够1. 读取一个目录下的所有文件和子目录2. 在每个文件中寻找一段文本,支持正则查找3. 把所有符合条件的文件添加到一个ZIP压缩包。3. 逐步分析3.1首先,我...

2019-08-03 11:19:49 451

原创 Java中 Queue队列的用法及例子

1. Usage 用法// "static void main" must be defined in a public class.public class Main { public static void main(String[] args) { // 1. Initialize a queue. Queue<Integer> q...

2019-08-01 22:33:08 479

原创 亚麻 OA 2019 题目

Most Common Word Prison Cells After N Days K Closest Points to Origin Reorder Log Files Partition Labels Min Cost to Add New Roads Min distance to remove the obstacle Roll Dice Min Cost to Con...

2019-07-29 23:08:57 2421

原创 Leetcode [141, 142] Linked List Cycle,java解法

141 Linked List CycleGiven a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the l...

2019-07-25 09:43:24 347

原创 Leetcode[217, 136, 349, 202] HashTable 小专题 1 HashSet

HashTableis a data structure which organizes data usinghash functionsin order to supportquick insertion and search.In this article, we will take a look at the principle of the hash table.一 自己定...

2019-07-21 15:43:27 203

原创 Leetcode 1089. Duplicate Zeros, java解法 及Queue的使用

Given a fixed lengtharrayarrof integers, duplicate each occurrence of zero, shifting the remaining elements to the right.Note that elements beyond the length of the original array are not written...

2019-07-20 17:21:58 336

原创 Leetcode[498, 54, 118 ] Array 专题(2) 2D Array

此类题目就是花式遍历2维数组,我个人并不喜欢。498.Diagonal TraverseGiven a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.Example:I...

2019-07-19 11:51:34 178

原创 Leetcode 283. Move Zeroes java解法

Given an arraynums, write a function to move all0'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]Note:You m...

2019-07-16 08:58:48 301

原创 Leetcode 1119. Remove Vowels from a String, Java解法

Given a stringS, remove the vowels'a','e','i','o', and'u'from it, and return the new string.Example 1:Input: "leetcodeisacommunityforcoders"Output: "ltcdscmmntyfrcdrs"Example 2:Inpu...

2019-07-15 23:52:40 326

原创 Leetcode [724, 747,66] Array专题 (1)

Operations in Array// "static void main" must be defined in a public class.public class Main { public static void main(String[] args) { // 1. Initialize int[] a0 = new int[5];...

2019-07-15 13:12:46 163

原创 Leetcode 867. Transpose Matrix, Java解法

Given amatrixA, return the transpose ofA.The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.Example 1:Input: [[1,2,3]...

2019-07-14 21:11:57 193

原创 Leetcode 1002. Find Common Characters, Java 解法

Given an arrayAof strings made only from lowercase letters, return a list of all characters that show up in all strings within the list(including duplicates).For example, if a character occurs 3 ...

2019-07-14 20:56:08 309

原创 Leetcode 999. Available Captures for Rook , Java解法。

On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns. These are given as characters 'R', '.', 'B', and 'p' respectively. Uppercase charact...

2019-07-14 11:39:22 216

原创 Leetcode 509. Fibonacci Number , Java 解法

TheFibonacci numbers, commonly denotedF(n)form a sequence, called theFibonacci sequence, such that each number is the sum of the two preceding ones, starting from0and1. That is,F(0) = 0, F(...

2019-07-14 09:08:49 409

原创 Leetcode 11. Container With Most Water , Java解法

Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Find two...

2019-07-13 08:59:06 208

原创 公开课 CS61B Data Structures, UCB

CS61B Data Structures, UCB(1)Primitive TypesEach Java type has a different way to interpret the bits:eg. 72 stored as 01001000Letter H stored as 01001000primitive types in Javabyteshortintlo...

2019-07-12 22:54:37 665

原创 Leetcode 922. Sort Array By Parity II , Java解法

Given an arrayAof non-negative integers, half of the integers in A are odd, and half of the integers are even.Sort the array so that wheneverA[i]is odd,iis odd; and wheneverA[i]is even,iis...

2019-07-12 20:10:22 384

原创 Leetcode 1051. Height Checker, Java解法

Students are asked to stand in non-decreasing order of heights for an annual photo.Return the minimum number of students not standing in the right positions. (This is the number of students that mu...

2019-07-12 14:40:32 574 1

原创 Leetcode 561. Array Partition I, Java解法

Given an array of2nintegers, your task is to group these integers intonpairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as poss...

2019-07-12 12:37:46 299

原创 Leetcode 977. Squares of a Sorted Array, Java解法

Given an array of integersAsorted in non-decreasing order,return an array of the squares of each number,also in sorted non-decreasing order.Example 1:Input: [-4,-1,0,3,10]Output: [0,1,9,16,1...

2019-07-12 11:16:39 413

原创 Leetcode 905. Sort Array By Parity, Java解法

Given an arrayAof non-negative integers, return an array consisting of all the even elements ofA, followed by all the odd elements ofA.You may return any answer array that satisfies this conditi...

2019-07-12 10:34:30 223

原创 Leetcode 832. Flipping an Image, Java解法

Given a binary matrixA, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For examp...

2019-07-12 10:01:35 187

原创 Leetcode 1085. Sum of Digits in the Minimum Number, Java解法

Given an arrayAof positive integers, letSbe the sum of the digits of the minimal element ofA.Return 0 ifSis odd, otherwise return 1.Example 1:Input: [99,77,33,66,55]Output: 1Explana...

2019-07-11 20:03:08 263

原创 Leetcode 1086. High Five Java 解法

先吐槽一下这个难度,咋也不能是easy啊,和其他easy的不在一个量级。Given a list of scores of different students, return the average score of each student'stop five scoresinthe order of each student's id.Each entryitems[i]h...

2019-07-11 16:11:37 1391

原创 一瞥 Java Arrays

一瞥 Java Arrays Java Arrays1 Declare and Initalize2 The "for each" Loop3 Array Copying4 Command-Line Parameters5 Array Sorting其他 java.util.Arrays , API1. binarySearch2. fill3. equals6 Multidimensional...

2019-07-10 23:37:53 205

原创 Leetcode 1. Two Sum, Java 解法

Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not use thesame...

2019-07-10 20:15:22 209

翻译 Leetcode 1064. Fixed Point, Java解法

Given an arrayAof distinct integers sorted in ascending order, return the smallest indexithat satisfiesA[i] == i. Return-1if no suchiexists.Example 1:Input: [-10,-5,0,3,7]Output: 3...

2019-07-10 14:22:34 800

原创 Leetcode 760. Find Anagram Mappings, java解法

Given two listsAandB, andBis an anagram ofA.Bis an anagram ofAmeansBis made by randomizing the order of the elements inA.We want to find anindex mappingP, fromAtoB. A mappingP[i] =...

2019-07-10 13:51:48 192

原创 Leetcode 1108. Defanging an IP Address, Java解法

Given a valid (IPv4) IPaddress, return a defanged version of that IP address.AdefangedIP addressreplaces every period"."with"[.]".Example 1:Input: address = "1.1.1.1"Output: "1[.]1[....

2019-07-09 23:43:23 505

翻译 Leetcode 771. Jewels and Stones Java解法

You're given stringsJrepresenting the types of stones that are jewels, andSrepresenting the stones you have. Each character inSis a type of stone you have. You want to know how many of the ston...

2019-07-05 23:59:35 218

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除