leetcode Submission Details
代码:
#include<iostream>
#include<vector> using namespace std; struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
}; ListNode* rotateRight(ListNode* head, int k) {
if (head == NULL)
return head;
ListNode * p = head;
int i = ;
while (p->next != NULL)
{
p = p->next;
i++;
}
ListNode * tail = p;
int L = i;
cout << "L = " << L << endl;
k = L - k%L;
cout << "K = " << k << endl;
if (k == L)
return head;
i = ;
p = head;
while (i != k)
{
p = p->next;
i++;
}
cout << "p ="<<p->val << endl;
ListNode *newHead = p->next;
p->next = NULL;
tail->next = head;
return newHead;
} int main()
{
ListNode * head = new ListNode();
ListNode *p = head;
for (int i = ; i <= ; i++)
{
p->next = new ListNode(i);
p = p->next;
}
p = NULL;
for (ListNode * temp = head; temp != NULL; temp = temp->next)
cout << temp->val << endl;
ListNode * newHead = rotateRight(head, );
cout << "-----------------------------------------" << endl;
for (ListNode * temp = newHead; temp != NULL; temp = temp->next)
cout << temp->val << endl;
}
leetcode Submission Details的更多相关文章
- LeetCode——Submission Details
Description: Given a string of numbers and operators, return all possible results from computing all ...
- Submission Details [leetcode] 算法的改进
最先看到这一题,直觉的解法就是len从1到s1.size()-1,递归调用比較s1和s2长度为len的子串是否相等.以及剩余部分是否相等. 将s1分成s1[len + rest],分别比較s2[len ...
- 【leetcode】Submission Details
Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...
- Submission Details
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- [LeetCode OJ] Max Points on a Line
Max Points on a Line Submission Details 27 / 27 test cases passed. Status: Accepted Runtime: 472 ms ...
- [leetCode][012] Two Sum (1)
[题目]: Given an array of integers, find two numbers such that they add up to a specific target number ...
- [leetCode][016] Add Two Numbers
[题目]: You are given two linked lists representing two non-negative numbers. The digits are stored in ...
- leetcode 15. 3Sum 二维vector
传送门 15. 3Sum My Submissions Question Total Accepted: 108534 Total Submissions: 584814 Difficulty: Me ...
- [sqoop1.99.6] 基于1.99.6版本的一个小例子
1.创建mysql数据库.表.以及测试数据mysql> desc test;+-------+-------------+------+-----+---------+------------- ...
随机推荐
- 转: 使用Jmeter创建ActiveMQ JMS POINT TO POINT请求,环境搭建、请求创建、插件安装、监听服务器资源等
转自:http://www.cnblogs.com/qianyiliushang/p/4348584.html 准备工作: 安装JDK,推荐使用1.7以上版本,并设置JAVA_HOME 下载Jmete ...
- 在window下 进入系统盘命令
示例: cd C:\work 查看文件夹直接在当前路径下输入 dir 在当前路径下输入 dir/? 查看帮助
- protobuff java 包编译(Windows)
google probuffer的强大,很多人都知道,但是官方的source 里是没有jar下载,唯有源码下载,故需自己编译得到jar. java 的jar的编译采用maven 编译的,因此需先构建m ...
- 今天去python官网下载包安装的时候的问题记录
去官网下载了 tar压缩包 放到了site-packages下解压 然后使用 python setup.py install 安装 安装完后,所要引用的模块文件居然还在解压出来的压缩文件里面,导致无法 ...
- AngularJS:表格
ylbtech-AngularJS:表格 1.返回顶部 1. AngularJS 表格 ng-repeat 指令可以完美的显示表格. 在表格中显示数据 使用 angular 显示表格是非常简单的: A ...
- Python print format() 格式化内置函数
Python2.6 开始,新增了一种格式化字符串的函数 str.format(),它增强了字符串格式化的功能. 基本语法是通过 {} 和 : 来代替以前的 % . format 函数可以接受不限个参数 ...
- PHP $_SERVER变量
<?php #测试网址: http://localhost/t/test.php?id=5 //获取域名或主机地址 echo $_SERVER['HTTP_HOST']."<br ...
- oracle下载地址
12c 下载地址 http://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/index.html
- Apache配置中ProxyPass与ProxyPassReverse及ProxyPassMatch的概述
apache中的mod_proxy模块主要作用就是进行url的转发,即具有代理的功能.应用此功能,可以很方便的实现同tomcat等应用服务器的整合,甚者可以很方便的实现web集群的功能. 例如使用ap ...
- delphi IOS发布添加其他资源文件
添加自己的文件. Project>Deployment>Add File Remote Path android and IOS: assets\internal\ TPath.GetDo ...