自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 资源 (4)
  • 收藏
  • 关注

原创 Leetcode #101 Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the f

2015-12-03 17:03:56 319

原创 Leetcode #83 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->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. /** * Definition

2015-12-02 01:01:46 226

原创 Leetcode #169 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 assume that the array is non-empty and the majority element

2015-12-01 21:06:23 263

原创 Leetcode #171 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 example: A -> 1 B -> 2 C -> 3 ...

2015-12-01 20:47:20 278 1

原创 Leetcode #242 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 = "rat", t = "car", return false. Note: You may ass

2015-12-01 17:38:14 238

原创 Leetcode #217 Contains Duplicate

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element

2015-12-01 17:20:11 231

原创 Leetcode #226 Invert Binary Tree

TreeNode* invertTree(TreeNode* root) { if(!root) return NULL; TreeNode* temp; temp = root->left; root->left = root->right; root->right = temp; invertTree(root->left); invertTree(root->right)

2015-12-01 16:44:58 249

原创 Leetcode #100 Same tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. /**

2015-12-01 16:39:17 260

原创 Leetcode #283 Move Zeroes

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling you

2015-12-01 16:01:57 234

原创 Leetcode #237 Delete Node in a Linked List

Delete Node in a Linked List My Submissions Question Total Accepted: 46246 Total Submissions: 104863 Difficulty: Easy Write a function to delete a node (except the tail) in a singl

2015-12-01 15:32:00 309

原创 Leetcode #104 Maximum Depth of Binary Tree

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ clas

2015-12-01 11:24:14 244

原创 Leetcode #258 Add Digits

class Solution { public: int addDigits(int num) { int sum = 0; while(num > 0) { sum += num %10; num = num /10; } if(sum >= 10) return addDigits(su

2015-12-01 11:09:09 255

原创 Leetcode #292 Nim Game

class Solution { public: bool canWinNim(int n) { return !(n % 4 == 0); } }; 只要n-1 或者 n-2 或者 n-3之后是4的倍数,就一定能赢。

2015-12-01 10:57:54 271

原创 Leetcode #191 Number of 1 Bits

Question: 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, the 32-bit integer ’11' has binary represen

2015-03-31 00:48:55 394

原创 Is It A Tree?,判断是否是一棵树。(题目来源:九度OJ 1481,2012年北京大学计算机研究生机试真题)

题目描述: A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties

2013-11-13 17:27:22 836

原创 九度OJ题目 1526 朋友圈 并查集

题目描述: 假如已知有n个人和m对好友关系(存于数字r)。如果两个人是直接或间接的好友(好友的好友的好友...),则认为他们属于同一个朋友圈,请写程序求出这n个人里一共有多少个朋友圈。 假如:n = 5 , m = 3 , r = {{1 , 2} , {2 , 3} , {4 , 5}},表示有5个人,1和2是好友,2和3是好友,4和5是好友,则1、2、3属于一个朋友圈,4、5属于另一个朋友

2013-09-19 14:49:36 1383

原创 前后重叠的最长子串(题目来源:九度OJ 1535题)

以下的题目链接和描述:http://ac.jobdu.com/problem.php?pid=1535 题目描述: 给定两个字符串,求它们前后重叠的最长子串的长度,比如"abcde"和“cdefg”是"cde",长度为3。 输入: 输入可能包含多个测试案例。 对于每个测试案例只有一行, 包含两个字符串。字符串长度不超过1000000,仅包含字符'a'-'z

2013-09-10 00:57:17 1356 3

N皇后问题和优化

N皇后问题及其优化,主要是对角线和副对角线的判断上面的优化。输入要求的皇后数目n,输出有多少种排列的数目。 九度OJ1254已经AC

2013-04-09

九度OJ八皇后问题

九度OJ八皇后问题,主要是主对角线和副对角线的判断上面优化。在九度1140上面已经AC

2013-04-09

2013年华科计算机考研上机第二题

2013年华科计算机考研上机第二题,c语言描述

2013-04-09

2013年华中科技大学计算机考研上机第一题

2013年华中科技大学计算机考研上机第一题,c语言描述

2013-04-09

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除