What is inside this repo? Each folder contains a algorithm questions, and some test (if it is written in ruby).
On the top of each question, there is a brief description of the question, input output, difficulty level and related tags.
How to ran it? Java solution:
- Open https://codepad.remoteinterview.io/pads in browser.
- Pause the solution in the editor and hit "run" on the bottom.
Ruby solution:
- Open the terminal and clone the folder.
- Direct inside the folder and ran Rspec file.
track everything!
input: an array of intergers and a target.
output: index position of the first/any/last of the given target.
public class TreeNode {
public int value;
public TreeNode left, right;
public TreeNode(int) {
this.value = int;
this.left = this.right = null;
}
}
// for codepad
class MyCode {
public static class TreeNode {
public int val;
public TreeNode left, right;
public TreeNode(int num) {
this.val = num;
this.left = this.right = null;
}
}
public static void main (String[] args) {
TreeNode root = new TreeNode(2);
root.left = new TreeNode(3);
root.right = new TreeNode(4);
System.out.println(root.val);
}
}
class TreeNode {
constructor(num) {
this.val = num;
this.left = this.right = null;
}
}
var root = new TreeNode(3);
console.log(root.val);
class TreeNode
attr_accessor :val, :left, :right
def initialize(num)
@val = num
@left = @right = nil
end
end
root = TreeNode.new(5)
puts root.val
public class TreeNode {
public int value;
public TreeNode left, right;
public TreeNode(int) {
this.value = int;
this.left = this.right = null;
}
}
// for codepad
class MyCode {
public static class TreeNode {
public int val;
public TreeNode left, right;
public TreeNode(int num) {
this.val = num;
this.left = this.right = null;
}
}
public static void main (String[] args) {
TreeNode root = new TreeNode(2);
root.left = new TreeNode(3);
root.right = new TreeNode(4);
System.out.println(root.val);
}
}
class TreeNode {
constructor(num) {
this.val = num;
this.left = this.right = null;
}
}
var root = new TreeNode(3);
console.log(root.val);
class TreeNode
attr_accessor :val, :left, :right
def initialize(num)
@val = num
@left = @right = nil
end
end
root = TreeNode.new(5)
puts root.val
Recursion:
- Definition
- Disassembly
- Exit
public ListNode {
int val;
ListNode next;
ListNode(int val) {
val = val;
next = null;
}
}
// reverse an array
// use while
public void reverse(char[] s) {
int left = 0, right = s.length - 1;
while (left < right) {
char temp = s[left];
s[left] = s[right];
s[right] = temp;
left++;
right--;
}
}
// use for loop
public void reverse(char[] s) {
for (int i = 0, j = s.length - 1; i < j; i++, j--) {
char temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}
- Remove Duplicates In An Array
- Window Sum
- Two Sum Difference Equals To Target
- Middle Of Linked List
- Linked List Cycle
How do we do this one?
- We can vote the topic for the next meetup and do flash talk(15min?).
- Have someone talks about it during the meetup.(more like a short class?? it may be really dry!)