03 2018 档案

摘要:1、问题描述 Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime c 阅读全文
posted @ 2018-03-29 17:06 山里的小勇子 阅读(532) 评论(0) 推荐(0)
摘要:1、问题描述 Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it woul 阅读全文
posted @ 2018-03-29 15:57 山里的小勇子 阅读(180) 评论(0) 推荐(0)
摘要:1、题目描述 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 far 阅读全文
posted @ 2018-03-29 14:26 山里的小勇子 阅读(631) 评论(0) 推荐(0)
摘要:1、问题描述 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a can 阅读全文
posted @ 2018-03-29 14:09 山里的小勇子 阅读(340) 评论(0) 推荐(0)
摘要:1、问题描述 Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 - 阅读全文
posted @ 2018-03-29 12:53 山里的小勇子 阅读(3604) 评论(0) 推荐(0)
摘要:1、问题描述 Reverse Vowels of a String Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "hello", 阅读全文
posted @ 2018-03-29 10:37 山里的小勇子 阅读(433) 评论(0) 推荐(0)
摘要:1、题目描述 Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if t 阅读全文
posted @ 2018-03-28 17:52 山里的小勇子 阅读(145) 评论(0) 推荐(0)
摘要:1、题目描述 You are given a string representing an attendance record for a student. The record only contains the following three characters: A student coul 阅读全文
posted @ 2018-03-28 17:16 山里的小勇子 阅读(209) 评论(0) 推荐(0)
摘要:1、题目描述 Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Example 2: 阅读全文
posted @ 2018-03-27 20:06 山里的小勇子 阅读(875) 评论(0) 推荐(0)
摘要:1、题目描述 Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" re 阅读全文
posted @ 2018-03-27 18:59 山里的小勇子 阅读(1147) 评论(0) 推荐(0)
摘要:1、题目描述 X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be 阅读全文
posted @ 2018-03-27 14:08 山里的小勇子 阅读(1132) 评论(0) 推荐(0)
摘要:1、问题描述 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 阅读全文
posted @ 2018-03-26 17:16 山里的小勇子 阅读(145) 评论(0) 推荐(0)
摘要:1、题目描述 Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word o 阅读全文
posted @ 2018-03-26 16:12 山里的小勇子 阅读(169) 评论(0) 推荐(0)
摘要:1、题目描述 Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to 阅读全文
posted @ 2018-03-26 15:30 山里的小勇子 阅读(241) 评论(0) 推荐(0)
摘要:1、题目描述 返回一个 string中最后一个单词的长度。单词定义为没有空格的连续的字符,比如 ‘a’,'akkk'。 2、问题分析 从后向前扫描,如果string是以空格‘ ’结尾的,就不用计数,现将空格最后的空格排除掉,直到找到最后一个出现的字符。从最后一个出现的字符开始计数,一直到下一次出现空 阅读全文
posted @ 2018-03-26 13:44 山里的小勇子 阅读(154) 评论(0) 推荐(0)
摘要:1、题目描述 反转一个单链表。链表节点结构如下: 2、问题分析 特殊情况是输入的头结点是一个空的,或者只有一个头结点 3、代码实现 阅读全文
posted @ 2018-03-26 10:09 山里的小勇子 阅读(469) 评论(0) 推荐(0)
摘要:一、问题描述 判断一个integer 型的数字是否是回文,空间复杂度应该是常数级别的 。 二、问题分析 首先,负数不是回文,10的整数倍不会是回文,个位数一定是回文。 三、代码实现 思路:将一个数字翻转,即最高位变成最低位,最低位变成最高位,然后比较输入的字符和翻转之后的字符。 阅读全文
posted @ 2018-03-25 21:49 山里的小勇子 阅读(212) 评论(0) 推荐(0)
摘要:STL中的vector特点是: 其容量在需要时可以自动分配,本质上是数组形式的存储方式。即在索引可以在常数时间内完成。缺点是在插入或者删除一项时,需要线性时间。但是在尾部插入或者删除,是常数时间的。 STL的 list 是双向链表:如果知道位置,在其中进行插入和删除操作时,是常数时间的。索引则需要线 阅读全文
posted @ 2018-03-25 16:09 山里的小勇子 阅读(1965) 评论(0) 推荐(0)