摘要:
各种情况。有恶心的负数最值,用long long来做了。除此之外的情况下面都列出来了。/*1, 8 = 0.1251, 6 = 0.1(6)-50, 6 = -6.250, -3 = 0-1, -2147483648 = "0.0000000004656612873077392578125"*/ty... 阅读全文
摘要:
这道题,其实不简单。知道是26进制,怎么能够找规律找到+-1的位置呢?思路是去找 比如,AAB到AB的表达式的不变的地方,找到递推式。class Solution {public: string convertToTitle(int n) { string result; ... 阅读全文
摘要:
黑帮火并简单版。多个数的有另一篇文章。class Solution {public: int majorityElement(vector &num) { int size = num.size(); int major = 0; int count ... 阅读全文
摘要:
本质是26进制,注意每次+1.class Solution {public: int titleToNumber(string s) { int size = s.size(); int num = 0; for (int i = 0; i < siz... 阅读全文
摘要:
老题,简单题。数5的个数就行了。class Solution {public: int trailingZeroes(int n) { int result = 0; while (n > 0) { result += n / 5; ... 阅读全文
摘要:
使用栈来记录可能的路径,栈顶一直是下一个元素。 class BSTIterator { public: stack<TreeNode *> path; BSTIterator(TreeNode *root) { path = stack<TreeNode *>(); TreeNode *node = 阅读全文