![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
dama677409
这个作者很懒,什么都没留下…
展开
-
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 · 259 阅读 · 0 评论 -
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 · 243 阅读 · 0 评论 -
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 · 230 阅读 · 0 评论 -
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 · 252 阅读 · 0 评论 -
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 · 267 阅读 · 0 评论 -
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 · 264 阅读 · 0 评论 -
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 · 234 阅读 · 0 评论 -
Leetcode #171 Excel Sheet Column Number
Related 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 -> 2 C -> 3 ...原创 2015-12-01 20:47:20 · 282 阅读 · 1 评论 -
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 · 275 阅读 · 0 评论 -
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 · 237 阅读 · 0 评论 -
Leetcode #237 Delete Node in a Linked List
Delete Node in a Linked ListMy SubmissionsQuestionTotal Accepted: 46246 Total Submissions: 104863 Difficulty: EasyWrite a function to delete a node (except the tail) in a singl原创 2015-12-01 15:32:00 · 313 阅读 · 0 评论 -
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 3But the f原创 2015-12-03 17:03:56 · 321 阅读 · 0 评论