
leetcode
Enpong
我是小小白
展开
-
LeetCode869---重新排序得到2的幂
原创 2019-03-02 12:54:18 · 826 阅读 · 0 评论 -
Leetcode---208.实现Trie前缀树
Java非递归版class Trie { private class Node{ boolean isTrie; Map<Character, Node> children = new HashMap<>(); } private Node root = new Node(); /** Initia...原创 2019-03-02 17:59:11 · 618 阅读 · 0 评论 -
leetcode---二分查找
//二分查找基本实现public int binarySearch(int[] nums, int key){ int l = 0, h = nums.length-1; while(l<=h){ int mid = l+(h-l)/2; //防止(h+l)/2加法溢出 if(nums[mid]==key) return mid; else if(nums[mid]...原创 2019-03-22 15:10:34 · 362 阅读 · 0 评论 -
leetcode---241. 为运算表达式设计优先级
回溯搜索。该问题牵涉到括号的组合问题,一般使用递归+回溯的思想。主要想法:递归回溯。可以产生所有的组合方式。每个小组合方式相当于一个子集,不断的将计算结果返回给上一层。举例:a + (b - (c * d))会不断的变成a + (b - (res1 * res2))-> a + (res1 - res2) -> res1 + res2计算结果需要for循环!!!其实有这种情...原创 2019-03-22 15:39:51 · 244 阅读 · 0 评论