Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
joebiden
interview
提交
85910c51
I
interview
项目概览
joebiden
/
interview
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
interview
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
85910c51
编写于
4月 16, 2018
作者:
辉哈
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
删除LeetcodeProblems
上级
296d3cf8
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
0 addition
and
248 deletion
+0
-248
Problems/LeetcodeProblems/1-two-sum.h
Problems/LeetcodeProblems/1-two-sum.h
+0
-18
Problems/LeetcodeProblems/11-container-with-most-water.h
Problems/LeetcodeProblems/11-container-with-most-water.h
+0
-22
Problems/LeetcodeProblems/118-pascals-triangle.h
Problems/LeetcodeProblems/118-pascals-triangle.h
+0
-21
Problems/LeetcodeProblems/119-pascals-triangle-ii.h
Problems/LeetcodeProblems/119-pascals-triangle-ii.h
+0
-13
Problems/LeetcodeProblems/121-best-time-to-buy-and-sell-stock.h
...ms/LeetcodeProblems/121-best-time-to-buy-and-sell-stock.h
+0
-14
Problems/LeetcodeProblems/122-best-time-to-buy-and-sell-stock-ii.h
...LeetcodeProblems/122-best-time-to-buy-and-sell-stock-ii.h
+0
-26
Problems/LeetcodeProblems/169-majority-element.h
Problems/LeetcodeProblems/169-majority-element.h
+0
-26
Problems/LeetcodeProblems/26-remove-duplicates-from-sorted-array.h
...LeetcodeProblems/26-remove-duplicates-from-sorted-array.h
+0
-14
Problems/LeetcodeProblems/283-move-zeroes.h
Problems/LeetcodeProblems/283-move-zeroes.h
+0
-12
Problems/LeetcodeProblems/4-median-of-two-sorted-arrays.h
Problems/LeetcodeProblems/4-median-of-two-sorted-arrays.h
+0
-34
Problems/LeetcodeProblems/53-maximum-subarray.h
Problems/LeetcodeProblems/53-maximum-subarray.h
+0
-13
Problems/LeetcodeProblems/66-plus-one.h
Problems/LeetcodeProblems/66-plus-one.h
+0
-15
Problems/LeetcodeProblems/88-merge-sorted-array.h
Problems/LeetcodeProblems/88-merge-sorted-array.h
+0
-20
未找到文件。
Problems/LeetcodeProblems/1-two-sum.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
vector
<
int
>
twoSum
(
vector
<
int
>&
nums
,
int
target
)
{
vector
<
int
>
sum
;
for
(
auto
i
=
0
;
i
<
nums
.
size
();
i
++
)
{
for
(
auto
j
=
i
+
1
;
j
<
nums
.
size
();
j
++
)
{
if
(
i
==
j
)
continue
;
if
(
nums
[
i
]
+
nums
[
j
]
!=
target
)
continue
;
sum
.
push_back
(
i
);
sum
.
push_back
(
j
);
return
sum
;
}
}
return
sum
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/11-container-with-most-water.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
int
maxArea
(
vector
<
int
>&
height
)
{
int
left
=
0
,
right
=
height
.
size
()
-
1
;
int
max
=
0
,
temp
=
0
;
while
(
left
<
right
)
{
temp
=
(
right
-
left
)
*
(
height
[
left
]
<
height
[
right
]
?
height
[
left
]
:
height
[
right
]);
if
(
max
<
temp
)
max
=
temp
;
if
(
height
[
left
]
<
height
[
right
])
{
do
{
left
++
;
}
while
(
left
<
right
&&
height
[
left
-
1
]
>=
height
[
left
]);
}
else
{
do
{
right
--
;
}
while
(
left
<
right
&&
height
[
right
]
<=
height
[
right
+
1
]);
}
}
return
max
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/118-pascals-triangle.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
vector
<
vector
<
int
>>
generate
(
int
numRows
)
{
vector
<
vector
<
int
>>
triangle
;
for
(
int
i
=
0
;
i
<
numRows
;
i
++
){
vector
<
int
>
v
;
if
(
i
==
0
){
v
.
push_back
(
1
);
}
else
{
v
.
push_back
(
1
);
for
(
int
j
=
0
;
j
<
triangle
[
i
-
1
].
size
()
-
1
;
j
++
){
v
.
push_back
(
triangle
[
i
-
1
][
j
]
+
triangle
[
i
-
1
][
j
+
1
]);
}
v
.
push_back
(
1
);
}
triangle
.
push_back
(
v
);
}
return
triangle
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/119-pascals-triangle-ii.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
vector
<
int
>
getRow
(
int
rowIndex
)
{
vector
<
int
>
v
(
rowIndex
+
1
,
0
);
v
[
0
]
=
1
;
for
(
int
i
=
0
;
i
<
rowIndex
;
i
++
){
for
(
int
j
=
i
+
1
;
j
>
0
;
j
--
){
v
[
j
]
+=
v
[
j
-
1
];
}
}
return
v
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/121-best-time-to-buy-and-sell-stock.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
int
maxProfit
(
vector
<
int
>&
prices
)
{
int
left
=
0
,
right
=
0
;
int
max
=
0
,
temp
=
0
;
for
(
auto
i
=
0
;
i
<
prices
.
size
();
++
i
)
{
right
=
i
;
temp
=
prices
[
right
]
-
prices
[
left
];
if
(
temp
<
0
)
left
=
i
;
if
(
max
<
temp
)
max
=
temp
;
}
return
max
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/122-best-time-to-buy-and-sell-stock-ii.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
int
maxProfit
(
vector
<
int
>&
prices
)
{
int
max
=
0
,
begin
=
0
,
end
=
0
;
bool
up
=
false
,
down
=
false
;
for
(
int
i
=
1
;
i
<
prices
.
size
();
i
++
)
{
if
(
prices
[
i
]
>
prices
[
i
-
1
]
&&
up
==
false
){
// goes up
begin
=
i
-
1
;
up
=
true
;
down
=
false
;
}
if
(
prices
[
i
]
<
prices
[
i
-
1
]
&&
down
==
false
)
{
// goes down
end
=
i
-
1
;
down
=
true
;
up
=
false
;
max
+=
(
prices
[
end
]
-
prices
[
begin
]);
}
}
// edge case
if
(
begin
<
prices
.
size
()
&&
up
==
true
){
end
=
prices
.
size
()
-
1
;
max
+=
(
prices
[
end
]
-
prices
[
begin
]);
}
return
max
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/169-majority-element.h
已删除
100644 → 0
浏览文件 @
296d3cf8
#include <map>
class
Solution
{
public:
int
majorityElement
(
vector
<
int
>&
nums
)
{
int
n
=
nums
.
size
();
map
<
int
,
int
>
m_times
;
int
moreThanTimes
=
n
/
2
;
for
(
auto
i
=
0
;
i
<
n
;
++
i
)
{
auto
it
=
m_times
.
find
(
nums
[
i
]);
if
(
it
==
m_times
.
end
())
{
// No existence in map, insert
m_times
.
insert
(
std
::
pair
<
int
,
int
>
(
nums
[
i
],
1
));
it
=
m_times
.
find
(
nums
[
i
]);
}
// Is it more than ⌊ n/2 ⌋ times ?
if
((
*
it
).
second
>
moreThanTimes
)
{
return
(
*
it
).
first
;
}
else
{
(
*
it
).
second
++
;
}
}
// Can't find
return
-
1
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/26-remove-duplicates-from-sorted-array.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
int
removeDuplicates
(
vector
<
int
>&
nums
)
{
int
n
=
nums
.
size
(),
pos
=
0
;
if
(
n
<=
1
)
return
n
;
for
(
int
i
=
0
;
i
<
n
-
1
;
++
i
)
{
if
(
nums
[
i
]
!=
nums
[
i
+
1
])
{
nums
[
++
pos
]
=
nums
[
i
+
1
];
}
}
return
pos
+
1
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/283-move-zeroes.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
void
moveZeroes
(
vector
<
int
>&
nums
)
{
int
left
=
0
,
right
=
0
;
for
(;
left
<
nums
.
size
()
&&
nums
[
left
]
!=
0
;
left
++
);
for
(
right
=
left
;
right
<
nums
.
size
();
right
++
)
{
if
(
nums
[
right
]
==
0
)
continue
;
nums
[
left
++
]
=
nums
[
right
];
}
while
(
left
<
nums
.
size
())
nums
[
left
++
]
=
0
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/4-median-of-two-sorted-arrays.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
double
findMedianSortedArrays
(
vector
<
int
>&
nums1
,
vector
<
int
>&
nums2
)
{
int
len1
=
nums1
.
size
();
int
len2
=
nums2
.
size
();
int
len
=
len1
+
len2
;
if
(
len
&
1
)
return
findKth
(
nums1
,
0
,
nums2
,
0
,
len
/
2
+
1
);
else
return
(
findKth
(
nums1
,
0
,
nums2
,
0
,
len
/
2
)
+
findKth
(
nums1
,
0
,
nums2
,
0
,
len
/
2
+
1
))
/
2
;
}
// find kth number of two sorted array
double
findKth
(
vector
<
int
>&
nums1
,
int
i1
,
vector
<
int
>&
nums2
,
int
i2
,
int
k
)
{
if
(
i1
>=
nums1
.
size
())
{
return
nums2
[
i2
+
k
-
1
];
}
if
(
i2
>=
nums2
.
size
())
{
return
nums1
[
i1
+
k
-
1
];
}
if
(
k
==
1
)
{
return
min
(
nums1
[
i1
],
nums2
[
i2
]);
}
int
key1
=
i1
+
k
/
2
-
1
>=
nums1
.
size
()
?
INT_MAX
:
nums1
[
i1
+
k
/
2
-
1
];
int
key2
=
i2
+
k
/
2
-
1
>=
nums2
.
size
()
?
INT_MAX
:
nums2
[
i2
+
k
/
2
-
1
];
if
(
key1
<
key2
)
{
return
findKth
(
nums1
,
i1
+
k
/
2
,
nums2
,
i2
,
k
-
k
/
2
);
}
else
{
return
findKth
(
nums1
,
i1
,
nums2
,
i2
+
k
/
2
,
k
-
k
/
2
);
}
}
};
\ No newline at end of file
Problems/LeetcodeProblems/53-maximum-subarray.h
已删除
100644 → 0
浏览文件 @
296d3cf8
#define MIN_INT -2147483648
class
Solution
{
public:
int
maxSubArray
(
vector
<
int
>&
nums
)
{
int
max
=
MIN_INT
,
temp
=
0
;
for
(
auto
i
=
0
;
i
<
nums
.
size
();
++
i
)
{
temp
+=
nums
[
i
];
if
(
temp
>
max
)
max
=
temp
;
if
(
temp
<
0
)
temp
=
0
;
}
return
max
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/66-plus-one.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
vector
<
int
>
plusOne
(
vector
<
int
>&
digits
)
{
int
carry
=
1
;
for
(
int
i
=
digits
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
int
add
=
digits
[
i
]
+
carry
;
digits
[
i
]
=
add
%
10
;
carry
=
add
/
10
;
}
if
(
carry
>
0
)
{
digits
.
insert
(
digits
.
begin
(),
carry
);
}
return
digits
;
}
};
\ No newline at end of file
Problems/LeetcodeProblems/88-merge-sorted-array.h
已删除
100644 → 0
浏览文件 @
296d3cf8
class
Solution
{
public:
void
merge
(
vector
<
int
>&
nums1
,
int
m
,
vector
<
int
>&
nums2
,
int
n
)
{
int
i1
=
m
-
1
,
i2
=
n
-
1
;
for
(
int
i
=
m
+
n
-
1
;
i
>=
0
;
i
--
)
{
if
(
i1
>=
0
&&
i2
<
0
)
break
;
if
(
i1
<
0
&&
i2
>=
0
)
{
nums1
[
i
]
=
nums2
[
i2
--
];
}
if
(
i1
>=
0
&&
i2
>=
0
)
{
if
(
nums1
[
i1
]
>
nums2
[
i2
])
{
nums1
[
i
]
=
nums1
[
i1
--
];
}
else
{
nums1
[
i
]
=
nums2
[
i2
--
];
}
}
}
}
};
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录