Rotate List
Rotate ListGiven a list, rotate the list to the right by k places, where k is non-negative. For example:12Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.
Rotate ListGiven a list, rotate the list to the right by k places, where k is non-negative. For example:12Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.
Permutation SequenceThe set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3): “123” “132
Spiral Matrix IIGiven an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example:Given n = 3, You should return the following matrix: 12345[ [ 1, 2, 3 ], [
Merge IntervalsGiven a collection of intervals, merge all overlapping intervals. For example:12Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. 提示 解題應用 Array Array/Slice Sort In
Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example:Given the following matrix: 12345[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8,
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [
Group AnagramsGiven an array of strings, group anagrams together. For example:Given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],Return: 12345[ ["ate", "eat","tea"], [&
Rotate ImageYou are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place? 提示 解題應用 Array Array/Slice Default:123fu
Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations. For example:[1,1,2] have the following unique permutations: 12345[ [1,1,2], [1,2
PermutationsGiven a collection of distinct numbers, return all possible permutations. For example:[1,2,3] have the following permutations: 12345678[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],
Multiply StringsGiven 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 cont
Combination Sum IIGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once
Combination SumGiven a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may
Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no dupl
Search for a RangeGiven an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(lo
Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target v
Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the l
Implement strStr()Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 提示 解題應用 TwoPointers KMP演算法 String 規律觀查 Defa
Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example:Given n = 3, a solution set is: 1234567[ "((()))",