2016年3月15日

最大子序列-NlogN

摘要: //分治#includeusing namespace std;int MaxSubSum(int A[], int Left, int Right){ int MaxLeftSum, MaxRightSum; int MaxLeftBorderSum, MaxRightBorderSum; ... 阅读全文

posted @ 2016-03-15 19:34 小二杰 阅读(105) 评论(0) 推荐(0) 编辑

最大子序列-N

摘要: #includeusing namespace std;int MaxSubSum(int A[], int N){ int ThisSum = 0; int MaxSum = 0; for(int i = 0; i MaxSum) MaxSum = ThisSum; else if(Th... 阅读全文

posted @ 2016-03-15 19:32 小二杰 阅读(95) 评论(0) 推荐(0) 编辑

2015年11月3日

LeetCode--Linked List Cycle

摘要: 题目: Given a linked list, determine if it has a cycle in it. 代码: /** * Definition for singly-linked list. * struct ListNode { * int val; * L... 阅读全文

posted @ 2015-11-03 19:31 小二杰 阅读(99) 评论(0) 推荐(0) 编辑

LeetCode--Missing Number

摘要: 题目: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given num... 阅读全文

posted @ 2015-11-03 17:25 小二杰 阅读(118) 评论(0) 推荐(0) 编辑

LeetCode--Binary Tree Inorder Traversal

摘要: 题目: Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 ... 阅读全文

posted @ 2015-11-03 14:40 小二杰 阅读(97) 评论(0) 推荐(0) 编辑

LeetCode--Binary Tree Preorder Traversal

摘要: 题目: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 ... 阅读全文

posted @ 2015-11-03 13:44 小二杰 阅读(119) 评论(0) 推荐(0) 编辑

LeetCode--Majority Element

摘要: 题目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assum... 阅读全文

posted @ 2015-11-03 13:42 小二杰 阅读(125) 评论(0) 推荐(0) 编辑

LeetCode--Valid Anagram

摘要: 题目: Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s =... 阅读全文

posted @ 2015-11-03 13:40 小二杰 阅读(97) 评论(0) 推荐(0) 编辑

LeetCode--Number of 1 Bits

摘要: 题目: Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, t... 阅读全文

posted @ 2015-11-03 13:37 小二杰 阅读(84) 评论(0) 推荐(0) 编辑

LeetCode--Excel Sheet Column Number

摘要: 题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For e... 阅读全文

posted @ 2015-11-03 11:38 小二杰 阅读(102) 评论(0) 推荐(0) 编辑

导航