Determine whether an integer is a palindrome. Do this without extra space. 判断一个正整数是不是回文数。 回文数的定义是,将这个数反转之后,得到的…
标签:LeetCode题目解答
LeetCode 28. Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not pa…
LeetCode 134. Gas Station
题目 There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a…
LeetCode 25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a posit…
LeetCode 13. Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Su…
LeetCode Single Number
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algor…
LeetCode 16. 3Sum Closest
题目 给一个包含 n 个整数的数组 S, 找到和与给定整数 target 最接近的三元组,返回这三个数的和。 注意事项 只需要返回三元组之和,无需返回三元组本身 样例 例如 S = [-1, 2, 1, -4] and …
LeetCode 77. Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example,If n…
LintCode Binary Tree Maximum Node二叉树的最大节点
Find the maximum node in a binary tree, return the node. 样例 给出如下一棵二叉树: 1 / -5 2 / \ / 0 3 -4 -5 返回值为 3 的节点。 分析…
LeetCode 11. Container With Most Water
Given n non-negative integers *a1 *, *a2 *, …, an , where each represents a point at coordinate (i, ai )…
LintCode 在二叉查找树中插入节点
题目 给定一棵二叉查找树和一个新的树节点,将节点插入到树中。 你需要保证该树仍然是一棵二叉查找树。 分析 分别用递归和非递归两种方法实现。本质上会发现,两种方法类似 public class Solution { /**…
LeetCode 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You …