【简单】1-两数之和 Two Sum

【中等】2-两数相加 Add Two Num

【中等】3-无重复字符的最长子串 Longest Substring Without Repeating Characters

【困难】4-寻找两个有序数组的中位数 Median of Two Sorted Arrays

【中等】22-括号生成 Generate Parentheses

【中等】445-两数相加Ⅱ Add Two Numbers

【中等】542 - 01 矩阵 01 Matrix


时间: 04-15



原题: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging. 这也是我第一个过百行的代码(带注释,空格什么的) 主要分两个部分:输入和输出 #include < stdio.h > #define


原题: /*Write a program to print a histogram of the frequencies of *difficent characters in it inputs */ 这个和上一个类似 输入部分 #include < stdio.h >    #define NUM_CHARS 256    main ( void )  { int c; int done = 0; int thisIdx = 0; long frequrr[NUM_CHARS + 1];

Leetcode 详解(ReverseWords)

Leetcode里面关于字符串的一些问题,描述如下: Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For C programmers: Try to solve it inO(1) space. click to show cla

习题6-8 统计一行文本的单词个数(15 分)

本题目要求编写程序统计一行字符中单词的个数.所谓"单词"是指连续不含空格的字符串,各单词之间用空格分隔,空格数可以是多个. 输入格式: 输入给出一行字符. 输出格式: 在一行中输出单词个数. 输入样例: Let's go to room 209. 输出样例: 5 #include <stdio.h> int main() { char s[100]; int num=0,word=0;//num表示单词数,Word表示该字符是否是单词 char c; gets(s); fo

习题6-8 统计一行文本的单词个数 (15分)

本题目要求编写程序统计一行字符中单词的个数.所谓“单词”是指连续不含空格的字符串,各单词之间用空格分隔,空格数可以是多个. 输入格式: 输入给出一行字符. 输出格式: 在一行中输出单词个数. 输入样例: Let's go to room 209. 输出样例: 5 发现别人都是用数组,但是我自己觉得这个方法比较容易理解. #include<stdio.h> int main(void) { char ch='0'; int sum=0; int sign; while(ch!='\n'){ si

The Skyline Problem leetcode 详解

class Solution { public: vector<pair<int, int>> getSkyline(vector<vector<int>>& buildings) { vector<pair<int, int> > h, res; multiset<int> m; int pre = 0, cur = 0; for (auto &a : buildings) { h.push_back({

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, and you may not use the same element twice. 使用hash public int[] twoSum

LeetCode Summary Ranges (统计有序数列范围)

题意:给出个有序不重复数列(可能负数),用缩写法记录这个数列. 思路:找每个范围的起始和结束即可. 1 class Solution { 2 public: 3 vector<string> summaryRanges(vector<int>& nums) { 4 if(nums.empty()) return vector<string>(); 5 vector<string> vect; 6 for(int i=0; i<nums.size

(LeetCode)Count Primes --- 统计素数(质数)

Description: Count the number of prime numbers less than a non-negative number, n. Credits: Special thanks to @mithmatt for adding this problem and creating all test cases. Hint: Let's start with a isPrime function. To determine if a number is prime,