![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
文章平均质量分 79
fibo_nacci
C/C coder
展开
-
**Leetcode_largest-rectangle-in-histogram(c++ and python version)
地址:http://oj.leetcode.com/problems/largest-rectangle-in-histogram/原创 2014-05-04 11:25:21 · 845 阅读 · 0 评论 -
*Leetcode_binary-tree-maximum-path-sum (updated c++ and python version)
地址:http://oj.leetcode.com/problems/binary-tree-maximum-path-sum/Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be原创 2014-05-14 12:53:33 · 659 阅读 · 0 评论 -
Leetcode_maximum-depth-of-binary-tree (updated c++ and python version)
地址:http://oj.leetcode.com/problems/maximum-depth-of-binary-tree/Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node原创 2014-03-18 10:08:22 · 618 阅读 · 0 评论 -
Leetcode_binary-tree-zigzag-level-order-traversal (updated c++ and python version)
地址:http://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right原创 2014-03-18 23:43:45 · 724 阅读 · 0 评论 -
**Leetcode_copy-list-with-random-pointer (c++ and python version)
地址:http://oj.leetcode.com/problems/copy-list-with-random-pointer/A linked list is given such that each node contains an additional random pointer which could point to any node in the list or nul原创 2014-03-22 22:18:38 · 837 阅读 · 0 评论 -
Leetcode_next-permutation(c++ and python version)
地址:http://oj.leetcode.com/problems/next-permutation/原创 2014-05-09 23:58:16 · 583 阅读 · 0 评论 -
Leetcode_swap-nodes-in-pairs(c++ and python version)
地址:http://oj.leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2-原创 2014-03-17 19:28:30 · 544 阅读 · 0 评论 -
Leetcode_remove-duplicates-from-sorted-array-ii (c++ and python version)
地址:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted arra原创 2014-03-23 13:33:07 · 694 阅读 · 0 评论 -
Leetcode_best-time-to-buy-and-sell-stock(c++ and python version)
地址:http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/Say 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 comple原创 2014-03-31 21:18:23 · 508 阅读 · 0 评论 -
Leetcode_climbing-statirs (c++ and python version)
地址:http://oj.leetcode.com/problems/climbing-stairs/You 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 w原创 2014-03-21 19:24:34 · 548 阅读 · 0 评论 -
Leetcode_sort-colors(c++ and python updated)
地址:http://oj.leetcode.com/problems/sort-colors/Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order re原创 2014-04-02 22:45:27 · 500 阅读 · 0 评论 -
Leetcode_minimum-depth-of-binary-tree (c++ and python version)
地址:http://oj.leetcode.com/problems/minimum-depth-of-binary-tree/Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root nod原创 2014-03-19 11:56:29 · 590 阅读 · 0 评论 -
Leetcode_plus-one(c++ and python updated)
地址:http://oj.leetcode.com/problems/plus-one/Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant d原创 2014-03-21 22:55:29 · 530 阅读 · 0 评论 -
Leetcode_remove-nth-node-from-end-of-list(c++ and python version)
地址:http://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2原创 2014-03-17 18:32:07 · 627 阅读 · 0 评论 -
Leetcode_path-sum (updated c++ and python version)
地址:http://oj.leetcode.com/problems/path-sum/Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo原创 2014-03-23 13:22:32 · 508 阅读 · 0 评论 -
Leetcode_binary-tree-level-order-traversal (updated c++ and python version)
地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal/Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For原创 2014-03-18 23:01:30 · 618 阅读 · 0 评论 -
Leetcode_first-missing-positive (updated c++ and python version)
地址:http://oj.leetcode.com/problems/first-missing-positive/思路:模拟题。用一个足够长的布尔数组来存储。时间复杂度O(N), 空间复杂度都O(k).参考代码:class Solution {public: bool bs[1000000]; int firstMissingPositive(int A[]原创 2014-03-26 14:05:06 · 558 阅读 · 0 评论 -
**Leetcode_median-of-two-sorted-arrays (c++ and python version)
地址:http://oj.leetcode.com/problems/median-of-two-sorted-arrays/There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time comp原创 2014-05-08 20:35:56 · 869 阅读 · 0 评论 -
Leetcode_Maximum Product Subarray(c++ version)
地址:点击打开链接原创 2014-09-28 22:35:05 · 578 阅读 · 0 评论 -
Leetcode_count-and-say(c++ and python version)
地址:http://oj.leetcode.com/problems/count-and-say/The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.原创 2014-04-14 16:42:42 · 638 阅读 · 0 评论 -
Leetcode_flatten-binary-tree-to-linked-list
//http://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \原创 2014-03-25 12:34:59 · 539 阅读 · 0 评论 -
Leetcode_word-break(c++ and python version)
地址:http://oj.leetcode.com/problems/word-break/原创 2014-04-05 22:27:37 · 934 阅读 · 0 评论 -
Leetcode_two-sum (c++ and python version)
地址:http://oj.leetcode.com/problems/two-sum/Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two原创 2014-03-27 01:17:16 · 710 阅读 · 0 评论 -
What is the difference between new and malloc()?
我记不得我曾多少次在网上搜索new 和 malloc 的区别,qian原创 2014-09-07 19:47:51 · 1084 阅读 · 1 评论 -
Leetcode_remove-duplicates-from-sorted-list (updated c++ and python version)
地址:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/ Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1-原创 2014-03-20 22:23:16 · 630 阅读 · 0 评论 -
Leetcode_multiply-strings (updated c++ and python version)
地址:http://oj.leetcode.com/problems/multiply-strings/Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and原创 2014-05-05 14:59:14 · 610 阅读 · 0 评论 -
Leetcode_unique-paths-ii
地址:http://oj.leetcode.com/problems/unique-paths-ii/Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and原创 2014-03-26 17:27:18 · 536 阅读 · 0 评论 -
Leetcode_pascals-triangle (updated c++ and python version)
地址:http://oj.leetcode.com/problems/pascals-triangle/Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2原创 2014-03-22 09:50:55 · 429 阅读 · 0 评论 -
Leetcode_unique-paths (updated c++ and python version)
地址:http://oj.leetcode.com/problems/unique-paths/A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right a原创 2014-03-23 00:55:24 · 558 阅读 · 0 评论 -
Leetcode_search-in-rotated-sorted-array-ii(updated c++ and python version)
地址:http://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity原创 2014-05-10 11:10:03 · 777 阅读 · 0 评论 -
Leetcode_candy
地址:http://oj.leetcode.com/problems/candy/There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following re原创 2014-04-10 10:11:20 · 502 阅读 · 0 评论 -
Leetcode_search-for-a-range
http://oj.leetcode.com/problems/search-for-a-range/Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in原创 2014-03-25 15:47:04 · 534 阅读 · 0 评论 -
Leetcode_pascals-triangle-ii (updated c++ and python version)
地址:http://oj.leetcode.com/problems/pascals-triangle-ii/Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your原创 2014-03-24 16:21:16 · 595 阅读 · 0 评论 -
Leetcode_wildcard-matching(c++ and python version)
地址:http://oj.leetcode.com/problems/wildcard-matching/原创 2014-04-10 22:17:37 · 748 阅读 · 4 评论 -
Leetcode_permutation-sequence(c++ and python version)
地址:http://oj.leetcode.com/problems/permutation-sequence/原创 2014-05-08 23:31:32 · 623 阅读 · 0 评论 -
Leetcode_best-time-to-buy-and-sell-stock-ii(c++ and python version)
地址: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/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原创 2014-03-31 21:58:20 · 680 阅读 · 0 评论 -
Leetcode_powx-n(c++ and python version)
地址:http://oj.leetcode.com/problems/powx-n/Implement pow(x, n).s原创 2014-04-25 11:22:18 · 613 阅读 · 0 评论 -
编程小题
列几个最近遇到的笔试题,不完全一样,可能是题目的一部分或者bianxing原创 2014-04-11 22:58:12 · 451 阅读 · 0 评论 -
PAT 3-05. 求链式线性表的倒数第K项
题目地址:http://pat.zju.edu.cn/contests/ds/3-05用vector有一个case超时,用list 顺利通过#include#includeusing namespace std;int main(){ int K, num; list vec; scanf("%d", &K); while(sc原创 2013-10-10 11:34:30 · 910 阅读 · 0 评论 -
pat advanced 1071 Speech Patterns
题目地址: http://pat.zju.edu.cn/contests/pat-a-practise/1071思路比较简单,用map来记录,map默认是按字典序的。但是前几次有两个case TLE了,有可能是用strtok耗时比较长。先贴一个AC的,用c++的getline来换取一行。#include#include#include#include#include原创 2014-01-29 18:07:44 · 631 阅读 · 0 评论