Here's a set of problems for the class. Exploiring strings.
Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?
Hints:
class Solution { | |
private: | |
void eraseIsland(vector<vector<char>>& grid, int x, int y) { | |
if (grid[y][x] == '0') { | |
return; | |
} | |
grid[y][x] = '0'; | |
if (y > 0) eraseIsland(grid, x, y - 1); | |
if (y < grid.size() - 1) eraseIsland(grid, x, y + 1); |
/** | |
* @param {number} dividend | |
* @param {number} divisor | |
* @return {number} | |
*/ | |
var divide = function(dividend, divisor) { | |
if (dividend == INT_MIN && divisor == -1) { | |
return INT_MAX; | |
} |
class Solution { | |
public: | |
vector<int> twoSum(vector<int>& nums, int target) { | |
vector<pair<int, int>> numsNpos; | |
for (auto i = 0; i < nums.size(); i++) { | |
numsNpos.push_back({ nums[i], i }); | |
} | |
sort(numsNpos.begin(), numsNpos.end()); | |
function removeItemFromStack(stack, item) { | |
const tmp = stack.pop(); | |
// if we've looked up the whole stack there's no item | |
// just return tmp element back to the top and we're done | |
if (stack.length === 0) { | |
stack.push(tmp); | |
return; | |
} | |
function mult(a, b) { | |
let carry = 0; | |
for (let i = 0; i < a.length || carry > 0; i++) { | |
if (i === a.length) { | |
a.push(0); | |
} | |
const curr = carry + a[i] * b; | |
a[i] = curr % 10; | |
carry = Math.floor(curr / 10); |
Hello software engineers and computer scientists! :)
I'm working on open source JavaScript project which has css parser as one if its modules. Node --perf shows me that the cricical part is REGEXP which is used to find the next word boundary.
const RE_WORD_END = /[ \n\t\r\f\(\)\{\}:;@!'"\\\]\[#]|\/(?=\*)/g;
// pos - current boundary
// next - next boundary which the code has to find
/my-website/
| package.json
| /src/
| | /pages/
| | | index.html
| | | about.html
| | /assets/
| | | site.css
| | | site.js
if (err.code === 'ERR_HTTP_HEADERS_SENT') { | |
//do something with the error | |
} |
if (err.message === 'Can\'t set headers after they are sent.') { | |
//do something with the error | |
} |