随笔分类 -  cpp刷Leetcode

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

第一遍刷完leetcode,过程非常纠结。 第二遍再过leetcode,看看自己能记得多少,顺便加深印象。
摘要:题目: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 承续缘 阅读(290) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(206) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(199) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(324) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(210) 评论(0) 推荐(0)

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

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

摘要:题目: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 承续缘 阅读(233) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(265) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(295) 评论(0) 推荐(0)

摘要:题目:第一次刷的时候漏掉了这道题。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 承续缘 阅读(164) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(205) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(207) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(305) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(201) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(171) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(281) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(169) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(185) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(240) 评论(0) 推荐(0)

摘要:题目: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 承续缘 阅读(199) 评论(0) 推荐(0)

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

导航