![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
静心观复
这个作者很懒,什么都没留下…
展开
-
Linked List Cycle
Leetcode:141. Linked List CycleMethod1/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * ne...原创 2019-12-19 17:00:11 · 98 阅读 · 0 评论 -
Valid Parentheses
Leetcode:20.Valid Parenthesesclass Solution { private HashMap<Character,Character> hashmap; { hashmap = new HashMap(); hashmap.put(')','('); hashmap.put('}','{'); hash...原创 2019-12-10 13:39:55 · 69 阅读 · 0 评论 -
Remove Nth Node From End of List
Problem solving ideasFirst we will add a dummy node as an auxiliary, which is located at the head of the list. Dumb nodes are used to simplify some extreme cases, such as the list contains only one ...原创 2019-12-10 11:14:26 · 81 阅读 · 0 评论 -
Find the maximum element in an array which is first increasing and then decreasing
Examples :Input: arr[] = {1, 3, 50, 10, 9, 7, 6}Output: 50Method 1 (Linear Search)public class FindMaximum { static int findMaximum(int arr[], int low, int high) { int max = arr[low];...原创 2019-12-06 14:28:34 · 189 阅读 · 0 评论 -
Ugly Number
leetcode(264. Ugly Number II)method 1(Use Dynamic Programming)public class UglyNumber{ public static int nthUglyNumber(int n) { int[] dp = new int[n]; dp[0] = 1; int i...原创 2019-12-05 09:45:56 · 84 阅读 · 0 评论 -
Binary Tree Level Order Traversal
single line and multi line printpublic class LevelOrderTraversal { public static class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public...原创 2019-12-04 14:59:44 · 92 阅读 · 0 评论 -
Java Program for Fibonacci numbers
Use recursion Programmingclass Fibonacci { static int fib(int n) { if (n <= 1) return n; return fib(n-1) + fib(n-2); } } Use memory searchclass Fibonacci { ...原创 2019-11-14 14:05:46 · 99 阅读 · 0 评论 -
Fibonacci Sequence
overviewFibonacci numbers are used to create technical indicators using a mathematical sequence developed by the Italian mathematician, commonly referred to as “Fibonacci,” in the 13th century. The s...原创 2019-11-14 10:53:21 · 485 阅读 · 0 评论