ZMR小站

很高兴遇见你~


  • 首页

  • 标签

  • 分类

  • 归档

p415

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

LeetCode p415 Add Strings 题解

1.题目:

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

Note:

The length of both num1 and num2 is < 5100.
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.
阅读全文 »

p234

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

LeetCode p234 Palindrome Linked List 题解

1.题目:

Given a singly linked list, determine if it is a palindrome.

Follow up:
Could you do it in O(n) time and O(1) space?

阅读全文 »

p160

发表于 2017-02-14 | 分类于 blog

LeetCode p160 Intersection of Two Linked Lists 题解

1.题目:

Write a program to find the node at which the intersection of two singly linked lists begins.

For example, the following two linked lists:

A: a1 → a2
↘
c1 → c2 → c3
↗
B: b1 → b2 → b3

阅读全文 »

p155

发表于 2017-02-14 | 分类于 blog

LeetCode p155 Min Stack 题解

1.题目:

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

push(x) -- Push element x onto stack.
pop() -- Removes the element on top of the stack.
top() -- Get the top element.
getMin() -- Retrieve the minimum element in the stack.

Example:

MinStack minStack = new MinStack();
minStack.push(-2);
minStack.push(0);
minStack.push(-3);
minStack.getMin(); –> Returns -3.
minStack.pop();
minStack.top(); –> Returns 0.
minStack.getMin(); –> Returns -2.

阅读全文 »

p119

发表于 2017-02-14 | 分类于 blog

LeetCode p119 Pascal’s Triangle II 题解

1.题目:

Given an index k, return the kth row of the Pascal’s triangle.

For example, given k = 3,
Return [1,3,3,1].

Note:
Could you optimize your algorithm to use only O(k) extra space?

阅读全文 »

p112

发表于 2017-02-14 | 分类于 blog

LeetCode p112 Path Sum 题解

1.题目:

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree and sum = 22,

      5
     / \
    4   8
   /   / \
  11  13  4
 /  \      \
7    2      1

return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22.

阅读全文 »

p125

发表于 2017-02-13 | 分类于 blog

LeetCode p125 Valid Palindrome 题解

1.题目:

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

For example,
“A man, a plan, a canal: Panama” is a palindrome.
“race a car” is not a palindrome.

Note:
Have you consider that the string might be empty? This is a good question to ask during an interview.

For the purpose of this problem, we define empty string as valid palindrome.

阅读全文 »

1…678…33
ZhangMengRou

ZhangMengRou

ZMR小站

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