p*****2 发帖数: 21240 | 1 我刚写了一个,没发现有什么问题。就是leetcode现在很慢。
public ListNode partition(ListNode head, int x) {
ListNode dummy=new ListNode(0);
dummy.next=head;
ListNode newDummy=new ListNode(0);
ListNode p1=dummy;
ListNode p2=newDummy;
while(p1.next!=null){
if(p1.next.val
p2.next=p1.next;
p2=p2.next;
p1.next=p1.next.next;
}
else
p1=p1.next;
... 阅读全帖 |
|
h******3 发帖数: 351 | 2 for the java solution, we have
public class Solution{
public partition(ListNode head, int x){
}
}
Where do you guys define class ListNode? Define in a separate java file or a
member class within Solution ?
thanks |
|
x*********w 发帖数: 533 | 3 为什么quick sort partition 在中间优于在1/3的位置?
换一个角度说,为什么
T(n) = n + T(n/2) + T(n/2)
优于
T(n) = n + T(n/3) + T(2n/3) |
|
S*****J 发帖数: 18 | 4 两个dp是求最小palindrome切割数的,这道题recursive地往回找就行了,和subsets的
思路差不多。
class Solution {
public:
bool isPalindrome(string s, int start, int end)
{
while(start
{
if(s[start]!=s[end])
return false;
start++;
end--;
}
return true;
}
void DFS(string &s, int start, vector &temp, vector
string>> &res)
{
if(start==s.size())
{
res.push_back(temp);
r... 阅读全帖 |
|
h**o 发帖数: 548 | 5 明白了。 谢谢。:-)
请问 我说的 Palindrome Partitioning 这道题 time 复杂度 是 n^n 吗? 如果不是
,那是什么那? |
|
h**o 发帖数: 548 | 6 明白了。 谢谢。:-)
请问 我说的 Palindrome Partitioning 这道题 time 复杂度 是 n^n 吗? 如果不是
,那是什么那? |
|
S*****J 发帖数: 18 | 7 两个dp是求最小palindrome切割数的,这道题recursive地往回找就行了,和subsets的
思路差不多。
class Solution {
public:
bool isPalindrome(string s, int start, int end)
{
while(start
{
if(s[start]!=s[end])
return false;
start++;
end--;
}
return true;
}
void DFS(string &s, int start, vector &temp, vector
string>> &res)
{
if(start==s.size())
{
res.push_back(temp);
r... 阅读全帖 |
|
h**o 发帖数: 548 | 8 明白了。 谢谢。:-)
请问 我说的 Palindrome Partitioning 这道题 time 复杂度 是 n^n 吗? 如果不是
,那是什么那? |
|
h**o 发帖数: 548 | 9 明白了。 谢谢。:-)
请问 我说的 Palindrome Partitioning 这道题 time 复杂度 是 n^n 吗? 如果不是
,那是什么那? |
|
c*********n 发帖数: 1057 | 10 同问这题求所有partition的复杂度是什么? |
|
j********r 发帖数: 25 | 11 /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *partition(ListNode *head, int x) {
ListNode dummy(0);
ListNode dummy2(0);
ListNode *p = &dummy;
ListNode *pp = &dummy2;
while(head) {
if (head->val < x) {
p->next = head;
p = p->next;
}
else {
... 阅读全帖 |
|
m**p 发帖数: 189 | 12 为什么泥?
class Solution {
public:
ListNode *partition(ListNode *head, int x) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
ListNode* dummy = new ListNode(-1);
ListNode* pivot = new ListNode(x);
ListNode* dummy_tail = dummy;
ListNode* pivot_tail = pivot;
ListNode* cur = head;
while (cur) {
if (cur->val < x) {
dummy_tail->next = cur;
dummy_tail = dummy_tail->next;
} else {
... 阅读全帖 |
|
h****g 发帖数: 308 | 13 You should preserve the original relative order of the nodes in each of the
two partitions. |
|
h****g 发帖数: 308 | 14 You should preserve the original relative order of the nodes in each of the
two partitions. |
|
l*********8 发帖数: 4642 | 15 c/c++ 可以写成这样。
void partition(int * low, int * high, int pivot) {
for (int *p = low; p < high; ) {
if (*p == pivot)
++p;
else if (*p < pivot)
swap(*low++, *p++);
else
swap(*p, *--high);
}
} |
|
l*********8 发帖数: 4642 | 16 high 是指向数组最后一个元素的后面一个。
比如:
int a[5] = {3,2, 7, 2, 1};
int pivot = 2;
partition(a, a+5, pivot); |
|
w*******1 发帖数: 32 | 17 原题在这:
https://oj.leetcode.com/problems/palindrome-partitioning/
根据结果分析猜是O(n*2^n),但是不会从代码分析。请教各位大牛,如果用以下代码,
怎么分析复杂度?
public void palindromeHelper(String input, List> resultList
, List curResult, int index){
if(index == input.length()){
resultList.add(new ArrayList(curResult));
return;
}
for(int i=index; i
String substring = input.substring(index, i+1);
if(isPalind... 阅读全帖 |
|
w*******1 发帖数: 32 | 18 多谢!!
但是从结果来看,一个长度为N的string,partition的结果个数为2^(N-1),相当于把N-
1个挡板插入N个字符里:
string: 1234
C30: 1234
C31: 1|234, 12|34, 123|4
C32: 1|2|34, 1|23|4, 12|3|4
C33: 1|2|3|4
C30 + C31 + C32 + C33 = 2^3
所以不考虑isPalindrom的影响,复杂度应该不低于O(2^N)
be |
|
y******r 发帖数: 1500 | 19 上次的sale价格还挺高的,reason一处写的“Tenancy Partition”,加之上次买房到
这次又卖房才不到一年时间,觉得比较奇怪,不理解怎么回事?
望大侠指点,谢谢 |
|
G*********a 发帖数: 113 | 20 用UltraISO在优盘上做了一个Windows 7系统,准备给T400装,但是装的过程中出现
Windows cannot be installed installed to Disk 0 Partition 1.请问这是怎么回事
,怎么解决?万分感谢! |
|
h*d 发帖数: 19309 | 21 据说现在可以支持NTFS partition放wbfs文件了。 |
|
|
F******n 发帖数: 18 | 23 divide 更强调一分为二,partition 可以分为几部分, 很多情况下可以通用,divide 更
口语化,
仅供参考. |
|
l***i 发帖数: 632 | 24 divide可以把东西归类 divide ... into subgroups...
partition没见过这么用的 |
|
s**s 发帖数: 404 | 25 division觉着更像一分部门
partition数学里是一图形分割 |
|
s****r 发帖数: 3326 | 26 I can think of two ways to make partitions, both of them will clear all data
in the disk though :(
1. Start the machine using OS 9 CD. It's like a live CD. You can use Disk
Utility under OS 9.
2. Start the machine using OS X install CD. Rather than install the system,
you cleck the menu to choose disk utility.
到 |
|
S**********y 发帖数: 101 | 27 通过 boot camp 在 mac mini 里装了 windows xp. 开始在 windows 环境下可以读
mac partition, 现在读不了了, 说 "the disk in drive F is not formatted, do
you want to format it now?"
怎末解决?谢谢! |
|
|
h****r 发帖数: 2056 | 29 Could anybody explain what is a partitioned database and where can we find
some related information online? |
|
k*****n 发帖数: 361 | 30 原始数据:
Date Value
2011-02-13 07:53:00 1.0
2011-02-13 07:56:00 2.0
2011-02-14 08:01:00 1.0
2011-02-14 08:03:00 1.0
2011-02-15 08:18:00 2.0
2011-02-15 08:27:00 1.0
2011-02-16 08:30:00 1.0
2011-02-16 08:40:00 1.0
2011-02-17 08:44:00 1.0
按相同日子分组后得到相同日子的value总数
select sum(Value)
from table
group by day(date)
得到
3.0
2.0
3.0
2.0
1.0
再取这组数据的avg值
不能用partition怎么写成一个语句 |
|
b******i 发帖数: 2536 | 31 空值可以用NVL,不知道MSSQL有没有这个功能
row_number partition by a order by b?
google一下就知道啦 |
|
j******i 发帖数: 121 | 32 非常感谢讲解。
还有点迷糊....
我们不需要drop data 就是建个新表 把半年的数据select as 导入,然后名字改掉
证明数据不存在 用select where 会不会是全表扫描?会时间很长么?能给个范例 讲
解吗
多谢多谢
[在 smallburrito (smallburrito) 的大作中提到:]
:你这个只是删除数据,最多就是DROP掉几个FILEGROUP,修改一下PARTITION SCHEME,
:INDEX REBUILD一下就够了吧,证明数据不存在,那不就是SELECT WHERE一下么
:........... |
|
j******i 发帖数: 121 | 33 是你说的那样按月partition
因为现在数据库太大了 为了容易维护的目的,把旧的table rename,复制出最新半年
的重新命名在数据库里.
但数据校验的方法我没有做过 不太明白
谢谢你的讲解,清晰容易理解 |
|
n****f 发帖数: 905 | 34 1, 是先load data到空白表,然后 partition,然后index。
SQL server 很強啊, 還能把空白表給分了。
行。 |
|
o*******8 发帖数: 249 | 35 表达错了,是想说建表的时候建成partition的。
你的意思是第一个方法好,对吗?为啥?谢谢指正。 |
|
w*********t 发帖数: 928 | 36 如果这 partition 有500-1000G. |
|
w*********t 发帖数: 928 | 37 tens of Gs, dd can handle that?
thanks, I am not very familiar with linux
that partition has been sitting there for years
now i want to store it as an image file rather than a physical disk |
|
n******7 发帖数: 5678 | 38 Just got my HP pc. "C:" is 640GB. How to partition it into 2 or more drives?
I tried Disk Management, but didn't see how to do it. |
|
N****w 发帖数: 21578 | 39 you can shrink it in Disk Management, then create a new partition
drives? |
|
n******7 发帖数: 5678 | 40 Thanks. I downloaded a free software called "Partition Wizard Home Edition 4
.0". It works. |
|
a9 发帖数: 21638 | 41 删掉就成未分区空间了,怎么会还是primary partition呢。 |
|
D**********N 发帖数: 743 | 42 的确是先成未分区空间,但是还是primary partition,可以就直接创建空间,但是我
希望是能并入到平常工作的logic drive去。 |
|
I****9 发帖数: 5245 | 43 expand neighboring partition |
|
m******c 发帖数: 2248 | 44 Dell PC,Win7,有两块硬盘,硬盘1有C(OS)和D,硬盘2有E和F分区,昨晚电脑蓝屏后
Partition D消失,我的电脑里看不到D盘,C,E,F好好的。在disk management下看到
D的空间的是unallocated,diskgenius给它加盘符后,D盘出现,里面的文件都在。可
是每次重启后,D盘总消失,每次启动后都要diskgenius手动加盘符才能看到D盘。
不想挪文件format D盘,请问有什么简单的解决办法么?
谢谢,问题解决后双黄包奉上。 |
|
i**e 发帖数: 6810 | 45 嗯,谢谢。也许我没写清楚。按Blue button或者F11,按完进去,选restore
to factory,然后就reboot到一个特殊的(windows based的)的环境,然后
问我要从前的backup(我没有专门做backup),而不是直接从recovery
partition restore。 |
|
S*A 发帖数: 7142 | 46 看你如何些,如果从新构建 partition table 的话不会。
如果就是 byte to byte copy 的话,后面空间就没有用上。
如果你自己要在后面 15G 读写数据也是可以的。
这个 LIVE USB 用完就从新格式化不就完了,你 16G 又回来了。 |
|
k**L 发帖数: 3630 | 47 Thanks for reply. here is the situation. I wanted to install a suitable
Linux Distro. into a old laptop that I have, this laptop has no CD-rom,
floppy drive, so I can't install any Distro that require CD/DVD bootup. Are
you saying that I should install DSL first? I tried loadlin but I think it
need a Linux partition first. so I am stuck. I've got a 30GB hard drive with
DOS command.com only. But I can take it out and copy file into it via
windows as a USB drive. I was thinking about OPENSUSE, you |
|
p*****s 发帖数: 344 | 48 u don't need linux partition to run dsl or slax.
as you have a powerful laptop, dsl is too small to play with, then
search slax.
as you only have a harddisk that can boot. I suggest you to search
"Starting GRUB for DOS from DOS".
You can use load GRUB for DOS in config.sys using one of the following
lines:
DEVICE=GRUB.EXE
INSTALL=GRUB.EXE
SHELL=GRUB.EXE
grub.exe can also be launched from DOS prompt or batch file such as
AUTOEXEC.BAT.
once you have grub running, it can boot slax easily. |
|
w*********t 发帖数: 928 | 49 not a system partition, I just need the data?
also how to backup my home directory on department's server?
dd, tar, or dump, etc? |
|
|