《 Java 编程思想》CH05 初始化与清理

2020-02-13
阅读 8 分钟
859
用构造器确保初始化 在 Java 中,通过提供构造器,类的设计者可确保每个对象都会得到初始化。Java 会保证初始化的进行。构造器采用与类相同的名称。 由于构造器的名称必须与类名完全相同,所以“每个方法首字母小写”的风格在这里不适用。 构造器方法可以有参数,这样可以在初始化对象时提供实际参数。 不接受任何参数的构...

[LeetCode题解] ZigZag Conversion

2019-02-15
阅读 2 分钟
1.7k
原文在这,可以来我blog翻翻哦。 第二天。今天AC掉了一道之前没AC掉的题目。。。 今天的题目是6. ZigZag Conversion 题目描述: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) {代...

LeetCode题解 String-to-Integer(atoi)

2019-02-14
阅读 3 分钟
1.1k
原文在此, 可以来我Blog翻翻哦。 hhh, 开始一天一道LeetCode吧, 恩, 忘记了之前算到第几天了, 那么从头开始吧, 今天是第一天. 今天的题目是(8. String to Integer (atoi))[[链接]] 题目描述: Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as nece...

[LeetCode题解]Queue Reconstruction by Height

2018-03-04
阅读 3 分钟
1.7k
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this person who have a height greater than or equal to h. Write an algorithm to reconstruct the queue.

LeetCode题解 [Count Complete Tree Nodes]

2018-03-03
阅读 3 分钟
2.2k
本文首发于我的blog中 题目是Count Complete Tree Nodes: 题目描述: Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are ...

LeetCode题解[Add Two Numbers II]

2018-03-02
阅读 3 分钟
2.3k
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.