ZMR小站

很高兴遇见你~


  • 首页

  • 标签

  • 分类

  • 归档

p82

发表于 2017-03-17 | 分类于 blog

LeetCode p82 Remove Duplicates from Sorted List II 题解

1.题目:

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1->1->2->3, return 2->3.

阅读全文 »

p79

发表于 2017-03-17 | 分类于 blog

LeetCode p79 Word Search 题解

1.题目:

Given a 2D board and a word, find if the word exists in the grid.

The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.

For example,
Given board =

[
[‘A’,’B’,’C’,’E’],
[‘S’,’F’,’C’,’S’],
[‘A’,’D’,’E’,’E’]
]
word = “ABCCED”, -> returns true,
word = “SEE”, -> returns true,
word = “ABCB”, -> returns false.

阅读全文 »

p43

发表于 2017-03-17 | 分类于 blog

LeetCode p43 Multiply Strings 题解

1.题目:

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.

Note:

The length of both num1 and num2 is < 110.
Both num1 and num2 contains only digits 0-9.
Both num1 and num2 does not contain any leading zero.
You must not use any built-in BigInteger library or convert the inputs to integer directly.

阅读全文 »

p6

发表于 2017-03-16 | 分类于 blog

LeetCode p6 ZigZag Conversion 题解

1.题目:

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)

P A H N
A P L S I I G
Y I R
And then read line by line: “PAHNAPLSIIGYIR”
Write the code that will take a string and make this conversion given a number of rows:

string convert(string text, int nRows);
convert(“PAYPALISHIRING”, 3) should return “PAHNAPLSIIGYIR”.

阅读全文 »

p8

发表于 2017-03-16 | 分类于 blog

LeetCode p8 String to Integer (atoi) 题解

1.题目:

Implement atoi to convert a string to an integer.

Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.

Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front.

Update (2015-02-10):
The signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button to reset your code definition.

阅读全文 »

p5

发表于 2017-03-15 | 分类于 blog

LeetCode p5 Longest Palindromic Substring 题解

1.题目:

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.

Example:

Input: “babad”

Output: “bab”

Note: “aba” is also a valid answer.
Example:

Input: “cbbd”

Output: “bb”

阅读全文 »

p2

发表于 2017-03-15 | 分类于 blog

LeetCode p2 Add Two Numbers 题解

1.题目:

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.

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8

阅读全文 »
123…33
ZhangMengRou

ZhangMengRou

ZMR小站

230 日志
4 分类
14 标签
© 2019 ZhangMengRou
由 Hexo 强力驱动
|
主题 — NexT.Gemini v5.1.4