剑指Offer——全排列递归思路_0_10_全排列 剑指offer,web开发基本步骤

33 阅读2分钟

最后

本人分享一下这次字节跳动、美团、头条等大厂的面试真题涉及到的知识点,以及我个人的学习方法、学习路线等,当然也整理了一些学习文档资料出来是给大家的。知识点涉及比较全面,包括但不限于前端基础,HTML,CSS,JavaScript,Vue,ES6,HTTP,浏览器,算法等等

前端视频资料: 开源分享:docs.qq.com/doc/DSmRnRG…

      我们可以看到,这里的孩子个数是递减的,直到最后一个元素,就不用选择了,同时也得到一种可能。

      要枚举出所有的,那么就遍历这样一颗树。好了,先上代码。

 

package cn.edu.ujn.nk;
 
public class FullPermutation {
/**
     * recursive method, used for the tree traversal.
     *  
     * @param inStr
     *            the elements need to be choose
     * @param pos
     *            the position of the elements we choose
     * @param parentData
     *            the elements have been chosen
     */  
    public void permutation(String inStr, int pos, StringBuffer parentData) {  
        if (inStr.length() == 0) {
            return;
        }
        if (inStr.length() == 1) {
            System.out.println("{" + inStr + "}");
            return;
        }
        // here we need a new buffer to avoid to pollute the other nodes.
        StringBuffer buffer = new StringBuffer();
        // copy from the parent node
        buffer.append(parentData.toString());
  
        // choose the element
        buffer.append(inStr.charAt(pos));
  
        // get the remnant elements.  
        String subStr = kickChar(inStr, pos);  
  
        // got one of the result  
        if (subStr.length() == 1) {  
            buffer.append(subStr);  
            System.out.println(buffer.toString());  
            return;  
        }  
  
        // here we use loop to choose other children.  
        for (int i = 0; i < subStr.length(); i++) {  
            permutation(subStr, i, buffer);  
        }  
  
    }  
  
    // a simple method to delete the element we choose  
    private String kickChar(String src, int pos) {  
        StringBuffer srcBuf = new StringBuffer();  
        srcBuf.append(src);  
        srcBuf.deleteCharAt(pos);  
        return srcBuf.toString();  
    }  
    
    public static void main(String args[]) {  
        FullPermutation p = new FullPermutation();
        StringBuffer buffer = new StringBuffer();
        String input = "ABCD";
        for (int i = 0; i < input.length(); i++) {  
            p.permutation(input, i, buffer);  
        }  
    }  
}

 

美文美图

React

  • 介绍一下react

  • React单项数据流

  • react生命周期函数和react组件的生命周期

  • react和Vue的原理,区别,亮点,作用

  • reactJs的组件交流

  • 有了解过react的虚拟DOM吗,虚拟DOM是怎么对比的呢

  • 项目里用到了react,为什么要选择react,react有哪些好处

  • 怎么获取真正的dom

  • 选择react的原因

  • react的生命周期函数

  • setState之后的流程

  • react高阶组件知道吗?

  • React的jsx,函数式编程

  • react的组件是通过什么去判断是否刷新的

  • 如何配置React-Router

  • 路由的动态加载模块

  • Redux中间件是什么东西,接受几个参数

  • redux请求中间件如何处理并发

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】