ori

leetcode--61--旋转链表

与世无争的帅哥 提交于 2020-03-04 18:26:47
题目描述: 给定一个链表,旋转链表,将链表每个节点向右移动 k 个位置,其中 k 是非负数。 示例 1 : 输入: 1->2->3->4->5->NULL, k = 2 输出: 4->5->1->2->3->NULL 解释: 向右旋转 1 步: 5->1->2->3->4->NULL 向右旋转 2 步: 4->5->1->2->3->NULL 示例 2 : 输入: 0->1->2->NULL, k = 4 输出: 2->0->1->NULL 解释: 向右旋转 1 步: 2->0->1->NULL 向右旋转 2 步: 1->2->0->NULL 向右旋转 3 步: 0->1->2->NULL 向右旋转 4 步: 2->0->1->NULL 解题思路1: 当链表在向右移动时, 移动的步数k有可能大于链表的长度。 移动链表后会让原链表的头和尾首尾相接,这就相当于是找一个环形链表的断开点, 找到这个新链表的头节点。因此, 将原链表尾节点指向头节点, 将原链表改造成一个环形链表. 根据移动步数k计算链表的断开点. 将断开的节点做头结点, 同时把新的尾节点置空. 代码: python class ListNode ( object ) : def __init__ ( self , x ) : self . val = x self . next = None class Solution (

12_3拓扑排序

落花浮王杯 提交于 2020-01-20 15:29:29
任务调度: 从task.in 文件中读入任务调度序列,输出n个任务适合的一种调度方式到task.out中。每行第一个表示前序任务,括号中的任务为若干个后序任务,表示只有在前序任务完成的情况下,后序任务才能开始。若后序为NULL则表示无后继任务。 Sample Input: Task0 ( Task1 , Task2 ) Task1 ( Task3 ) Task2 ( NULL ) Task3 ( NULL ) Sample Output: Task0 Task1 Task3 Task2 知识点: 从字符串中提取数字 拓扑排序 AC代码 # include <stdio.h> # include <cstring> # include <algorithm> # include <vector> # define maxn 1000 using namespace std ; vector < int > G [ maxn ] ; int n = 0 ; int InDegree [ maxn ] = { 0 } ; void TopoSort ( ) { int Q [ maxn ] ; int front = - 1 , rear = - 1 ; int u ; for ( int i = 0 ; i < n ; i ++ ) { if ( InDegree [ i ] == 0

2020 GDUT Winter Personal Training Contest I (Div. 2) D - Diverse Garland 题解

跟風遠走 提交于 2020-01-18 01:22:57
原题 题目大意 和 上一题 差别不大,就是这次和旁边不同的就行 题目分析 将上一题的贪心代码复制过来改改就行……不过这次贪心是看前一位和后一位(话说能叫贪心么) 代码 # include <cstdio> # include <cstring> # include <string> # include <iostream> char ori [ 400010 ] ; bool been [ 128 ] , flag ; int ans = 0 , fs = 0 , ft = 0 , tot = 0 ; int main ( ) { int n ; char t ; scanf ( "%d" , & n ) ; scanf ( "%s" , ori ) ; flag = false ; for ( ft = 0 ; ft < 2 && ft < n ; ft ++ ) { if ( ! been [ ori [ ft ] ] ) { been [ ori [ ft ] ] = true ; } else { flag = true ; } } if ( flag ) { been [ ori [ ft ] ] = true ; if ( ! been [ 'R' ] ) { ori [ 1 ] = 'R' ; been [ 'R' ] = true ; ans ++ ; } else

按指定的尺寸修改Pocal Voc数据中的GT的尺寸

送分小仙女□ 提交于 2019-12-25 01:26:22
import os import xml.etree.ElementTree as ET #程序功能:批量修改VOC数据集中xml标签文件的标签名称 def changelabelname(inputpath): listdir = os.listdir(inputpath) for file in listdir: if file.endswith('xml'): file = os.path.join(inputpath,file) print(file) tree = ET.parse(file) root = tree.getroot() for object1 in root.findall('object'): for bboxs in object1.findall('bndbox'): xmin=ymin=xmax=ymax=0 xmin_ori=ymin_ori=xmax_ori=ymax_ori=0 for bbox_xmin in bboxs.findall('xmin'): xmin_ori=int(bbox_xmin.text) xmin=int(bbox_xmin.text)-250 for bbox_ymin in bboxs.findall('ymin'): ymin_ori=int(bbox_ymin.text) ymin=int(bbox

PTA甲级——1136 A Delayed Palindrome (20 分)

爷,独闯天下 提交于 2019-12-05 07:43:06
1136 A Delayed Palindrome (20 分) Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ with 0≤a​i​​<10 for all i and a​k​​>0. Then N is palindromic if and only if a​i​​=a​k−i​​ for all i. Zero is written 0 and is also palindromic by definition. Non-palindromic numbers can be paired with palindromic ones via a series of operations. First, the non-palindromic number is reversed and the result is added to the original number. If the result is not a palindromic number, this is repeated until it gives a palindromic number. Such number is called a

Why is recode in R not changing the original values?

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use recode in R (from the car package) and it is not working. I read in data from a .csv file into a data frame called results . Then, I replace the values in the column Built_year , according to the following logic. recode(results$Built_year, "2 ='1950s';3='1960s';4='1970s';5='1980s';6='1990s';7='2000 or later'") When I check results$Built_year after doing this step, it appears to have worked. However, it does not store this value, and returns to its previous value. I don't understand why. Thanks. (at the moment something is

git - Your branch is ahead of &#039;origin/master&#039; by 1 commit

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am newbie in git and I am working on git. I added some files in git : git add <file1> git add <file2> then I wanted to push that for review, but mistakenly I did git commit so the files which I have changed don't go for reviews. Now if I enter the command : git status it says # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # nothing to commit (working directory clean) I want to revert that commit and I want to push those files for review rather than commit. Can anyone let me know how I can do that? 回答1: You cannot

SecurityError: Blocked a frame with origin from accessing a cross-origin frame

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am loading an in my HTML page and trying to access the elements within it using Javascript, but when I try to execute my code, I get the following error: SecurityError: Blocked a frame with origin "http://www. .com" from accessing a cross-origin frame. Can you please help me to find a solution so that I can access the elements in the frame? I am using this code for testing, but in vain: $(document).ready(function() { var iframeWindow = document.getElementById("my-iframe-id").contentWindow; iframeWindow.addEventListener("load", function() {

Getting a function&#039;s module of original definition

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Given a class or function, is there a way to find the full path of the module where it is originally defined? (I.e. using def xxx or class xxx .) I'm aware that there is sys.modules[func.__module__] . However, if func is imported in a package's __init__.py , then sys.modules will simply redirect to that __init__.py , because the function has been brought into that namespace, as far as my understanding goes. A concrete example: >>> import numpy as np >>> import sys >>> np.broadcast.__module__ 'numpy' >>> sys.modules[np.broadcast.__module__]

Chrome Version 66 : Blocked current origin from receiving cross-site document at

匿名 (未验证) 提交于 2019-12-03 01:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: On my local machine i have been using --disable-web-security --user-data-dir to disable the web security. After upgrading to Chrome Version 66 i have started getting Blocked current origin from receiving cross-site document at ... warning. How to disable the web security for this version of chrome ? 回答1: Found a workaround mentioned in https://www.chromium.org/Home/chromium-security/site-isolation C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --disable-web-securi ty --user-data-dir --disable-features