java实现的字符串翻转,能想到的这几种方法
如果有其他方法,欢迎交流
//字符串反转
public class ReverseString {
public String reverse1(String str){
StringBuffer sb = new StringBuffer(str);
str = sb.reverse().toString();
return str...
分类:
其他好文 时间:
2014-07-27 11:09:12
阅读次数:
211
10628. Count on a treeProblem code: COTYou are given a tree with N nodes.The tree nodes are numbered from 1 to N.Each node has an integer weight.We wi...
分类:
其他好文 时间:
2014-07-27 10:31:42
阅读次数:
304
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062解题报告:注意一行的末尾可能是空格,还有记得getchar()吃回车符。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #incl...
分类:
其他好文 时间:
2014-07-27 10:12:02
阅读次数:
149
Reverse Words in a String考虑几个特殊的情况1.若字符窜s=" "2.字符窜s=“a b d e”3.字符窜s=“ a”class Solution {public: void reverseWords(string &s) { int i; int c...
分类:
其他好文 时间:
2014-07-26 17:03:01
阅读次数:
360
[cpp] view plaincopytemplatevoidreverse(BidirectionalIteratorfirst,BidirectionalIteratorlast);[cpp] view plaincopy如果不是改变原来的容器,而是翻转之后放在新容器里面,直接用reverse...
分类:
编程语言 时间:
2014-07-26 16:59:21
阅读次数:
394
今天用python自带的sorted对一个列表进行排序, 在这里总结一下只要是可迭代对象都可以用sorted 。sorted(itrearble, cmp=None, key=None, reverse=False)=号后面是默认值 默认是升序排序的, 如果想让结果降序排列,用reverse=Tru...
分类:
编程语言 时间:
2014-07-26 14:49:40
阅读次数:
284
命令简介: 该命令用来删除Linux系统中的文件或目录。通常情况下rm不会删除目录,你必须通过指定参数-r或-R来删除目录。另外rm通常可以将该文件或目录恢复(注意,rm删除文件其实只是将指向数据块的索引点(information nodes)释放,只要不被覆盖,数据其实还在硬盘上。如果想要保证文件...
分类:
系统相关 时间:
2014-07-26 14:43:51
阅读次数:
547
题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or anothe....
分类:
编程语言 时间:
2014-07-26 14:14:35
阅读次数:
225
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example: Given binary tree {3...
分类:
其他好文 时间:
2014-07-26 14:03:16
阅读次数:
174
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321 1 class Solution { 2 public: 3 int reverse(int x){ 4 ...
分类:
其他好文 时间:
2014-07-26 13:54:24
阅读次数:
206