
C++
文章平均质量分 72
Kelly Fu
这个作者很懒,什么都没留下…
展开
-
Score of Parentheses(856)
856— Score of ParenthesesGiven a balanced parentheses string S, compute the score of the string based on the following rule:“()” has score 1“AB” has score A + B, where A and B are balanced parenth...原创 2018-12-19 21:24:00 · 204 阅读 · 0 评论 -
C++ 常用
输入输出#include <iostream>using namespace std;int main(int argc, char const *argv[]){ /*c*/ printf("%d\n", 'A'); printf("%u\n", 'A'); //无正负10进制 printf("%o\n", 'A'); //无正负8进制 printf(...原创 2019-01-15 09:38:10 · 199 阅读 · 0 评论 -
C++ STL使用方法
Algorithm参考: https://blog.youkuaiyun.com/yo_bc/article/details/53337839#include <iostream>#include <cstdio>#include <algorithm>using namespace std;void print(int &elem){ //有无&...原创 2019-01-15 00:21:48 · 420 阅读 · 0 评论 -
排序算法(插入、希尔、选择、冒泡、归并, 快速)
排序算法常见的排序算法内部排序插入查找希尔排序选择排序冒泡排序归并排序快速排序外部排序1. 插入排序思路插入已经排好序的前面部分, 相当于在前面排好序的部分进行search.复杂度分析:最好情况: O(n)最差情况: O(n2n^2n2)平均情况: O(n2n^2n2)代码:void insertSort(int *arr...原创 2019-01-08 01:44:02 · 305 阅读 · 0 评论 -
Maximum Subarray(53) - easy
53— Maximum SubarrayGiven an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example1:Input: [-2,1,-3,4,-1,2,1,-5,4]...原创 2019-01-11 00:58:33 · 333 阅读 · 0 评论 -
House Robber(198) - easy
198— House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is ...原创 2019-01-10 21:48:28 · 152 阅读 · 0 评论 -
Best Time to Buy and Sell Stock(121) - easy
121— Best Time to Buy and Sell StockSay 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 ...原创 2019-01-10 20:09:56 · 119 阅读 · 0 评论 -
Climbing Stairs(70) - easy
70— Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n ...原创 2019-01-10 16:23:49 · 240 阅读 · 0 评论 -
Add Two Numbers(2)
2— Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two n...原创 2018-12-24 14:51:17 · 123 阅读 · 0 评论 -
搜索算法(顺序、二分、索引)
搜索算法平均查找长度ASLASL=P1C1+P2C2+...+PnCnASL = P_{1}C_{1} + P_{2}C_{2} + ...+ P_{n}C_{n}ASL=P1C1+P2C2+...+PnCnP_{n}: 查找第n个元素的概率C_{n}:查找第n个元素的比较次数常见的查询算法顺序查找二分查找索引查找哈希查找1. 顺序查找复杂度分析:...原创 2018-12-29 12:55:45 · 502 阅读 · 0 评论 -
Task Scheduler(621)
621— Task SchedulerGiven a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original ord...原创 2018-12-27 20:55:13 · 147 阅读 · 0 评论 -
Min Stack(155)
155— Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack....原创 2018-12-26 22:33:26 · 106 阅读 · 0 评论 -
Valid Parentheses(20)
20— Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed ...原创 2018-12-26 21:35:09 · 89 阅读 · 0 评论 -
Decode String(394)
394— Decode StringGiven 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. ...原创 2018-12-26 21:00:18 · 187 阅读 · 0 评论 -
Permutations(46)
46— PermutationsGiven a collection of distinct integers, return all possible permutations.Example 1:Input: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]C++代码:class So...原创 2018-12-20 18:02:35 · 202 阅读 · 0 评论 -
Letter Case Permutation(784)
784— Letter Case PermutationGiven a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create....原创 2018-12-20 11:48:49 · 159 阅读 · 0 评论 -
二叉树(性质、存储、遍历、建立)
二叉树性质二叉树第i层叶子数最多为2i−12^{i-1}2i−1深度为i的二叉树的节点数最多为 2i−12^{i}-12i−1在二叉树中, 叶子数为n0n_{0}n0, 度为2的节点数为n2n_{2}n2, 则满足 :n0=n2+1n_{0} = n_{2}+1n0=n2+1 证明: n0+n1+n2=n0∗0+n1∗1+n2∗2+1n_{0} + n_{1} + n_{2} =...原创 2019-01-09 18:01:27 · 303 阅读 · 0 评论