C语言
文章平均质量分 58
allforwhat
这个作者很懒,什么都没留下…
展开
-
大端小端 简单的程序判断
http://blog.csdn.net/zhaoshuzhaoshu/article/details/37600857 1. 什么是大端,什么是小端: 所谓的大端模式,是指数据的低位保存在内存的高地址中,而数据的高位,保存在内存的低地址中; 所谓的小端模式,是指数据的低位保存在内存的低地址中,而数据的高位保存在内存的高地址中。 2.为什么会有大小端:转载 2015-02-12 16:03:17 · 800 阅读 · 0 评论 -
[leetcode 147]Insertion Sort List
Sort a linked list using insertion sort. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * };转载 2015-03-12 16:31:14 · 292 阅读 · 0 评论 -
[leetcode160链表]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 ↘转载 2015-03-12 17:25:31 · 361 阅读 · 0 评论 -
[leetoce 143 链表]Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example, Given {1,2,3,4}, reorder it to翻译 2015-03-12 14:56:37 · 393 阅读 · 0 评论 -
[leetcode 92]Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy the转载 2015-03-12 11:46:50 · 242 阅读 · 0 评论 -
[leetcode #86 链表] Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of转载 2015-03-12 11:14:50 · 285 阅读 · 0 评论 -
[leetcode141 142]Linked List Cycle I II
1 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 如何求环的长度,记住碰撞点的指针,让slow指针不停向后遍历,当再次回到碰撞点时走过的距离就是环的长度。 碰撞点到环节点 = 头结点到环节点 设环外转载 2015-03-12 13:22:49 · 294 阅读 · 0 评论 -
[leetcode #20 stack]Valid Parentheses
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转载 2015-03-14 19:12:48 · 241 阅读 · 0 评论 -
[leecode 190]Reverse digits of an integer.Reverse digits of an integer.
反转很容易实现,难的是对异常case的考虑。 比如如果没有示例,你是否会考虑到负数的情况。 10,100这个可以在写代码前问下面试官或者在代码里写明,表示你考虑到了这种情况。 然后就是有可能溢出!! Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -转载 2015-03-18 22:02:01 · 459 阅读 · 0 评论 -
[#23 leetcode]Merge k Sorted Lists
方法1:一开始想到的方法,每次都要遍历一遍vector.时间复杂度很高,如果每个链表都只有一个元素,但是有很多个链表。class Solution { public: ListNode *mergeKLists(vector &lists) { ListNode head(0); ListNode *p = &head; ListNode *转载 2015-03-11 14:14:39 · 299 阅读 · 0 评论 -
[leetcode 82]Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1-转载 2015-03-11 17:44:50 · 274 阅读 · 0 评论 -
[leetcode 83]Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. class Solut转载 2015-03-11 18:47:11 · 290 阅读 · 0 评论 -
[leetcode 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 as0011100101转载 2015-03-27 14:42:31 · 270 阅读 · 0 评论 -
[leetcode 168]Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB 考虑下这个正整转载 2015-03-17 14:38:27 · 293 阅读 · 0 评论 -
[leetcode #3待续]Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo转载 2015-03-17 13:11:09 · 304 阅读 · 0 评论 -
leetcode[21 链表]Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 很简单的题目,第一次刷的时候不知道加个头结点,代码如下,自己写的再看都觉得很难阅读,不够清晰。因为第一个节点是转载 2015-03-10 21:01:07 · 395 阅读 · 0 评论 -
[Leetcode 24 链表]Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. Y转载 2015-03-11 14:51:00 · 336 阅读 · 0 评论 -
[leetcode #25]Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is转载 2015-03-11 16:13:01 · 330 阅读 · 0 评论 -
[leetcode #61]Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. 需要考虑k大于链表长度,主流的方法是将链表成环然后找到位置然后断环转载 2015-03-11 17:00:37 · 278 阅读 · 0 评论 -
leetcode[#19 链表 标尺]Remove Nth Node From End of List
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转载 2015-03-10 16:59:34 · 417 阅读 · 0 评论 -
[leetcode 191]Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 000000原创 2015-03-18 21:17:42 · 268 阅读 · 0 评论