![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
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 · 2398 阅读 · 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 · 173 阅读 · 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 · 141 阅读 · 0 评论 -
【c/c++】leetcode 118 & 119 Pascal‘s triangle I & II
1 普通思路根据定义,用一个vector存前一行的数据,后一行根据前一行计算 存一个二维vec 并返回//118class Solution {public: vector<vector<int>> generate(int numRows) { vector<vector<int>> vec; ...原创 2018-12-10 20:01:23 · 130 阅读 · 1 评论 -
【leetcode】120.triangle(c/c++,medium难度)
题目链接 mediumGiven 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 · 273 阅读 · 0 评论 -
【leetcode】49. Group Anagrams(c/c++,medium难度)
原题链接 MediumGiven 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 · 306 阅读 · 0 评论 -
【leetccode】66. Plus One(c/c++,easy难度)
原题链接 easyGiven 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 · 192 阅读 · 0 评论 -
【leetcode】38. Count and Say(c/c++,easy难度)
原题链接 easyThe count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 ...原创 2018-08-07 17:52:18 · 121 阅读 · 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 · 798 阅读 · 0 评论 -
【leetcode】122. Best Time to Buy and Sell Stock II (c/c++,easy难度)
原题链接 easySay 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 · 157 阅读 · 0 评论 -
【leetcode】121. Best Time to Buy and Sell Stock(c/c++,easy难度)
原题链接 easySay 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 · 288 阅读 · 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: 4Explanation: The longest increasing subsequence is[2,3...原创 2018-08-01 21:35:27 · 473 阅读 · 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: 6Ex...原创 2018-08-01 14:39:02 · 186 阅读 · 0 评论 -
【c/c++】指针和引用
数组作参(void change(int a[], int b[][5])一维数组可省略长度,二维需写第二维和一般的局部变量不同,数组作参时,在函数中对数组元素的修改就等同于是对原数组的修改。...原创 2018-06-14 15:45:38 · 114 阅读 · 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 = 3Output: [5,6,7,1,2,3,4]Explanation:rotate...原创 2018-12-11 09:58:50 · 135 阅读 · 0 评论