码迷,mamicode.com
首页 >  
搜索关键字:reverse    ( 5099个结果
统计字符出现次数并排序(hash)
统计字符出现次数并排序class Hist(dict): def add(self, item, increment=1): """increase num""" self[item] = increment + self.get(item, 0) def counts(self, reverse=False): """return"""...
分类:编程语言   时间:2015-05-18 12:58:07    阅读次数:148
LeetCode_Reverse Linked List
LeetCode_Reverse Linked List...
分类:其他好文   时间:2015-05-18 10:59:26    阅读次数:138
leetcode_Rotate Array
当然,一个很简单且容易想到的思路就是直接循环移位k位即可,但每次都要移动n个元素,即总共需要移动k*n个元素 和Reverse Words in a String II题目类似,还有一种通过改变固定数目的元素就可以实现移位数组的功能,即先将1~len-k,len-k~len之间的元素逆置,最后将1~len之间的元素逆置,可以实现最后的旋转数组的目的。...
分类:其他好文   时间:2015-05-17 16:50:29    阅读次数:145
[LeetCode] 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 following co...
分类:其他好文   时间:2015-05-16 18:26:43    阅读次数:99
反转链表
带头结点的链表结点定义如下:1 struct ListNode2 {3 int value;4 ListNode *next;5 };代码如下: 1 ListNode* Reverse(ListNode *pHead) 2 { 3 ListNode *pReverse = N...
分类:其他好文   时间:2015-05-16 16:11:15    阅读次数:116
[LeetCode] Reverse Linked List(递归与非递归反转链表)
Reverse a singly linked list.解题思路对于非递归实现,思路是依次将从第二个结点到最后一个结点的后继设为头结点,然后将该节点设为头结点(需记住将原头结点的后继设为空)。 对于递归实现,首先反转从第二个结点到最后一个结点的链表,然后再将头结点放到已反转链表的最后,函数返回新链表的头结点。递归实现代码1//Runtime:10 ms class Solution { publ...
分类:其他好文   时间:2015-05-16 14:51:32    阅读次数:147
Java [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 th...
分类:编程语言   时间:2015-05-15 21:20:39    阅读次数:141
【Pointers On C】C和指针部分编程题 solution
第6章 指针 6.18.3   编写函数reverse_string,  函数原型为 void reverse_string(char *string); #define NUL '\0' void reverse_string(char *str) { char *tail = str; char *head = str; int len = 0; for (; *tail...
分类:其他好文   时间:2015-05-15 17:43:50    阅读次数:137
java十进制转二进制
例如: 5的二进制转换方法为 5除以2 得余数1 然后再用商值2继续除以2 得余数0 然后除尽了商值为1 所以 最后得到二进制值为 101 public static void main(String[] args)     {           StringBuffer sbf = toBin(10);           String str=sbf.reverse().to...
分类:编程语言   时间:2015-05-15 12:10:39    阅读次数:139
Lettcode_206_Reverse Linked List
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/45739753     Reverse a singly linked list. click to show more hints. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both? 思...
分类:其他好文   时间:2015-05-15 09:07:25    阅读次数:122
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!