Skip to content

Instantly share code, notes, and snippets.

View DmitriiKosenko's full-sized avatar
🤠

Dmitrii Kosenko DmitriiKosenko

🤠
View GitHub Profile
class Solution {
public:
int strStr(string haystack, string needle) {
if (needle.length() == 0) return 0;
if (haystack.length() == 0) return -1;
if (needle.length() > haystack.length()) return -1;
if (haystack.length() == needle.length()) {
for (int i = 0; i < haystack.length(); i++) {
if (haystack[i] != needle[i]) return -1;
class Solution {
public:
int strStr(string haystack, string needle) {
if (needle.length() == 0) return 0;
if (haystack.length() == 0) return -1;
if (needle.length() > haystack.length()) return -1;
if (haystack.length() == needle.length()) {
for (int i = 0; i < haystack.length(); i++) {
if (haystack[i] != needle[i]) return -1;
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> result;
if (nums.size() == 2) {
result.push_back(0);
result.push_back(1);
return result;
}
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> result;
if (nums.size() == 2) {
result.push_back(0);
result.push_back(1);
return result;
}