C++
panzw2015
求知,心得体会
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
微软2017校招第一题
解题思路是采用递归,跳出条件是:两两相加不再是奇数。 附上代码: #include #include using namespace std; class Solution { public: int minleng(vector &num,int n) { vector ret = myCount(num,n); return ret.s原创 2016-10-10 20:58:58 · 654 阅读 · 2 评论 -
108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 给定一个数组,数组中的元素是升序排好的,将它转换为高度平衡二叉检索树。 高度平衡二叉检索树:任意两子树之间的深度之差不大于1. 思路:类似于二分查找法,nums的中间元素(mid)为根节点,0~mi原创 2016-11-26 19:32:57 · 226 阅读 · 0 评论 -
216. Combination Sum III 递归的使用
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Example 1: Inpu原创 2016-11-25 21:07:36 · 306 阅读 · 0 评论 -
378 Kth Smallest Element in a Sorted Matrix
给定一个每一行每一列都排好序的矩阵,求其中第k大的元素 我直接暴力解法,居然被AC了!!!!!! class Solution { public: int kthSmallest(vector>& matrix, int k) { int n = matrix.size(); vector ret; for(int i=0;i<n;i++原创 2016-11-16 20:08:27 · 258 阅读 · 0 评论 -
394. Decode String
Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is原创 2016-11-28 21:18:53 · 301 阅读 · 0 评论 -
2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link原创 2016-10-31 19:40:19 · 273 阅读 · 0 评论 -
leetcode: 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. 判断一个整数是不是“回文”。 思路:将整数反转,然后判断两者是否相等。 附上代码: #include #include using namespace std; class Solution { public:原创 2016-10-03 20:04:58 · 294 阅读 · 0 评论 -
46. Permutations
Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1原创 2016-11-07 20:04:09 · 250 阅读 · 0 评论 -
43. Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative.Converting the input string to integ原创 2016-11-07 16:50:53 · 240 阅读 · 0 评论 -
今日头条2017校招笔试题
一些出题人出了n道题,每道题有一个难度系数,难度系数满足以下关系的3道题可以组成一套试卷,为了使这n道题使用上且只能使用一次,问出题人最少还要出多少题? a b-a c-b 直接附上代码: #include #include using namespace std; class Solution { public: int myCount(vector &a,int原创 2016-09-24 10:54:37 · 5744 阅读 · 1 评论 -
Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthe
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ "((()))", "(()())", "(())()", "()(())转载 2016-11-03 21:19:37 · 1640 阅读 · 0 评论 -
58. Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is原创 2016-10-12 19:32:27 · 245 阅读 · 0 评论 -
leetcode:3Sum问题
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. For example, given array S = [-1, 0原创 2016-09-26 20:04:44 · 292 阅读 · 0 评论
分享