This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |