c++学习笔记
某日暮光
这个作者很懒,什么都没留下…
展开
-
leetcode— 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.class Solution {public: bool isPalindrome(int x) { int a, b, tmp;int i = 0; a = 0; b = (x); while (b > 0) //负数不是原创 2017-06-01 22:15:50 · 228 阅读 · 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 answer is "原创 2017-04-27 19:33:50 · 198 阅读 · 0 评论 -
leetcode-2.Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i原创 2017-04-26 16:22:13 · 346 阅读 · 0 评论 -
leetcode-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, and you may not use the sam原创 2017-04-24 20:19:52 · 299 阅读 · 0 评论 -
百度机试-度度熊回家
一个数轴上共有N个点,第一个点的坐标是度度熊现在位置,第N-1个点是度度熊的家。现在他需要依次的从0号坐标走到N-1号坐标。但是除了0号坐标和N-1号坐标,他可以在其余的N-2个坐标中选出一个点,并直接将这个点忽略掉,问度度熊回家至少走多少距离? 输入描述:输入一个正整数N, N <= 50。接下来N个整数表示坐标,正数表示X轴的正方向,负数表示X轴的负方向。绝对值小于等于原创 2017-05-04 20:41:32 · 598 阅读 · 0 评论 -
百度机试—买帽子
度度熊想去商场买一顶帽子,商场里有N顶帽子,有些帽子的价格可能相同。度度熊想买一顶价格第三便宜的帽子,问第三便宜的帽子价格是多少? 输入描述:首先输入一个正整数N(N 输出描述:如果存在第三便宜的帽子,请输出这个价格是多少,否则输出-1输入例子:1010 10 10 10 20 20 30 30 40 40输出例子:30原创 2017-05-04 15:04:34 · 485 阅读 · 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转载 2017-05-03 19:29:08 · 274 阅读 · 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.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.原创 2017-05-03 09:08:25 · 271 阅读 · 0 评论 -
leetcode-4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 =原创 2017-05-02 14:01:46 · 276 阅读 · 0 评论 -
c++ 大小写转换&&字符转数字
大小写转换&&字符转数字,实验笔记。int main(){ //其实就是对ASCii表的操作 string s; char a = 'a'; int b = a - '0'; //字符转成数字 int c = (int)a; //就是asc码十进制值,不加(int)也会隐式转 char d = a + 32; //转小写原创 2017-07-04 20:39:39 · 5508 阅读 · 0 评论