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 ListNode { | |
int val; | |
ListNode next; | |
ListNode() {} | |
ListNode(int val) { this.val = val; } | |
ListNode(int val, ListNode next) { this.val = val; this.next = next; } | |
} | |
public class HelloWorld { | |
public static void printList(ListNode node) { |
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 void insertionSort(int[] numbsers) { | |
for(int i = 1; i < numbsers.length; i++) { | |
int item = numbsers[i]; | |
int j = i - 1; | |
while (j >= 0 && item < numbsers[j]) { | |
numbsers[j + 1] = numbsers[j]; |
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 void merge(int[] nums1, int m, int[] nums2, int n) { | |
int capacity = m + n; | |
for(int i = capacity -1; i >= 0; i--) { | |
if(n < 1) { | |
return; |
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 void duplicateZeros(int[] arr) { | |
for(int i = 0; i < arr.length; i++) { | |
if(arr[i] == 0) { | |
shiftRight(arr, i); | |
i += 1; | |
} |
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 int[] sortedSquares(int[] nums) { | |
for(int i=0; i < nums.length; i++) { | |
nums[i] *= nums[i]; | |
} | |
this.quickSort(nums, 0, nums.length - 1); | |
return nums; |
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.io.*; | |
import java.net.ServerSocket; | |
import java.net.Socket; | |
import java.nio.charset.StandardCharsets; | |
public class HelloWorldWeb { | |
public static final int PORT = 80; | |
public static void main(String [] args) throws IOException { |
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 boolean canConstruct(String ransomNote, String magazine) { | |
int[] charCount = new int[26]; | |
for (char c: magazine.toCharArray()) { | |
charCount[c - 'a']++; | |
} | |
for (char c: ransomNote.toCharArray()) { |
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 boolean canConstruct(String ransomNote, String magazine) { | |
HashMap<Character,Integer> charMap = new HashMap<Character, Integer>(); | |
for(char c : magazine.toCharArray()) { | |
if(charMap.containsKey(c)) { | |
int frequency = charMap.get(c); | |
charMap.put(c, frequency + 1); |
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
/** | |
* 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; } | |
* } | |
*/ |
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
/** | |
* 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; } | |
* } | |
*/ |
NewerOlder