1102 Invert a Binary Tree

The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a


1103 Integer Factorization

The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program t


1101 Quick Sort

There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then th


1105 Spiral Matrix

This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the fi


1104 Sum of Number Segments

Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we


1106 Lowest Price in Supply Chain

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer


跨域的几种主要解决方法以及过程

跨域的主要解决方式:JSONP,CORS(即加上CORS 请求头(诸如 Access-Control-Allow-Origin 等配置)),代理(Webpack代理,ngnix反向代理)。当然不止前面四种,还有其他一些这里就限于篇幅不提到了,可以参考网络上其他博客。 其中 两种代理的解决办法可以看另


使用setInterval模拟setTimeout

使用setInterval模拟setTimeout: 执行一次setInterval然后清除即可 function mySetTimeout(fn, t){ let timer = setInterval(()=>{ fn(); clearInterval(t


使用代理解决跨域的方式分析

1、代理为什么能解决跨域问题 代理就是一个服务,该服务的作用就是:监测本地的接口,当接口为需要访问外网的接口时,代理替你访问这个接口并把返回值返回给当前网页。 并不是网页服务访问代理,而是代理检测网页服务内部的接口服务,当符合条件的服务出现的时候,代理拦截住,并替代网页服务返回结果 2.webpac