Jump Game

This is No.55 in leetcode. The problem description is: "Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index." Here are 4 approaches to the …

Combination Sum

This is a problem in leetcode. To solve this problem, I decide to use recursion on it: class Solution { public List<List<Integer>> combinationSum(int[] candidates, int target) { List<List<Integer>> res = new ArrayList<List<Integer>>(); List<Integer> rec = new ArrayList<Integer>(); search( candidates, target, res, rec, 0); return res; } private void search(int[] arr, int tar, List<List<Integer>>res, List<Integer>rec, int …

What is call-back function

What is call back function: Simply put: A callback is a function that is to be executed after another function has finished executing — hence the name ‘call back’. More complexly put: In JavaScript, functions are objects. Because of this, functions can take functions as arguments, and can be returned by other functions. Functions that …

What does “let that = this” mean in Javascript/Typescript?

For example, let person = { name:"bill", speak:function(){ console.log("hi i am "+this.name) } } Functions has something called a context. A context is the object the function is being called on. if you were to do person.speak(), it will be called on the object that was defined. The variable person is the context. So when …

What is AJAX

What is AJAX AJAX is not a programming language. AJAX is a technique for accessing web servers from a web page. AJAX stands for Asynchronous JavaScript And XML. Here is an example of AJAX: How AJAX works

How to build navigator of video website in Wechat mini program

Here are some bilibili interface: 首页导航:http://mock-api.com/mnEe4VnJ.mock/navList 轮播图:http://mock-api.com/mnEe4VnJ.mock/swiperList 视频列表:http://mock-api.com/mnEe4VnJ.mock/videoList 视频详情:http://mock-api.com/mnEe4VnJ.mock/videoDetail 推荐视频:http://mock-api.com/mnEe4VnJ.mock/otherList 评论列表:http://mock-api.com/mnEe4VnJ.mock/commentList We can use postman to test the first one (navList): And good job this interface works. Then we should use code in index.js: data: { // 首页导航数据 navList:[] }, If the url we use is not allowed, we need to check this from setting …

Number of 1 Bits

This is No.191 in LeetCode. This is the best solution I think, easy to understand and has a straight logic: public class Solution { // you need to treat n as an unsigned value public int hammingWeight(int n) { int num_one = 0; //001000000010001 while( n > 0 ){ // 00010011 & 00000001 num_one += …