[LeetCode C 实现]345. 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", return "holle".

Example 2:

Given s = "leetcode", return "leotcede".

Note:

The vowels does not include the letter "y".

......

[LeetCode C 实现]234. Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.

Follow up:

Could you do it in O(n) time and O(1) space?

题目描述比较简单:判断链表中的val组成的数字是否是回文数即形如12321 123321即是回文数。

如果题目中没有O(1) space的要求的话,那么可以把链表的值顺序读出放在数组中,然后进行判断。

一种比较巧妙的思路是:逆序(reverse)后半段,然后比较前后两段的值是否相同。

实现代码:

/**

* Definition for......

[LeetCode C 实现]20. Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

Open brackets must be closed by the same type of brackets.

Open brackets must be closed in the ......

[LeetCode C实现] 160. Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins.

For example, the following two linked lists:

A: a1 → a2

c1 → c2 → c3

B: b1 → b2 → b3

begin to intersect at node c1.

Notes:

If the two linked lists have no interse......

[LeetCode C 实现]38.Count and Say

The count-and-say sequence is the sequence of integers with the first five terms as following:

1

11

21

1211

111221

1 is read off as "one 1" or 11.

11 is read off as "two 1s" or 21.

21 is read off as "one 2, then one 1" or 1211.

Given an integer n, generat......

一道fork面试题

原文链接一道fork面试题,本文对其内容进行组织优化,新增Unix高级环境编程中对此部分功能的讨论。如对文章内容有任何问题欢迎留言讨论。由于微信订阅号的限制,发布后不能再编辑,因此可以通过阅读原文来获取最新文章内容。如果文章内容存在错误,欢迎发送消息讨论。

#include <stdio.h>

#include <sys/types.h>

#include <unistd.h>

int main(void)

{

int i;

for(i=0; i<2; i++){

fork();

printf("-");

}

wait(NU......

[CSAPP]Linux系统中的库

本文学习文章Linux库文件详解的笔记,并对其内容进行组织优化,新增Unix高级环境编程中对共享库的讨论与介绍。如对文章内容有任何问题欢迎留言讨论。由于微信订阅号的限制,发布后不能编辑内容,因此可以通过阅读原文来获取最新文章内容。如果文章内容存在错误,欢迎发送消息讨论。

基本概念

库是写好的现有的,成熟的,可以复用的代码。现实中每个程序都要依赖很多基础的底层库,不可能每个人的代码都从零开始,因此库的存在意义非同寻常。

本质上来说库是一种可执行代码的二进制形式,可以被操作系统载入内存执行。库有两种:静态库(.a,.lib)和动态库(共享库)(.so,.dll)。

Linux系统中静态库......

[LeetCode C 实现]190. Reverse Bits

Reverse bits of a given 32 bits unsigned integer.

For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000).

Follow up:

If this function is called many times, how would you opti......

[LeetCode C实现]292. Nim Game

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 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

Both of you are very clever and have......

[LeetCode C实现]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 it as a linked list.

You may assume the two numbers do not contain any leading zero, except the numb......