This file contains 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
/** | |
* Update1: The solution didn't handle cases when a node covers its neighbours too | |
* Update2: Tested with randomly generated test cases ~10K | |
* Update3: Add an optimization to limit the max strength to range from -W to W, where W is the tree width | |
* DISCLAIMER: | |
* This solution is written for explanation/educational purposes | |
* and its intended to not follow coding guidelines or best practices | |
* as the main intention is to explain the thinking strategy in a way | |
* that's a little bit better than writing pseudo-code and to allow | |
* student(s) to test and add debugging messages in every step. |
This file contains 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
struct TrieNode { | |
public: | |
void insert(const string& word, int i) { | |
if (i >= word.size()) { | |
return; | |
} | |
if (children[word[i]] == NULL) { | |
children[word[i]] = new TrieNode(); |
This file contains 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<string> wordBreak(string s, vector<string>& wordDict) { | |
root = new TrieNode(); | |
for (string word : wordDict) { | |
root->insert(word, 0); | |
} | |
return wordBreakHelper(s, 0); |
This file contains 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
#include<iostream> | |
#include<algorithm> | |
#include<queue> | |
#include<map> | |
#include<functional> | |
using namespace std; | |
class Comparator { | |
public: | |
bool operator () (const pair<int, function<void()>> p1, const pair<int, function<void()>> p2) { |
This file contains 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
struct TrieNode { | |
public: | |
void insert(const string& word, int i) { | |
if (i >= word.size()) { | |
return; | |
} | |
if (children[word[i]] == NULL) { | |
children[word[i]] = new TrieNode(); |
This file contains 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
#include<iostream> | |
#include<cstdio> | |
#include<vector> | |
#include<algorithm> | |
#include<set> | |
#include<cstring> | |
#include<queue> | |
#include<map> | |
#include<stack> | |
#include<climits> |
This file contains 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
import lombok.SneakyThrows; | |
import lombok.extern.log4j.Log4j2; | |
import org.apache.logging.log4j.Level; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
@Log4j2 | |
public class Example { | |
@SneakyThrows |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>selenium-example</groupId> | |
<artifactId>automation-test</artifactId> | |
<version>1.0-SNAPSHOT</version> |
This file contains 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
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.Mock; | |
import org.mockito.runners.MockitoJUnitRunner; | |
import java.util.Arrays; | |
import java.util.List; | |
import static org.junit.Assert.*; |
This file contains 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
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class CSVLineParser { | |
private CSVLineReader reader; | |
public CSVLineParser(CSVLineReader reader) { | |
this.reader = reader; | |
} |
NewerOlder