摘要: You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose o 阅读全文
posted @ 2020-02-06 22:24 强威 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input 阅读全文
posted @ 2020-02-06 13:15 强威 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: 阅读全文
posted @ 2020-02-04 20:57 强威 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1.形如 T(n) = a * T(n/b) + f(n) 的时间复杂度计算方法 有一种方法叫做主方法(Master method)是用来专门计算这种形式的时间复杂度的,方法具体如下: 下边举例进行说明: 例1: T(n) = 25*T(n/5) + n^2 因为:a=25,b=5,d=2,f(n) 阅读全文
posted @ 2019-12-22 16:41 强威 阅读(2790) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-12-05 20:22 强威 阅读(271) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: Given a matrix of m x n elements (m r 阅读全文
posted @ 2019-12-04 21:35 强威 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文
posted @ 2019-12-04 21:30 强威 阅读(255) 评论(0) 推荐(0) 编辑
摘要: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Foll 阅读全文
posted @ 2019-11-27 09:44 强威 阅读(206) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int trap(vector<int>& height) { int l = 0, r = height.size()-1, level = 0, water = 0; while (l < r) { int lower = height[height[l] < height[r] ? l++ : r--]; level = max(level, 阅读全文
posted @ 2019-11-26 20:20 强威 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 1.顺时针: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place 阅读全文
posted @ 2019-11-26 20:18 强威 阅读(288) 评论(0) 推荐(0) 编辑