- 博客(13)
- 收藏
- 关注
原创 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 is...
2016-05-31 19:49:54 298
原创 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 a...
2016-05-31 19:39:01 217
原创 leetcode 171. Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number. 类似于进制转换 For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 2...
2016-05-30 19:38:08 228
原创 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. class ...
2016-05-30 19:26:25 195
原创 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. ...
2016-05-30 19:16:31 192
原创 leetcode 237. Delete Node in a Linked List
二十七号的。。。 Write 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 given the t...
2016-05-30 19:04:56 201
原创 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 your fu...
2016-05-26 10:17:40 176
原创 leetcode 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result must be unique. The result can b...
2016-05-26 09:28:44 209
原创 leetcode 226. Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 二叉树的递归实现: <span style="font-size:18px;">/** * Definition for a ...
2016-05-24 14:35:14 169
原创 leetcode 104 Maximum Depth of Binary Tree
Given 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. 二叉树的遍历。 /** * Definition f...
2016-05-23 19:15:39 244
原创 leetcode 258 Add Digits
Given 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 2 has only one dig...
2016-05-23 18:51:03 211
原创 leetcode 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be ...
2016-05-21 18:12:26 237
原创 leetcode第一天~344. Reverse String
第一天刷leetcode,先水一下签个到~ class Solution { public: string reverseString(string s) { string temp(s); int len; len = s.length(); for(int i=0;i<len;i++) ...
2016-05-20 21:08:29 243
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人