Skip to content

Commit 8bf3bcd

Browse files
BarklimBarklim
authored andcommitted
add classic examples
1 parent 5396da9 commit 8bf3bcd

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed

0122-best-time-to-buy-and-sell-stock-ii.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ var maxProfit = function(prices) {
2222
return prices[i - 1] < price ? result + (price - prices[i - 1]) : result;
2323
}, 0);
2424
};
25+
26+
// var maxProfit = function(prices) {
27+
// let profit = 0
28+
29+
// for (let i = 1; i < prices.length; i++) {
30+
// if (prices[i] > prices[i - 1]) {
31+
// profit += prices[i] - prices[i - 1]
32+
// }
33+
// }
34+
35+
// return profit
36+
// };

0189-rotate-array.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@
1414
var rotate = function(nums, k) {
1515
nums.unshift(...nums.splice((k % nums.length) * -1));
1616
};
17+
18+
// var rotate = function(nums, k) {
19+
// const n = nums.length;
20+
// k = k % n;
21+
// const rotated = new Array(n).fill(0);
22+
23+
// for (let i = 0; i < n; i++) {
24+
// rotated[(i + k) % n] = nums[i];
25+
// }
26+
27+
// for (let i = 0; i < n; i++) {
28+
// nums[i] = rotated[i];
29+
// }
30+
// };

example/README.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,82 @@ Better order to solve problems
470470
17. letter combinations of a phone number
471471
46. Permatations
472472
51. N-Queens
473-
22. Generate Parentheses
473+
22. Generate Parentheses
474+
475+
476+
### [classic](https://leetcode.com/explore/interview/card/top-interview-questions-easy)
477+
478+
##### Array
479+
480+
26. Remove Duplicates from Sorted Array
481+
122. Best Time to Buy and Sell Stock II
482+
189. Rotate Array
483+
217. Contains Duplicate
484+
136. Single Number
485+
350. Intersection of Two Arrays II
486+
66. Plus One
487+
283. Move Zeroes
488+
1. Two Sum
489+
36. Valid Sudoku
490+
48. Rotate Image
491+
492+
##### String
493+
494+
344. Reverse String
495+
7. Reverse Integer
496+
387. First Unique Character in a String
497+
242. Valid Anagram
498+
125. Valid Palindrome
499+
8. String to Integer (atoi)
500+
28. Implement strStr()
501+
14. Longest Common Prefix
502+
503+
##### Linked list
504+
505+
237. Delete Node in a Linked List
506+
19. Remove Nth Node From End of List
507+
206. Reverse Linked List
508+
21. Merge Two Sorted Lists
509+
234. Palindrome Linked List
510+
141. Linked List Cycle
511+
512+
##### Trees
513+
514+
104. Maximum Depth of Binary Tree
515+
98. Validate Binary Search Tree
516+
101. Symmetric Tree
517+
102. Binary Tree Level Order Traversal
518+
108. Convert Sorted Array to Binary Search Tree
519+
520+
##### Sorting and Searching
521+
522+
88. Merge Sorted Array
523+
278. First Bad Version
524+
525+
##### Dynamic Programming
526+
527+
70. Climbing Stairs
528+
121. Best Time to Buy and Sell Stock
529+
53. Maximum Subarray
530+
198. House Robber
531+
532+
##### Design
533+
534+
384. Shuffle an Array
535+
155. Min Stack
536+
537+
##### Math
538+
539+
412. Fizz Buzz
540+
204. Count Primes
541+
326. Power of Three
542+
13. Roman to Integer
543+
544+
##### Other
545+
546+
191. Number of 1 Bits
547+
461. Hamming Distance
548+
190. Reverse Bits
549+
118. Pascal's Triangle
550+
20. Valid Parentheses
551+
268. Missing Number

0 commit comments

Comments
 (0)