- 博客(7)
- 收藏
- 关注
原创 实现单链表的反转
单链表的反转实现很常见:#include #include #include #define NUM 9typedef struct LNode{ int data; struct LNode *next;}LNode, *LinkedList;LNode slinklist = {0, NULL};int initLinkl
2016-08-30 14:04:45 689
原创 function to count the number of "1" of one byte
function to count the number of "1" of one byte ,for example 5(0101)has two "1"经常遇到的面试题,毫无疑问需要借助位操作:unsigned int bitCount (unsigned int value) { unsigned int count = 0; while (value >
2016-08-30 14:02:14 295
原创 求一个数组中子数组中的和的最大值
遇到的面试题:int maxSumOfArray(int array[], int len){ int mark = 0, i , j; int result = array[0]; for(i = 0; i < len; i ++) { if (mark >= 0) { mark += array[i]; } else { mark = arra
2016-08-30 13:59:09 537
原创 实现memove
void *memmoves(void *dest, const void *src, size_t count){ char *tmp_dst = NULL; const char *tmp_src = NULL; if (dest <= src) { tmp_dst = dest; tmp_src = src;
2016-08-30 13:54:13 362
原创 [Leetcode]字符串的反转
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".很简单,针对长度为奇偶情况不同,作对应的处理:char* reverseString(char* rs) { char *p
2016-08-28 14:33:15 788
原创 [Leetcode]Longest Substring Without Repeating Characters
题为:求最大长度的子串,要求不能有重复字符首先想到的是暴力解决方法,循环创建每个子串,并记录长度,同时确认是否有重复字符,如下:int lengthOfLongestSubstring(char* s) { int maxLen = 0; int i = 0, j = 0, len = 0; char *p = s, *res = s; len = strlen(s);
2016-08-28 11:31:21 525
原创 [LeetCode]Add Two Numbers解析
将两个链表的值进行相加,并返回一个新的链表,注意两个地方:一是考虑两个链表的长度是否相同,二是考虑相加后的进位问题/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */struct ListNode* a
2016-08-19 14:12:05 664
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人