Leetcode - find-pivot-index

https://leetcode.com/problems/find-pivot-index

Given an array of integers nums, write a method that returns the "pivot" index of this array.

We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index.

If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.

Example 1:

Input: 
nums = [1, 7, 3, 6, 5, 6]
Output: 3
Explanation: 
The sum of the numbers to the left of index 3 (nums[3] = 6) is equal to the sum of numbers to the right of index 3.
Also, 3 is the first index where this occurs.

Leetcode - subarray-sum-equals-k

https://leetcode.com/problems/subarray-sum-equals-k/

Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.

Example 1:

Input:nums = [1,1,1], k = 2
Output: 2

Note:

  1. The length of the array is in range [1, 20,000].
  2. The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7].

Leetcode - 3sum-closest

Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.

Example:

Given array nums = [-1, 2, 1, -4], and target = 1.

The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).

Array- CountTripletsSmallerThanSum

统计数组中总和小于sum的三元组的数量

给定一个没有重复元素的数组,和一个sum值。统计数组中总和小于sum的三元组的数量。

例如对于数组nums[] = {-2, 0, 1, 3},sum = 2,共有2个三元组的总和小于sum:(-2, 0, 1)和(-2, 0, 3)

Leetcode - deepest-leaves-sum

https://leetcode.com/problems/deepest-leaves-sum

Given a binary tree, return the sum of values of its deepest leaves.

Array - Array Rotation

问题:将一个长度为n的数组中的元素右移k个位置。例如当n=5, k=3时:[1, 2, 3, 4, 5] => [3, 4, 5, 1, 2]。

要求O(1)的空间复杂度。

 

搞起一个测试 Golang HTTP server 的性能测试

现在在工作中开始搞 Go 了,重构了一个工具,查了一波如何做性能测试,就当记个笔记。