![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 52
愤怒的菜鸟_
修行之路。。。
展开
-
leetcode[7] Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321class Solution {public: int reverse(int x) { if (x > 0) { int a = 0, b; while (x > 0)原创 2016-08-04 10:54:42 · 146 阅读 · 0 评论 -
leetcode:Remove Nth Node From End of List [19]
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the原创 2016-08-16 22:06:55 · 219 阅读 · 0 评论 -
leetcode:Valid Parentheses [20]
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va原创 2016-08-16 22:08:14 · 215 阅读 · 0 评论 -
leetcode:3Sum Closest [16]
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact原创 2016-08-11 22:08:49 · 155 阅读 · 0 评论 -
leetcode:3Sum [15]
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain原创 2016-08-11 22:07:06 · 153 阅读 · 0 评论 -
leetcode:Longest Common Prefix [14]
Write a function to find the longest common prefix string amongst an array of strings.class Solution {public: string longestCommonPrefix(vector& strs) { if (strs.size() == 0) return "";原创 2016-08-09 22:29:42 · 158 阅读 · 0 评论 -
leetcode:Roman to Integer [13]
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.class Solution {public: int getVal(char a) { switch (a) { case 'I': return 1原创 2016-08-09 22:27:31 · 162 阅读 · 0 评论 -
leetcode:Integer to Roman [12]
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.class Solution { public: string intToRoman(int num) { string thousand[原创 2016-08-08 21:15:31 · 228 阅读 · 0 评论 -
leetcode:Letter Combinations of a Phone Number [17]
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st原创 2016-08-15 10:13:40 · 153 阅读 · 0 评论 -
leetcode:4Sum [18]
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution原创 2016-08-15 10:14:46 · 192 阅读 · 0 评论 -
leetcode:Container With Most Water [11]
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,原创 2016-08-08 21:13:41 · 175 阅读 · 0 评论 -
leetcode:Regular Expression Matching [10]
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st原创 2016-08-06 21:43:57 · 224 阅读 · 0 评论 -
leetcode[6] ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I原创 2016-08-04 10:53:26 · 132 阅读 · 0 评论 -
leetcode[5] Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.clas原创 2016-08-04 10:51:38 · 186 阅读 · 0 评论 -
error LNK2038 RuntimeLibrary 不匹配的解决
在工程上右键-》属性-》c/c++-》代码生成-》运行库error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”因为所选的工程运行库选择错误导致的。其中四个选项的对应含义如下:多线程调试Dll (/MDd) 对应的是MD_Dyna原创 2015-12-28 21:29:18 · 321 阅读 · 0 评论 -
leetcode-34. Search for a Range
class Solution {public: vector searchRange(vector& nums, int target) { int start = 0, end = nums.size() - 1; vector search; if (nums.empty()) { search.push_back(-1); search.push_back(-1)原创 2016-04-27 14:34:09 · 318 阅读 · 0 评论 -
leetcode-35. 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 would be if it were inserted in order.You may assume no duplicates in the array.原创 2016-04-27 14:40:40 · 221 阅读 · 0 评论 -
VS2015下一些问题解决方法
errorc4996的解决方法#define_CRT_SECURE_NO_DEPRECATE vs使用sort的函数必须添加如下语句#includeusingstd::sort; 解决运行完程序窗口自动关闭对该项目点右键->属性->链接器->系统在子系统那边选控制台原创 2016-04-27 14:46:42 · 223 阅读 · 0 评论 -
[LeetCode]1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Given nums =原创 2016-04-17 23:03:57 · 201 阅读 · 0 评论 -
[LeetCode]3. Longest Substring Without Repeating Characters
题目:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answ原创 2016-04-23 14:32:42 · 194 阅读 · 0 评论 -
leetcode之Construct Binary Tree from Preorder and Inorder Traversal
题目:Given preorder and inorder traversal of a tree, construct the binary tree.根据前序序列和中序序列构建二叉树。思路:前序序列的第一数必然是根结点,中序序列中,在该根结点前面的数均为根结点的左子树结点,该结点后面的数均为根结点的右子树结点,根据这个规律不断递归即可构建完整的二叉树。代码/** * De原创 2016-06-27 09:00:38 · 209 阅读 · 0 评论 -
leetcode:Repeated DNA Sequences
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.Wri原创 2016-07-14 21:17:43 · 184 阅读 · 0 评论 -
leetcode:Course Schedule
题目:There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expr原创 2016-07-16 21:22:53 · 164 阅读 · 0 评论 -
c++ 虚函数的实现机制:笔记
1、c++实现多态的方法其实很多人都知道,虚函数在c++中的实现机制就是用虚表和虚指针,但是具体是怎样的呢?从more effecive c++其中一篇文章里面可以知道:是每个类用了一个虚表,每个类的对象用了一个虚指针。具体的用法如下:class A{public: virtual void f(); virtual void g();private转载 2016-07-18 21:17:04 · 184 阅读 · 0 评论 -
leetcode:Word Search II
题目:Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are th原创 2016-07-18 21:45:56 · 180 阅读 · 0 评论 -
leetcode:Palindrome Number [9]
Determine whether an integer is a palindrome. Do this without extra space.class Solution {public: bool isPalindrome(int x) { int d = x; int a = 0; if (x >= 0) while (x != 0) { a原创 2016-08-06 21:42:38 · 176 阅读 · 0 评论