- 博客(21)
- 资源 (2)
- 收藏
- 关注
原创 C++ 求排列组合
在笔试面试中经常会遇到求排列组合的题目(或者需求),现在将它们做一个总结。 1.排列数公式与组合数公式 2.思路 参考程序员面试宝典P112,求9位数能被整除的问题(具体请自己去看书),实际上的思路就是利用一个bool型数组记录被占用的位置,DFS求解。这里想指出STL有next_permutation方法。 vector<string> res; void dfs(...
2018-09-03 23:35:05
4657
原创 114. Flatten Binary Tree to Linked List
class Solution { public: void Core(TreeNode* root) { int flag = 0; if (root->left != NULL && (root->left->left != NULL || root->left->right != NULL)) Core(root->lef...
2018-09-01 20:36:07
188
原创 数组指针试题
#include<iostream> using namespace std; int main() { int data[][3] = { 10,20,30,40,50,60 }; int(*p)[3]; p = data; cout << p[0][0] << "," << *(p[0] + 1) << "," &a
2018-08-31 20:11:34
325
原创 149. Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Example 1: Input: [[1,1],[2,2],[3,3]] Output: 3 Explanation: ^ | | o | o | o +-----...
2018-08-30 16:29:00
164
原创 143. Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes itself may be changed. Example 1: Given 1->2-...
2018-08-30 11:23:19
128
原创 148. Sort List
Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1-...
2018-08-28 17:55:08
146
原创 c++虚函数表探究(2018.9.18更新)
2018.9.18更新 关于虚继承的sizeof问题 #include <iostream> #include <vector> #include <string.h> #include <stdio.h> using namespace std; class A { public: char a[4]; virtual void aa()...
2018-08-25 18:14:21
312
原创 一道很有意思的C++面试题
原题目为《程序员面试宝典》第7章面试题9: struct S{ int i; int *p; }; main() { S s; int *p =&s.i; p[0] = 4; p[1] = 3; s.p = p; s.p[1] = 1; s.p[0] = 2; } 问程序会在哪一行崩溃? 第一次做这道题时我崩溃...
2018-08-18 23:57:00
293
原创 438. Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be larger ...
2018-06-09 11:33:01
195
原创 543. Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n...
2018-06-09 10:47:39
222
原创 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 guara...
2018-06-09 10:27:43
188
原创 338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5 you sho...
2018-06-04 10:38:51
160
原创 315. Count of Smaller Numbers After Self
You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].Example:Input...
2018-06-04 10:12:59
265
原创 538. Convert BST to Greater Tree
Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.Example:...
2018-06-04 09:20:39
142
原创 11. 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-06-01 17:58:07
200
原创 DP基本问题总结(2018.5.29 2018.6.9 2018.8.9更新)
参考文献: 【1】https://segmentfault.com/a/1190000006325321 【2】https://blog.youkuaiyun.com/q623702748/article/details/51297949 一晃就过去了两个月,提前退出了网易游戏的实习,前途未卜。但不管怎么样,生活还是要继续。DP问题还是在笔试里考得多些,还要记录笔试DP的题目。 网易笔试:合唱团:ht...
2018-05-30 11:15:56
973
原创 312. Burst Balloons
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[le...
2018-05-29 11:56:48
244
原创 124. Binary Tree Maximum Path Sum
Given a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections...
2018-05-27 22:02:46
405
原创 102. Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (i.e, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / ...
2018-05-26 11:25:54
139
原创 94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,3,2]Follow up: Recursive solution is trivial, could you do i...
2018-05-25 22:30:02
183
原创 309. Best Time to Buy and Sell Stock with Cooldown
题目如下: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 (ie, buy o...
2018-05-24 22:35:15
144
【Andrea Goldsmith】无线通信
2018-01-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅