随笔分类 -  cpp刷Leetcode

1 2 3 4 5 ··· 8 下一页

第一遍刷完leetcode,过程非常纠结。 第二遍再过leetcode,看看自己能记得多少,顺便加深印象。
【Power of Two】cpp
摘要:题目:Given an integer, write a function to determine if it is a power of two.代码:class Solution {public: bool isPowerOfTwo(int n) { if ( n>... 阅读全文

posted @ 2015-07-22 07:23 承续缘 阅读(281) 评论(0) 推荐(0) 编辑

【Binary Search Tree Iterator 】cpp
摘要:题目:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the n... 阅读全文

posted @ 2015-07-14 19:25 承续缘 阅读(201) 评论(0) 推荐(0) 编辑

【Binary Tree Right Side View 】cpp
摘要:题目:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exa... 阅读全文

posted @ 2015-07-14 18:39 承续缘 阅读(190) 评论(0) 推荐(0) 编辑

【Count Complete Tree Nodes】cpp
摘要:题目:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, exc... 阅读全文

posted @ 2015-07-14 17:25 承续缘 阅读(314) 评论(0) 推荐(0) 编辑

【Kth Smallest Element in a BST 】cpp
摘要:题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t... 阅读全文

posted @ 2015-07-14 13:00 承续缘 阅读(198) 评论(0) 推荐(0) 编辑

【Invert Binary Tree】cpp
摘要:题目:Invert Binary TreeTotal Accepted:20346Total Submissions:57084My SubmissionsQuestionSolutionInvert a binary tree. 4 / \ 2 7 / \ / \1 ... 阅读全文

posted @ 2015-07-14 12:48 承续缘 阅读(221) 评论(0) 推荐(0) 编辑

【Lowest Common Ancestor of a Binary Search Tree】cpp
摘要:题目:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedi... 阅读全文

posted @ 2015-07-14 12:35 承续缘 阅读(219) 评论(0) 推荐(0) 编辑

【Lowest Common Ancestor of a Binary Tree】cpp
摘要:题目:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowe... 阅读全文

posted @ 2015-07-14 10:55 承续缘 阅读(250) 评论(0) 推荐(0) 编辑

【Balanced Binary Tree】cpp
摘要:题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the de... 阅读全文

posted @ 2015-07-12 14:17 承续缘 阅读(286) 评论(0) 推荐(0) 编辑

【Remove Duplicates from Sorted List 】cpp
摘要:题目:第一次刷的时候漏掉了这道题。Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1-... 阅读全文

posted @ 2015-06-27 22:15 承续缘 阅读(155) 评论(0) 推荐(0) 编辑

【Max Points on a Line 】cpp
摘要:题目:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.代码:/** * Definition for a point. * struct Point { ... 阅读全文

posted @ 2015-06-09 23:46 承续缘 阅读(185) 评论(0) 推荐(0) 编辑

【Text Justification】cpp
摘要:题目:Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You shoul... 阅读全文

posted @ 2015-06-09 22:43 承续缘 阅读(196) 评论(0) 推荐(0) 编辑

【Divided Two】cpp
摘要:题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.代码:class Solution {public: int div... 阅读全文

posted @ 2015-06-09 15:23 承续缘 阅读(291) 评论(0) 推荐(0) 编辑

【ZigZag Conversion】cpp
摘要:题目:The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font... 阅读全文

posted @ 2015-06-09 09:54 承续缘 阅读(194) 评论(0) 推荐(0) 编辑

【Spiral Matrix II】cpp
摘要:题目:Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following ma... 阅读全文

posted @ 2015-06-09 08:21 承续缘 阅读(160) 评论(0) 推荐(0) 编辑

【Spiral Matrix】cpp
摘要:题目:Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3... 阅读全文

posted @ 2015-06-09 07:54 承续缘 阅读(267) 评论(0) 推荐(0) 编辑

【Pascal's Triangle II 】cpp
摘要:题目:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onl... 阅读全文

posted @ 2015-06-08 23:28 承续缘 阅读(157) 评论(0) 推荐(0) 编辑

【Pascal's Triangle】cpp
摘要:题目:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4... 阅读全文

posted @ 2015-06-08 23:14 承续缘 阅读(178) 评论(0) 推荐(0) 编辑

【Substring with Concatenation of All Words】cpp
摘要:题目:You are given a string,s, and a list of words,words, that are all of the same length. Find all starting indices of substring(s) insthat is a concat... 阅读全文

posted @ 2015-06-08 22:59 承续缘 阅读(227) 评论(0) 推荐(0) 编辑

【Multiply Strings】cpp
摘要:题目:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-n... 阅读全文

posted @ 2015-06-08 17:00 承续缘 阅读(188) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 8 下一页

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示