题目 Implement pow(x, n). Example 1: Input: 2.00000, 10 Output: 1024.00000 Example 2: Input: 2.10000, 3 Output: …
分类:LeetCode
[LeetCode] Set Mismatch 设置不匹配
The set S originally contains numbers from 1 to n. But unfortunately, due to the data er…
[LeetCode] Valid Parenthesis String 验证括号字符串
Given a string containing only three types of characters: ‘(‘, ‘)’ and ‘*…
[Leetcode] Encode and Decode Strings 字符串编解码
Encode and Decode Strings Design an algorithm to encode a list of strings to a string. The encoded string is t…
LeetCode | Interleaving String(交叉字符串)
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and&n…
[LintCode][Heap][Deque] Sliding Window Maximum
Problem Given an array of n integer with duplicate number, and a moving window(size k), move the window at eac…
283. 移动零
一、题目原型: 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 二、题目意思剖析: 示例: 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须…
算法:两数之和
给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。 你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 num…
13. Two Pointer
两个指针的问题:通过2个指针同步或不同步的移动,得到结果。时间复杂度一般会降低一个数量级。 适用于排好序的情况 86. Partition List 解析: 使用x进行划分,小的在前面,大的在后面,x两边的相对顺序不变。…
Leetcode - Rotate Function
My code: public class Solution { public int maxRotateFunction(int[] A) { if (A == null || A.length == 0) { ret…
Leetcode - Sum of Left Leaves
My code: recursion /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode le…
LeetCode | Copy List with Random Pointer
题目: A linked list is given such that each node contains an additional random pointer which could point to any …