array
我真的不会Coding
任何时候努力都不晚,要保持自信
展开
-
leetcode41. First Missing Positive
Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Ou...原创 2018-07-16 15:57:48 · 150 阅读 · 0 评论 -
leetcode45. Jump Game II&&55. Jump Game
Jump GameGiven 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.Dete...转载 2018-07-18 11:02:18 · 308 阅读 · 0 评论 -
leetcode 54 Spiral Matrix&&LeetCode 59. Spiral Matrix II (螺旋矩阵之二)
leetcode 54 Spiral Matrix Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]O...原创 2018-07-20 09:58:25 · 98 阅读 · 0 评论 -
leetcode11. Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two ...原创 2018-07-15 16:53:32 · 117 阅读 · 0 评论 -
leetcode18. 4Sum
Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of tar...转载 2018-07-16 10:13:20 · 149 阅读 · 0 评论 -
leetcode2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...转载 2018-07-23 09:52:44 · 86 阅读 · 0 评论 -
leetcode7. Reverse Integer整数反转
Given a 32-bit signed integer, reverse digits of an integer.Difficulty:EasyExample 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:A...原创 2018-08-01 15:34:32 · 114 阅读 · 0 评论 -
二进制中1的个数
问题描述;给定一个整数,包含正数和负数,输出该数二进制中1的个数三种方法:1优化方法public int NumberOf1(int n) { int count = 0; while (n != 0) { ++count; n = (n - 1) & n; } ...原创 2018-08-14 16:51:25 · 115 阅读 · 0 评论 -
奇数位于偶数的前半部分
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。 //两个思路吧,第一个思路:类似冒泡算法,前偶后奇数就交换: class Solution {public: void reOrderArray(vector<int> &array)...原创 2018-08-15 14:16:22 · 254 阅读 · 0 评论