This file contains hidden or 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 ListNode reverseList(ListNode head) { | |
ListNode prev = null; | |
ListNode current = head; | |
ListNode next = null; | |
while(current != null){ | |
next = current.next; | |
current.next = prev; |
This file contains hidden or 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
public class Solution { | |
public boolean hasCycle(ListNode head) { | |
//Using Hashset because items in hashset must be unique | |
HashSet<ListNode> hashSet = new HashSet<ListNode>(); | |
while(head != null){ | |
if(hashSet.contains(head)) | |
return true; | |
//when seeing the node for the first time, insert it in hashset | |
hashSet.add(head); |
This file contains hidden or 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 isPalindrome(int x) { | |
if(x<0){return false;} | |
String str = String.valueOf(x); | |
int length = str.length(); | |
for(int i = 0; i < length / 2; i++){ | |
if (str.charAt(i) != str.charAt(length- i - 1)) | |
return false; |
This file contains hidden or 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.*; | |
public class AnagramChecker { | |
public static void main(String[] args) { | |
List<String> wordList = new ArrayList<>(); | |
wordList.add("cat"); | |
wordList.add("is"); | |
wordList.add("in"); |
This file contains hidden or 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
package flag; | |
public class main { | |
public static void main(String args[]) { | |
String[] lines = {"RU", "WU", "WD"}; | |
Boolean redflag = true;//true = down | |
Boolean whiteflag = true; |
This file contains hidden or 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
npm i --save @fortawesome/fontawesome-svg-core | |
npm install --save @fortawesome/free-solid-svg-icons | |
npm install --save @fortawesome/react-fontawesome |
NewerOlder