Skip to content

Commit 9bf6023

Browse files
committed
readme
1 parent 08a546a commit 9bf6023

File tree

1 file changed

+9
-299
lines changed

1 file changed

+9
-299
lines changed

README.md

+9-299
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,24 @@
1-
# `Today Update`
2-
(Notes: "♥" Welcome to visit or fork or star my LeetCode Manager @
3-
https://github.com/jackzhenguo/LeetCodeManager
4-
## Sort
5-
### 324 Wiggle Sort II
6-
* [Github:#324 Wiggle Sort II](/Sort/WiggleSortSln.cs)
7-
* [CSDN:#324 Wiggle Sort II](http://blog.csdn.net/daigualu/article/details/72820281)
8-
* This is a great question for it involves a great idea: virtual index
9-
```C#
10-
/// <summary>
11-
/// WiggleSort
12-
/// </summary>
13-
public class WiggleSortSln
14-
{
15-
private static int[] _array;
16-
17-
public int[] WiggleSort(int[] array)
18-
{
19-
_array = array;
20-
int median = findKThLargest(_array.Length / 2);
21-
int left = 0, i = 0, right = _array.Length - 1;
22-
23-
while (i <= right)
24-
{
25-
if (_array[newIndex(i)] > median)
26-
{
27-
//put newIndex(i) at odd index(from 1, 3, to 5, ...)
28-
swap(newIndex(left++), newIndex(i));
29-
i++;
30-
}
31-
else if (_array[newIndex(i)] < median)
32-
{
33-
//put newIndex(i) at even index(max even index to little .... )
34-
swap(newIndex(right--), newIndex(i)); //right--, so i relatively toward right 1 step
35-
}
36-
else
37-
{
38-
i++;
39-
}
40-
}
41-
return _array;
42-
}
43-
44-
private int newIndex(int index)
45-
{
46-
return (1 + 2 * index) % (_array.Length | 1);
47-
}
48-
49-
private void swap(int i, int j)
50-
{
51-
int tmp = _array[i];
52-
_array[i] = _array[j];
53-
_array[j] = tmp;
54-
}
55-
56-
//based on quick sort to find the Kth largest in _array
57-
private int findKThLargest(int k)
58-
{
59-
int left = 0;
60-
int right = _array.Length - 1;
61-
while (true)
62-
{
63-
int pivotIndex = quickSort(left, right);
64-
if (k == pivotIndex)
65-
return _array[pivotIndex];
66-
else if (k < pivotIndex)
67-
right = pivotIndex - 1;
68-
else
69-
left = pivotIndex + 1;
70-
}
71-
}
72-
73-
private int quickSort(int lo, int hi)
74-
{
75-
int key = _array[lo];
76-
while (lo < hi)
77-
{
78-
while (lo < hi && _array[hi] >= key)
79-
hi--;
80-
//hi is less than key, hi element moves to lo index
81-
_array[lo] = _array[hi];
82-
while (lo < hi && _array[lo] < key)
83-
lo++;
84-
//lo is bigger than key, lo element moves to hi index
85-
_array[hi] = _array[lo];
86-
}
87-
_array[lo] = key;
88-
return lo;
89-
}
90-
}
91-
```
92-
## Bit Mainpulation
93-
### 342 Power of Four
94-
* [Github:#342 Power of Four](/BitManipulation/PowOfFourSln.cs)
95-
* [CSDN:#342 Power of Four](http://blog.csdn.net/daigualu/article/details/72821233)
96-
---
97-
98-
99-
# About it
1+
## About it
1002
Algorithm is tool for exercising our thinking patterns, and we can strengthen the ability to convert mathematical models into code. Whether you are engaged in artificial intelligence, in-depth learning, or advanced software development, no matter what language you use, such as C#,C++,Java,python,etc., and applying the most appropriate algorithm is always the most important point when faced with a specific problem. *Every problem in practice has its own particularity, which makes it not that easier to choose the most appropriate algorithm.* How do we write the algorithm that most efficiently apply to a practical issue? **Yes, LeetCode.** You can write an algorithm until it accepted, and do not rush to do the next question, and learn the solution someone else has submitted, `so you can solve the problem from the ability of solving the problem to that fast and efficient realm`.
1013

1024
I create this respository called **leetcode-csharp** because I apply C# language to solve LeetCode and `every day` will update it and also publish it in `CSDN blog`(http://blog.csdn.net/daigualu) my blog column(http://blog.csdn.net/column/details/14761.html) Also, I will put some algorithm ideas that famous scientists have created on [My Wiki for this repository](https://github.com/jackzhenguo/leetcode-csharp/wiki) such as [Flody tortoise and hare](https://github.com/jackzhenguo/leetcode-csharp/wiki/Floyd's-Tortoise-and-Hare) and [KMP](https://github.com/jackzhenguo/leetcode-csharp/wiki/KMP-getNext) and so on.
1035

1046
Anyway, welcome to view, star and fork, then contribute.
1057

8+
---
9+
10610
## Contributing
10711
1. Fork it!
10812
2. Create your feature branch: git checkout -b my-leetcode-csharp
10913
3. Commit your changes: git commit -am 'Add some questions and better solutions'
11014
4. Push to the branch: git push origin my-leetcode-csharp
11115
5. Submit a pull request and enjoy! :D
11216

17+
---
18+
19+
## Today Update
20+
[Leetcode Today Update](/TodayUpdate.md)
21+
11322
## Solution List
11423
solutions using C# for leetcode according to tags of questions
11524
Tags are following:
@@ -125,203 +34,4 @@ Tags are following:
12534
* [Tree](/Tree)
12635

12736
## Details
128-
## Array
129-
|Number| Title(Blog URL)|
130-
|------|-------|
131-
35 |[Search Insert Position](http://blog.csdn.net/daigualu/article/details/66995617)
132-
118| [Pascal's Triangle](http://blog.csdn.net/daigualu/article/details/67006388)
133-
119 |[Pascal's Triangle II](http://blog.csdn.net/daigualu/article/details/67069088)
134-
414| [Third Maximum Number](http://blog.csdn.net/daigualu/article/details/68063481)
135-
121| [Best Time to Buy and Sell Stock](http://blog.csdn.net/daigualu/article/details/71038726)
136-
66| [Plus One](http://blog.csdn.net/daigualu/article/details/71056697)
137-
26 |[Remove Duplicates from Sorted Array](http://blog.csdn.net/daigualu/article/details/71064545)
138-
27| [Remove Element](http://blog.csdn.net/daigualu/article/details/71104482)
139-
122 |[Best Time to Buy and Sell Stock II](http://blog.csdn.net/daigualu/article/details/71104584)
140-
268 |[Missing Number](http://blog.csdn.net/daigualu/article/details/69220202)
141-
217| [Contains Duplicate](http://blog.csdn.net/daigualu/article/details/71123673)
142-
532| [K-diff Pairs in an Array](http://blog.csdn.net/daigualu/article/details/71129806)
143-
189| [Rotate Array](http://blog.csdn.net/daigualu/article/details/71159419)
144-
169 |[Majority Element](http://blog.csdn.net/daigualu/article/details/69937729)
145-
167 |[Two Sum II - Input array is sorted](http://blog.csdn.net/daigualu/article/details/69787679)
146-
88 |[Merge Sorted Array](http://blog.csdn.net/daigualu/article/details/69367334)
147-
53 |[Maximum Subarray](http://blog.csdn.net/daigualu/article/details/69936974)
148-
485 |[Max Consecutive Ones](http://blog.csdn.net/daigualu/article/details/71216338)
149-
283 |[Move Zeroes](http://blog.csdn.net/daigualu/article/details/69329038)
150-
448 |[Find All Numbers Disappeared in an Array](http://blog.csdn.net/daigualu/article/details/71168875)
151-
1| [Two Sum](http://blog.csdn.net/daigualu/article/details/68957096)
152-
219 |[Contains Duplicate II](http://blog.csdn.net/daigualu/article/details/71166985)
153-
566| [Reshape the Matrix](http://blog.csdn.net/daigualu/article/details/71275325)
154-
561| [Array Partition I](http://blog.csdn.net/daigualu/article/details/71273279)
155-
156-
---
157-
158-
## Hash Table
159-
|Number| Title(Blog URL)|
160-
|------|-------|
161-
136 |[Single number](http://blog.csdn.net/daigualu/article/details/68921131)
162-
1| [Two Sum](http://blog.csdn.net/daigualu/article/details/68957096)
163-
447 |[Number of Boomerangs](http://blog.csdn.net/daigualu/article/details/68958818)
164-
463 |[Island Perimeter](http://blog.csdn.net/daigualu/article/details/68959304)
165-
409 |[Longest Palindrome](http://blog.csdn.net/daigualu/article/details/69053267)
166-
438 |[Find All Anagrams in a String](http://blog.csdn.net/daigualu/article/details/71339879)
167-
389 |[Find the Difference](http://blog.csdn.net/daigualu/article/details/71450823)
168-
350 |[Intersection of Two Arrays II](http://blog.csdn.net/daigualu/article/details/69666351)
169-
349 | [Intersection of Two Arrays](http://blog.csdn.net/daigualu/article/details/69666198)
170-
500 |[Keyboard Row](http://blog.csdn.net/daigualu/article/details/71447614)
171-
217| [Contains Duplicate](http://blog.csdn.net/daigualu/article/details/71123673)
172-
204 | [Count Primes](http://blog.csdn.net/daigualu/article/details/71366483)
173-
202 | [Happy Number](http://blog.csdn.net/daigualu/article/details/71433906)
174-
219 |[Contains Duplicate II](http://blog.csdn.net/daigualu/article/details/71166985)
175-
242 |[Valid Anagram](http://blog.csdn.net/daigualu/article/details/71358552)
176-
290 |[Word Pattern](http://blog.csdn.net/daigualu/article/details/71358552)
177-
205 |[Isomorphic Strings](http://blog.csdn.net/daigualu/article/details/71357419)
178-
179-
## Linked List
180-
|Number| Title(Blog URL)|
181-
|------|-------|
182-
141 | [Linked List Cycle](http://blog.csdn.net/daigualu/article/details/69055927)
183-
237 | [Delete Node in a Linked List](http://blog.csdn.net/daigualu/article/details/69055991)
184-
83 | [Remove Duplicates from Sorted List](http://blog.csdn.net/daigualu/article/details/69093677)
185-
160 | [Intersection of Two Linked Lists](http://blog.csdn.net/daigualu/article/details/69526717)
186-
203 |[Remove Linked List Elements](http://blog.csdn.net/daigualu/article/details/69389243)
187-
206 | [Reverse Linked List](http://blog.csdn.net/daigualu/article/details/69372119)
188-
234 | [Palindrome Linked List](http://blog.csdn.net/daigualu/article/details/69388513)
189-
21 | [Merge Two Sorted Lists](http://blog.csdn.net/daigualu/article/details/69565969)
190-
191-
---
192-
193-
## Math
194-
|Number| Title(Blog URL)|
195-
|------|-------|
196-
231 | [Power of Two](http://blog.csdn.net/daigualu/article/details/69102931)
197-
268| [Missing Number](http://blog.csdn.net/daigualu/article/details/69220202)
198-
507 | [Perfect Number](http://blog.csdn.net/daigualu/article/details/69233798)
199-
9| [Palindrome Number](http://blog.csdn.net/daigualu/article/details/72717009)
200-
453 | [Minimum Moves to Equal Array Elements](http://blog.csdn.net/daigualu/article/details/72354061)
201-
13 |Roman to Integer
202-
441 |[Arranging Coins]()
203-
415| [Add Strings](http://blog.csdn.net/daigualu/article/details/72356377)
204-
400 |[Nth Digit](http://blog.csdn.net/daigualu/article/details/72572244)
205-
367 |Valid Perfect Square
206-
66| [Plus One](http://blog.csdn.net/daigualu/article/details/71056697)
207-
7| [Reverse Integer](http://blog.csdn.net/daigualu/article/details/72464418)
208-
204 |[Count Primes](http://blog.csdn.net/daigualu/article/details/71366483)
209-
202 |[Happy Number](http://blog.csdn.net/daigualu/article/details/71433906)
210-
172 |Factorial Trailing Zeroes
211-
171 |[Excel Sheet Column Number](http://blog.csdn.net/daigualu/article/details/72717145)
212-
168 |[Excel Sheet Column Title](http://blog.csdn.net/daigualu/article/details/72638706)
213-
258 |Add Digits
214-
263 |Ugly Number
215-
69| [Sqrt(x)](http://blog.csdn.net/daigualu/article/details/72578272)
216-
67 |[Add Binary](http://blog.csdn.net/daigualu/article/details/72638937)
217-
246 |Strobogrammatic Number
218-
326 |Power of Three
219-
220-
---
221-
222-
## Two Pointers
223-
|Number| Title(Blog URL)|
224-
|------|-------|
225-
345 |[Reverse Vowels of a String](http://blog.csdn.net/daigualu/article/details/69257693)
226-
125 |[Valid Palindrome](http://blog.csdn.net/daigualu/article/details/69265381)
227-
283| [Move Zeroes](http://blog.csdn.net/daigualu/article/details/69329038)
228-
88 |[Merge Sorted Array](http://blog.csdn.net/daigualu/article/details/69367334)
229-
234| [Palindrome Linked List](http://blog.csdn.net/daigualu/article/details/69388513)
230-
349 |Intersection of Two Arrays
231-
167 |[Two Sum II - Input array is sorted](http://blog.csdn.net/daigualu/article/details/69787679)
232-
350| Intersection of Two Arrays II
233-
344| Reverse String
234-
28| Implement strStr()
235-
27 |Remove Element
236-
26| Remove Duplicates from Sorted Array
237-
141| Linked List Cycle
238-
532| K-diff Pairs in an Array
239-
240-
---
241-
242-
## String
243-
|Number| Title(Blog URL)|
244-
|------|-------|
245-
58| [Length of Last Word](http://blog.csdn.net/daigualu/article/details/69568460)| 31.5%| Easy
246-
20 |[Valid Parentheses](http://blog.csdn.net/daigualu/article/details/69569622) |32.8% |Easy
247-
520 |[Detect Capital](http://blog.csdn.net/daigualu/article/details/69663210)| 52.5%| Easy
248-
459 |[Repeated Substring Pattern](http://blog.csdn.net/daigualu/article/details/69663545)| 38.4%| Easy
249-
434 |[Number of Segments in a String](http://blog.csdn.net/daigualu/article/details/69664369) |37.0% |Easy
250-
408 |Valid Word Abbreviation | 27.5% |Easy
251-
13 |Roman to Integer |44.6%| Easy
252-
14 |[Longest Common Prefix](http://blog.csdn.net/daigualu/article/details/69665015) |31.0% |Easy
253-
383 |[Ransom Note](http://blog.csdn.net/daigualu/article/details/69665190) |46.5% |Easy
254-
521 |Longest Uncommon Subsequence I |46.1% |Easy
255-
345 |Reverse Vowels of a String| 37.9% |Easy
256-
28 |Implement strStr() |27.5% |Easy
257-
344 |Reverse String| 58.2%| Easy
258-
293 |Flip Game |54.8% |Easy
259-
38 |Count and Say |33.4% |Easy
260-
157 |Read N Characters Given Read4 | 29.2%| Easy
261-
541 |Reverse String II |44.1% |Easy
262-
125 |Valid Palindrome |25.8% |Easy
263-
67 |Add Binary |31.3% |Easy
264-
265-
---
266-
267-
## Stack
268-
|Number| Title(Blog URL)| Pass Rate| Degree |
269-
|------|----------------|--------|----------|
270-
225|[Implement Stack using Queues](http://blog.csdn.net/daigualu/article/details/70183272)| 32.0%| Easy
271-
496| [Next Greater Element I](http://blog.csdn.net/daigualu/article/details/70185529) |57.5% |Easy
272-
155| [Min Stack](http://blog.csdn.net/daigualu/article/details/70185814)| 27.4%| Easy
273-
232| [Implement Queue using Stacks](http://blog.csdn.net/daigualu/article/details/70186010)| 35.8%| Easy
274-
20| [Valid Parentheses](http://blog.csdn.net/daigualu/article/details/69569622)| 32.9%| Easy
275-
276-
---
277-
278-
## Binary Search
279-
|Number| Title(Blog URL)| Pass Rate| Degree |
280-
|------|----------------|--------|----------|
281-
367 |[Valid Perfect Square](http://blog.csdn.net/daigualu/article/details/69787644)| 37.8%| Easy
282-
270| Closest Binary Search Tree Value| 38.8%| Easy
283-
167 |[Two Sum II - Input array is sorted](http://blog.csdn.net/daigualu/article/details/69787679) |47.4%| Easy
284-
441 |[Arranging Coins](http://blog.csdn.net/daigualu/article/details/69788500)| 36.0%| Easy
285-
35| [Search Insert Position](http://blog.csdn.net/daigualu/article/details/66995617)| 39.3%| Easy
286-
374 |Guess Number Higher or Lower |34.4%| Easy
287-
69 |Sqrt(x) |27.4%| Easy|
288-
278| [First Bad Version](http://blog.csdn.net/daigualu/article/details/69802371) |24.8% |Easy
289-
475| Heaters |29.7%| Easy
290-
350 |[Intersection of Two Arrays II](http://blog.csdn.net/daigualu/article/details/69666351) |44.1%| Easy
291-
349| [Intersection of Two Arrays](http://blog.csdn.net/daigualu/article/details/69666198)| 46.5%| Easy
292-
293-
---
294-
295-
## Dynamic Programming
296-
|Number| Title(Blog URL)| Pass Rate| Degree |
297-
|------|----------------|--------|----------|
298-
53| [Maximum Subarray](http://blog.csdn.net/daigualu/article/details/69936974)| 39.2%| Easy|
299-
169| [Majority Element](http://blog.csdn.net/daigualu/article/details/69937729)| 45.6%| Easy|
300-
303| [Range Sum Query - Immutable](http://blog.csdn.net/daigualu/article/details/69938986)| 27.8%| Easy|
301-
276 |Paint Fence | 34.1%| Easy|
302-
523 |[Continuous Subarray Sum](http://blog.csdn.net/daigualu/article/details/69941770)| 21.6%| Easy|
303-
256| Paint House | 45.9%| Easy|
304-
198| [House Robber](http://blog.csdn.net/daigualu/article/details/69946684)| 38.1%| Easy|
305-
121| Best Time to Buy and Sell Stock|40.1% |Easy|
306-
70| Climbing Stairs |39.2%| Easy|
307-
308-
---
309-
310-
## Tree
311-
|Number| Title(Blog URL)| Pass Rate| Degree |
312-
|------|----------------|--------|----------|
313-
107| [Binary Tree Level Order Traversal II](http://blog.csdn.net/daigualu/article/details/70254459)| 39.0%| Easy
314-
257 |[Binary Tree Paths](http://blog.csdn.net/daigualu/article/details/70340125)| 36.8%| Easy
315-
501 |[Find Mode in Binary Search Tree](http://blog.csdn.net/daigualu/article/details/70341143)| 38.4%| Easy
316-
437 |[Path Sum III](http://blog.csdn.net/daigualu/article/details/70342773)| 39.3% |Easy
317-
404 |[Sum of Left Leaves](http://blog.csdn.net/daigualu/article/details/70482270)| 46.5%| Easy
318-
112 |[Path Sum](http://blog.csdn.net/daigualu/article/details/70482285)| 33.5% |Easy
319-
110 |[Balanced Binary Tree](http://blog.csdn.net/daigualu/article/details/70482667)| 36.8% |Easy
320-
108 |[Convert Sorted Array to Binary Search Tree](http://blog.csdn.net/daigualu/article/details/70485834)| 41.3%| Easy
321-
543 |[Diameter of Binary Tree](http://blog.csdn.net/daigualu/article/details/70491447)| 42.3%| Easy
322-
226 |[Invert Binary Tree](http://blog.csdn.net/daigualu/article/details/70536685)| 50.8%| Easy
323-
235 |[Lowest Common Ancestor of a Binary Search Tree](http://blog.csdn.net/daigualu/article/details/70539096)| 38.5%| Easy
324-
104 |[Maximum Depth of Binary Tree](http://blog.csdn.net/daigualu/article/details/70541420)| 51.7%| Easy
325-
111| [Minimum Depth of Binary Tree](http://blog.csdn.net/daigualu/article/details/70543969)| 32.7% |Easy
326-
101 |[Symmetric Tree](http://blog.csdn.net/daigualu/article/details/70544774)| 37.9%| Easy
327-
100| [Same Tree](http://blog.csdn.net/daigualu/article/details/70254478)| 45.8%| Easy
37+
[Leetcode Solution Details](/Details.md)

0 commit comments

Comments
 (0)