Skip to content

Commit 3e3aa60

Browse files
committed
Add questions on queues
1 parent 64239f4 commit 3e3aa60

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

leetcode/heap-sort/sort-an-array/adaa-mgbede.php

+31
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,35 @@ function maxHeap(&$arr, $n, $i) {
3232
list($arr[$j], $arr[$i]) = [$arr[$i], $arr[$j]];
3333
maxHeap($arr, $n, $j);
3434
}
35+
}
36+
37+
function sortStr($str) {
38+
$arrStr = str_split($str);
39+
sort($arrStr);
40+
return implode($arrStr);
41+
}
42+
43+
function stringMatching($s, $t) {
44+
$n = strlen($s);
45+
$m = strlen($t);
46+
47+
$s = sortStr($s);
48+
$t = sortStr($t);
49+
str_replace()
50+
51+
for($i = 0; $i <= ($m - $n); $i++) {
52+
53+
for($j = 0; $j < $n; $j++) {
54+
if($t[$i + $j] !== $s[$j]) {
55+
break;
56+
}
57+
}
58+
59+
if($j == $n) {
60+
return true;
61+
}
62+
}
63+
64+
return false;
65+
3566
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://leetcode.com/problems/design-circular-queue/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://leetcode.com/problems/implement-queue-using-stacks/
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://leetcode.com/problems/orderly-queue/

0 commit comments

Comments
 (0)