08 2017 档案

LeetCode: 371 Sum of Two Integers(easy)
摘要:题目: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example:Given a = 1 and b = 2, return 3. 代码: 使用移位来 阅读全文

posted @ 2017-08-31 10:40 玲珑子 阅读(84) 评论(0) 推荐(0)

LeetCode: 258 Add Digits(easy)
摘要:题目: 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 l 阅读全文

posted @ 2017-08-29 17:47 玲珑子 阅读(93) 评论(0) 推荐(0)

LeetCode: 448 Find All Numbers Disappeared in an Array(easy)
摘要:题目: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, 阅读全文

posted @ 2017-08-29 17:12 玲珑子 阅读(124) 评论(0) 推荐(0)

LeetCode: 226 Invert Binary Tree(easy)
摘要:题目: Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 代码: Invert a binary tree. 自己的(递归实现): 别人的: 自己的(使用队列,非递归实现): 非递归和递归的在Le 阅读全文

posted @ 2017-08-28 20:04 玲珑子 阅读(83) 评论(0) 推荐(0)

LeetCode: 520 Detect Capital(easy)
摘要:题目: Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when on 阅读全文

posted @ 2017-08-28 16:26 玲珑子 阅读(104) 评论(0) 推荐(0)

LeetCode:104 Maximum Depth of Binary Tree(easy)
摘要:题目: 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 farthe 阅读全文

posted @ 2017-08-28 10:11 玲珑子 阅读(97) 评论(0) 推荐(0)

LeetCode: 485 Max Consecutive Ones(easy)
摘要:题目: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The len 阅读全文

posted @ 2017-08-28 09:38 玲珑子 阅读(136) 评论(0) 推荐(0)

LeetCode: 136 Single Number(easy)
摘要:题目: Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime com 阅读全文

posted @ 2017-08-26 11:36 玲珑子 阅读(140) 评论(0) 推荐(0)

LeetCode: 292 Nim Game(easy)
摘要:题目: 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 阅读全文

posted @ 2017-08-26 10:52 玲珑子 阅读(96) 评论(0) 推荐(0)

LeetCode: 521 Longest Uncommon Subsequence I(easy)
摘要:题目: anysubsequence of the other strings. A subsequence is a sequence that can be derived from one sequence by deleting some characters without changin 阅读全文

posted @ 2017-08-26 09:32 玲珑子 阅读(126) 评论(0) 推荐(0)

LeetCode: 637 Average of Levels in Binary Tree
摘要:题目: Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 7 阅读全文

posted @ 2017-08-24 22:38 玲珑子 阅读(130) 评论(0) 推荐(0)

LeetCode: 496 Next Greater Element I(easy)
摘要:题目: You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nu 阅读全文

posted @ 2017-08-24 09:40 玲珑子 阅读(125) 评论(0) 推荐(0)

LeetCode: 463 Island Perimeter(easy)
摘要:题目: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontall 阅读全文

posted @ 2017-08-24 08:59 玲珑子 阅读(151) 评论(0) 推荐(0)

LeetCode: 620 Not Boring Movies(easy)
摘要:题目: X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and des 阅读全文

posted @ 2017-08-23 15:11 玲珑子 阅读(321) 评论(0) 推荐(0)

C++: 其他类型转string
摘要:1.to_string函数 C++11新增的函数,c++11标准增加了全局函数std::to_string,以及std::stoi/stol/stoll等等函数(string转int,long,以及long long) string to_string (int val);string to_str 阅读全文

posted @ 2017-08-23 14:50 玲珑子 阅读(633) 评论(0) 推荐(0)

LeetCode: 412 Fizz Buzz(easy)
摘要:题目: Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the n 阅读全文

posted @ 2017-08-23 14:45 玲珑子 阅读(132) 评论(0) 推荐(0)

LeetCode: 344 Reverse String
摘要:题目: Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". 代码: 自己的: 1 class Solutio 阅读全文

posted @ 2017-08-23 11:24 玲珑子 阅读(124) 评论(0) 推荐(0)

LeetCode: 566 Reshape the Matrix
摘要:题目: In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original d 阅读全文

posted @ 2017-08-22 20:11 玲珑子 阅读(153) 评论(0) 推荐(0)

LeetCode: 575 Distribute Candies(easy)
摘要:题目: Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy o 阅读全文

posted @ 2017-08-21 16:47 玲珑子 阅读(116) 评论(0) 推荐(0)

LeetCode: 557Reverse Words in a String III(easy)
摘要:题目: Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word orde 阅读全文

posted @ 2017-08-21 15:53 玲珑子 阅读(114) 评论(0) 推荐(0)

LeetCode: 500 Keyboard Row (easy)
摘要:题目: Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. E 阅读全文

posted @ 2017-08-21 15:19 玲珑子 阅读(160) 评论(0) 推荐(0)

LeetCode: 476 Number Complement(easy)
摘要:题目: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 1: 阅读全文

posted @ 2017-08-20 11:52 玲珑子 阅读(101) 评论(0) 推荐(0)

导航