We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03ddf92 commit 0418c89Copy full SHA for 0418c89
june_challenge/week_2/isSubsequence.cpp
@@ -5,7 +5,6 @@ class Solution
5
public:
6
bool isSubsequence(string s, string t)
7
{
8
-
9
int tpos = 0;
10
for (int i = 0; s[i] != '\0'; ++i)
11
june_challenge/week_2/segregate012.cpp
@@ -0,0 +1,34 @@
1
+#include <iostream>
2
+#include <vector>
3
+using namespace std;
4
+class Solution {
+public:
+ void sortColors(vector<int>& nums) {
+ int k1 = 0, k2 = nums.size() - 1;
+ int i = 0;
+ while(i != nums.size()) {
+ if(i > k2)
+ break;
12
+ if(nums[i] == 0) {
13
+ if(i == k1) {
14
+ i++;
15
+ k1++;
16
+ }
17
+ else {
18
+ swap(nums[k1++], nums[i]);
19
20
21
+ else if(nums[i] == 2) {
22
+ if(i == k2) {
23
24
+ k2--;
25
26
+ else
27
+ swap(nums[k2--], nums[i]);
28
29
30
31
32
33
34
+};
0 commit comments