作者:empty 页数:181 出版社:empty |
Rotate Array in JavaYou may have been using Java for awhile.Do you think a simple Java array questioncan be a challenge?Let'suse the following problem to testProblem:Rotate an array of n elements to the right by k steps.For example, with n=7andk=3, the array[12, 3.4, 5, 6, 7] is rotated to[5.6, 7, 1, 2, 3.4] .How many different ways do you know to solve this problem?1.1 Solution 1-Intermediate ArrayIn a straightforward way, we can create a new array and then copy elements to thenew array.Then change the original array by using System array copy 0
Contents
Rotate Array in Java
7Median of Two Sorted Arrays Java
8RegularExpression Matching in Java
9Merge Intervals
10 Insert Interval
11TwoSum
12TwoSumII Input array is sorted
13TwoSumIII Datastructure design
143Sum
154Sum
163Sum Closest
17 String to Integer(a to i)
18Merge Sorted Array
19 Valid Parentheses
20 Implement strStr()
21Set Matrix Zeroes
22 Search Insert Position
23 Longest Consecutive Sequence Java
24 Valid Palindrome
25 Spiral Matrix
26Searcha2D Matrix
27 Rotate Image
28 Triangle
29 Distinct Subsequences Total
30 Maximum Subarray
31 Maximum Product Subarray
32 Remove Duplicates from Sorted Array
33 Remove Duplicates from Sorted Array II
34 Longest Substring Without Repeating Characters
35 Longest Substring Which Contains 2 Unique Characters
36 Palindrome Partitioning
37 Reverse Words in a String
38 Find Minimum in Rotated Sorted Array
39 Find Minimum in Rotated Sorted Array II
40 Find Peak Element
41Min Stack
42 Majority Element
43 Combination Sum
44 Best Time to Buy and Sell Stock
45 Best Time to Buy and Sell Stock II
Program Creek
Contents
46 Best Time to Buy and Sell Stock III
47 Best Time to Buy and Sell Stock IV
48 Longest Common Prefix
49 Largest Number
50 Combinations
51 Compare Version Numbers
52Gas Station
53 Candy
54Jump Game
55 Pascal's Triangle
56 Container With Most Water
57 Count and Say
58 Repeated DNA Sequences
59AddTwo Numbers
60Re order List
61 LinkedList Cycle
62Copy List with Random Pointer
63MergeTwo Sorted Lists
64Mergek Sorted Lists
65 Remove Duplicates from Sorted List
66 Partition List
67LRU Cache
68 Intersection of Two Linked Lists
69Java Priority Queue Class Example
70 Solution for Binary Tree Preorder Traversal in Java
72 Solution of Iterative Binary Tree Post order Traversal in Java
73 Validate Binary Search Tree
74 Flatten Binary Tree to LinkedList
75PathSum
76 Construct Binary Tree from In order and Post order Traversal
77 Convert Sorted Array to Binary Search Tree
78 Convert Sorted List to Bina