- 博客(17)
- 资源 (3)
- 收藏
- 关注
原创 leetcode 100 Same Tree(难易度:Easy)
Same TreeGiven 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.d
2015-08-31 18:11:06 259
原创 leetcode 263 Ugly Number
Ugly NumberWrite a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example,6, 8 are ugly while 14 is
2015-08-31 11:42:21 278
原创 leetcode 125 Valid Palindrome(难易度:Easy)
Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."rac
2015-08-31 11:34:35 256
原创 leetcode 172 Factorial Trailing Zeroes(难易度:Easy)
Factorial Trailing ZeroesGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.代码:int trailingZeroes(int n) { if(n == 0
2015-08-31 11:21:03 271
原创 leetcode 234 Palindrome Linked List(难易度:Easy)
Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?代码:/** * Definition for singly-linked list. * stru
2015-08-30 14:00:41 336
原创 leetcode 104 Maximum Depth of Binary Tree(难易度:Easy)
Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.代码:/
2015-08-29 12:01:36 358
原创 leetcode 136 Single Number(难易度:Easy)
Single NumberGiven an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wi
2015-08-29 11:21:51 228
原创 leetcode 160 Intersection of Two Linked Lists(难易度:Easy)
Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2
2015-08-29 10:15:51 276
原创 leetcode 069 Sqrt(x)(难易度:Medium)
Sqrt(x)Implement int sqrt(int x).Compute and return the square root of x.代码:int mySqrt(int x) { if(x <= 0) return 0; int left = 1; int right = x; int ans; while
2015-08-29 10:00:44 352
原创 leetcode 235 Lowest Common Ancestor of a Binary Search Tree(难易度:Easy)
Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wiki
2015-08-28 13:49:00 483
原创 leetcode 264 Ugly Number II(难易度:Medium)
Ugly Number IIWrite a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example,1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequenc
2015-08-27 14:05:16 269
原创 leetcode 171 Excel Sheet Column Number(难易度:Easy)
Excel Sheet Column NumberRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -
2015-08-27 13:58:27 339
原创 leetcode 058 Length of Last Word(难易度:Easy)
Length of Last WordGiven a string s consists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return
2015-08-27 13:49:42 292
原创 leetcode 258 Add Digits(难易度:Easy)
Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since
2015-08-26 22:15:00 312
原创 leetcode 242 Valid Anagram(难易度:Easy)
Valid AnagramGiven 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.N
2015-08-26 22:04:23 377
原创 leetcode 237 Delete Node in a Linked List(难易度:Easy)
Delete Node in a Linked ListWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are g
2015-08-26 21:54:33 253
转载 Linux系统编程--lseek调用
lseek 每个打开的文件都记录着当前读写位置,打开文件时读写位置是0,表示文件开头,通常读写多少个字节就会将读写位置往后移多少个字节。但是有一个例外,如果以O_APPEND方式打开,每次写操作都会在文件末尾追加数据,然后将读写位置移到新的文件末尾。lseek和标准I/O库的fseek函数类似,可以移动当前读写位置(或者叫偏移量)。#include #includ
2015-08-06 11:15:52 370
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人