![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
jovetickop
这个作者很懒,什么都没留下…
展开
-
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; * ListNode *next; * ListNode(int x) : val(原创 2015-11-03 19:31:45 · 268 阅读 · 0 评论 -
LeetCode--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-11-03 11:08:31 · 201 阅读 · 0 评论 -
LeetCode--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-11-03 11:38:37 · 289 阅读 · 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, the 32-bit integer ’11' has binary representati原创 2015-11-03 13:37:32 · 248 阅读 · 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 = "rat", t = "car", return false.Note:Yo原创 2015-11-03 13:40:19 · 294 阅读 · 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 nums = [0, 1, 3] return 2.Note:Your algori原创 2015-11-03 17:25:42 · 252 阅读 · 0 评论 -
LeetCode--Single Number
题目:Given 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 withou原创 2015-11-03 10:54:01 · 228 阅读 · 0 评论 -
LeetCode--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 third node w原创 2015-11-03 11:06:23 · 243 阅读 · 0 评论 -
LeetCode--Best Time to Buy and Sell Stock II
题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i原创 2015-11-03 11:21:24 · 218 阅读 · 0 评论 -
LeetCode--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原创 2015-11-03 10:45:25 · 271 阅读 · 0 评论 -
LeetCode--Invert Binary Tree
题目:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by M原创 2015-11-03 11:16:28 · 265 阅读 · 0 评论 -
LeetCode--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 ca原创 2015-11-03 11:10:48 · 182 阅读 · 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 assume that the array is non-empty and the majority原创 2015-11-03 13:42:11 · 235 阅读 · 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 / 3return [1,3,2].代码:/** * Defi原创 2015-11-03 14:40:46 · 255 阅读 · 0 评论 -
LeetCode--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 b原创 2015-11-03 10:32:07 · 269 阅读 · 0 评论 -
LeetCode--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 ele原创 2015-11-03 11:23:56 · 279 阅读 · 0 评论 -
LeetCode--Excel Sheet Column Title
题目:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB原创 2015-11-03 11:33:48 · 230 阅读 · 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 / 3return [1,2,3].代码:/** *原创 2015-11-03 13:44:16 · 227 阅读 · 0 评论 -
LeetCode--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.代码: int maxDepth(TreeN原创 2015-11-03 11:02:40 · 262 阅读 · 0 评论 -
LeetCode--Single Number III
题目:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:原创 2015-11-03 11:29:10 · 257 阅读 · 0 评论