Skip to content

Instantly share code, notes, and snippets.

@LenarBad
LenarBad / WordBoggle.java
Last active February 23, 2024 17:42
Word Boggle
public String[] wordBoggle(char board[][], String[] dictionary)
{
Set<String> doableWords = new HashSet<String>();
for (String word : dictionary) {
if (!doableWords.contains(word)) {
for (int i = 0; i < board.length; i++) {
for (int j = 0; j < board[0].length; j++) {
if (canMakeWord(i, j, word, 0, board)) {
doableWords.add(word);
}
@LenarBad
LenarBad / ReverseLinkedList.java
Created February 15, 2024 18:22
Reverse linked list
public ListNode reverseList(ListNode head) {
ListNode prev = null;
ListNode current = head;
while(current != null) {
ListNode next = current.next;
current.next = prev;
prev = current;
current = next;
@LenarBad
LenarBad / ReverseLinkedListII.java
Last active February 8, 2024 18:30
Reverse Linked List II. Leetcode 92.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
@LenarBad
LenarBad / MyStack.java
Created February 8, 2024 18:25
Implement Stack using Queues
class MyStack {
private Queue<Integer> q;
public MyStack() {
this.q = new LinkedList();
}
public void push(int x) {
q.add(x);
@LenarBad
LenarBad / MyQueue.java
Created February 8, 2024 18:22
Implement Queue using stacks
class MyQueue {
private Stack<Integer> s1;
private Stack<Integer> s2;
public MyQueue() {
s1 = new Stack<>();
s2 = new Stack<>();
}
public void push(int x) {
@LenarBad
LenarBad / BinaryTreePeers.java
Last active August 8, 2019 01:59
Binary Tree Peers. Everything is public for simplicity
public class Node {
public int value;
public Node left;
public Node right;
public Node peer;
public Node(int value) {
this.value = value;
}
@LenarBad
LenarBad / Heroku - mLab MongoDB - Spring Boot - How to start example StatEntry.java
Last active June 5, 2019 22:09
Heroku - mLab MongoDB - Spring Boot - How to start example
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "stats")
public class StatEntry {
@Id
public String id;
@LenarBad
LenarBad / settings.xml
Last active April 16, 2019 14:57
Maven settings.xml for publishing open source projects
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>your-sonatype-username</username>
<password>your-sonatype-password</password>
</server>
@LenarBad
LenarBad / pom.xml
Created April 15, 2019 21:58
POM.XML for Open Source Maven project example
<?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>io.lenar</groupId>
<artifactId>app-props</artifactId>
<version>0.9.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AppProps</name>
@LenarBad
LenarBad / JenkinsScheduleFormat
Created April 8, 2019 23:33
Jenkins schedule format
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;
│ │ │ │ │ 7 is also Sunday on some systems)
│ │ │ │ │
│ │ │ │ │
* * * * * schedule command to execute