
c/c++
momottyy
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【c/c++数组】复习数组操作
一维数组赋值( a[10]直接赋值:a[10]={1,2,3,...,9};不赋初值:随机值或0全赋同一初值:a[10] = {0}; //或者更推荐用memset函数memset函数:memset(数组名,值,sizeof(数组名));//如:memset(a , 0 , sizeof(a))二维数组(int a[5][6] 直接赋值:a[5][6] = {{},{},{},{},{},{}}...原创 2018-06-13 16:24:17 · 2462 阅读 · 0 评论 -
【c/c++】 leetcode 167. Two Sum II - Input array is sorted (easy)
167. Two Sum II - Input array is sorted (easy) Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The functio...原创 2018-12-11 00:48:30 · 211 阅读 · 0 评论 -
【c/c++】leetcode 35. Search Insert Position(easy)
35. Search Insert Position(easy) Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may ...原创 2018-12-11 00:28:33 · 183 阅读 · 0 评论 -
【c/c++】leetcode 118 & 119 Pascal‘s triangle I & II
1 普通思路 根据定义,用一个vector存前一行的数据,后一行根据前一行计算 存一个二维vec 并返回 //118 class Solution { public: vector<vector<int>> generate(int numRows) { vector<vector<int>> vec; ...原创 2018-12-10 20:01:23 · 179 阅读 · 1 评论 -
【leetcode】120.triangle(c/c++,medium难度)
题目链接 medium Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], ...原创 2018-08-27 14:51:51 · 354 阅读 · 0 评论 -
【leetcode】49. Group Anagrams(c/c++,medium难度)
原题链接 Medium Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"] , Output: [ ["ate","eat","tea"],原创 2018-08-08 10:57:24 · 382 阅读 · 0 评论 -
【leetccode】66. Plus One(c/c++,easy难度)
原题链接 easy Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is at the head of the list, and ...原创 2018-08-03 15:22:02 · 234 阅读 · 0 评论 -
【leetcode】38. Count and Say(c/c++,easy难度)
原题链接 easy The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11.11 ...原创 2018-08-07 17:52:18 · 156 阅读 · 0 评论 -
【leetcode】123. Best Time to Buy and Sell Stock III(c/c++,hard难度)
原题链接 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You ma...原创 2018-08-03 14:03:46 · 865 阅读 · 0 评论 -
【leetcode】122. Best Time to Buy and Sell Stock II (c/c++,easy难度)
原题链接 easy Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (...原创 2018-08-02 15:32:16 · 292 阅读 · 0 评论 -
【leetcode】121. Best Time to Buy and Sell Stock(c/c++,easy难度)
原题链接 easy Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share o...原创 2018-08-02 13:50:08 · 339 阅读 · 0 评论 -
【leetcode】300. Longest Increasing Subsequence(c/c++)
原题链接 Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input:[10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is[2,3...原创 2018-08-01 21:35:27 · 540 阅读 · 0 评论 -
【leetcode】53. Maximum Subarray
原题链接 Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Ex...原创 2018-08-01 14:39:02 · 364 阅读 · 0 评论 -
【c/c++】指针和引用
数组作参(void change(int a[], int b[][5])一维数组可省略长度,二维需写第二维和一般的局部变量不同,数组作参时,在函数中对数组元素的修改就等同于是对原数组的修改。...原创 2018-06-14 15:45:38 · 154 阅读 · 0 评论 -
【python】leetcode 189. Rotate Array (easy)
189. Rotate Array (easy) Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: [1,2,3,4,5,6,7] and k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate...原创 2018-12-11 09:58:50 · 182 阅读 · 0 评论