0%

Description

Given a string, find the length of the longest substring without repeating characters.

Example 1:

1
2
3
Input: "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.

Example 2:

1
2
3
Input: "bbbbb"
Output: 1
Explanation: The answer is "b", with the length of 1.

Example 3:

1
2
3
4
Input: "pwwkew"
Output: 3
Explanation: The answer is "wke", with the length of 3.
Note that the answer must be a substring, "pwke" is a subsequence and not a substring.

Difficulty: Medium

Code:

1
2
3
4
5
class Solution {
public int lengthOfLongestSubstring(String s) {

}
}

题意

给定一个字符串,找出不包含重复字符的最长子串的长度。

阅读全文 »

Description

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Example:

1
2
3
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.

Difficulty: Medium

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {

}
}

题意

给定两个非空链表分别代表两个非负整数。数位以倒序存储,并且每一个节点包含一位数字。将两个数字相加并以链表形式返回。假定两个数不包含任何前置0,除非这个数本身就是0。

这其实就是两个非负整数的加法运算,先从最后一位相加,有进位则保留在下一位中计算进去。

阅读全文 »

Description

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

Example:

1
2
3
4
Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].

Difficulty: Easy

Code:

1
2
3
4
5
class Solution {
public int[] twoSum(int[] nums, int target) {

}
}

题意

给定一个整数数组,从中找出两个数的下标,使得它们的和等于一个特定的数字。假定每个输入肯定会有一个唯一解,同一个元素不可以使用两次。

阅读全文 »

Markdown扩展语法的由来是基本语法不太够用,一些个人和组织添加来额外的元素来扩展基本语法。主要包括表格、代码块、语法高亮、URL自动链接、脚注。

可用性

扩展语法并不是在所有的Markdown应用中都能使用,你需要去检查自己的应用使用的轻量级Markdown语言是否支持。

轻量级Markdown语言

这里列举集中轻量级Markdown语言,很多流行的Markdown应用都使用其中一种。

Markdown处理器

有很多可用的Markdown处理器,都能够允许你增加扩展去使用扩展语法。

表格

使用3个或者更多的连字符---去创建每一列的表头,使用竖线|去分割每一列。

1
2
3
4
5
6
7
8
9
| Syntax      | Description |
| ----------- | ----------- |
| Header | Title |
| Paragraph | Text |

| Syntax | Description |
| --- | ----------- |
| Header | Title |
| Paragraph | Text |
Syntax Description
Header Title
Paragraph Text
阅读全文 »

Markdown基本语法,几乎所有Markdown应用程序都支持John Gruber原始设计文档中概述的基本语法。

标题

在标题前插入1到6个#,表示6个不同级别的标题

1
2
3
4
5
6
# Heading level 1
## Heading level 2
### Heading level 3
#### Heading level 4
##### Heading level 5
###### Heading level 6

段落

段落之间用空行隔开,不能使用空格或者缩进

1
2
3
I really like using Markdown.

I think I'll use it to format all of my documents from now on.
阅读全文 »