用户中心USER CENTER

首页/用户
  • [LintCode] Permutation in String

    Problem Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first strings permutations is the substring of the second string. ...

    wenshi11019 发布于Java
  • LRU & LFU Cache

    摘要:首先要做到是,能想到的数据结构只有两三种,一个是,一个是,是,还有一个,是。不太可能,因为长度要而且不可变,题目也没说长度固定。可以做到和都是。因为还有函数,要可以,所以还需要一个数据结构来记录顺序,自然想到。 LRU Cache 题目链接:https://leetcode.com/problems... 这个题要求O(1)的复杂度。首先要做到get(key)是O(1),能想到的数据结...

    wenshi11019 发布于Java
  • Construct Binary Tree from Traversal

    摘要:思路在的顺序里,先,然后再左右。所以根据可以知道的。接着再分别在和的里面重复找以及左右的过程。首先的包括和,以及对应的起始和结束位置,对应的起始和结束位置。返回值为,因为每个里要一个,同时找到它的和,左右节点通过返回值获得。同时的不需要了。 From Preorder and Inorder 思路在preorder的顺序里,先root,然后再左右。所以根据preorder可以知道roo...

    wenshi11019 发布于Java
  • 【面试算法】由两个栈组成的队列

    摘要:题目编写一个类,用两个栈实现队列,支持队列的基本操作,,代码实现 【题目】编写一个类,用两个栈实现队列,支持队列的基本操作(add,poll,peek) 代码实现 public class TwoStacksQueue { private Stack stackPush; private Stack stackPop; public TwoStacksQue...

    wenshi11019 发布于Java
  • 遍历Map的四种方法

    摘要:第一种普遍使用,二次取值通过遍历和第二种通过使用遍历和第三种推荐,尤其是容量大时通过遍历和第四种通过遍历所有的,但不能遍历 public static void main(String[] args) { Map map = new HashMap(); map.put(1, value1); map.put(2, value2); map.put(3,...

    wenshi11019 发布于Java
<