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
| // Can be run at https://coderpad.io/sandbox | |
| import java.io.*; | |
| import java.util.*; | |
| import org.junit.*; | |
| /** Rotate characters in string s, ‘r’ times without creating a copy | |
| * (i.e. change the supplied string in place). | |
| * | |
| * r > 0 - rotate right |
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.io.*; | |
| import java.util.*; | |
| import org.junit.Assert; | |
| class Solution { | |
| public static void main(String[] args) { | |
| int oranges[][] = { | |
| {2, 1, 0, 2, 1}, | |
| {1, 0, 1, 2, 1}, | |
| {1, 0, 0, 2, 1} |
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 StringIterator { | |
| Stack<Character> stack = new Stack<>(); | |
| public StringIterator(String compressedString) { | |
| int loop = 0; | |
| int loopLen = 0; | |
| boolean isPrevNum = false; | |
| for(int i=compressedString.length()-1; i>=0; i--) { | |
| int currentChar = compressedString.charAt(i) - '0'; | |
| if(currentChar >= 0 && currentChar <= 9) { | |
| if(isPrevNum) { |
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
| {"lastUpload":"2018-08-24T05:41:10.896Z","extensionVersion":"v3.0.0"} |
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 codezilla.leetcod3; | |
| import org.junit.Assert; | |
| public class LC8_StringToInt { | |
| public static void main(String[] args) { | |
| Assert.assertEquals(1, myAtoi("+1")); | |
| Assert.assertEquals(-42, myAtoi(" -42")); | |
| Assert.assertEquals(42, myAtoi("42")); |
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 org.junit.Assert; | |
| public class RotatedDigits { | |
| public static void main(String[] args) { | |
| Assert.assertEquals(4, rotatedDigits(10)); | |
| } | |
| public static int rotatedDigits(int N) { | |
| int inValidNums = 0; | |
| char[] rotateSelf = new char[]{'0', '1', '8'}; |
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
| /* | |
| You're now a baseball game point recorder. | |
| Given a list of strings, each string can be one of the 4 following types: | |
| Integer (one round's score): Directly represents the number of points you get in this round. | |
| "+" (one round's score): Represents that the points you get in this round are the sum of the last two valid round's points. | |
| "D" (one round's score): Represents that the points you get in this round are the doubled data of the last valid round's points. | |
| "C" (an operation, which isn't a round's score): Represents the last valid round's points you get were invalid and should be removed. | |
| Each round's operation is permanent and could have an impact on the round before and the round after. |
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
| function twilioCall() { | |
| var request = require("request"); | |
| var basicAuthToken = "Basic " + twilio.basicAuthToken; | |
| var textBody = twilio.textBody; | |
| var options = { method: 'POST', | |
| url: twilio.apiUrl, | |
| headers: | |
| { 'content-type': 'application/x-www-form-urlencoded', | |
| authorization: basicAuthToken | |
| }, |
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
| { | |
| "id": "WH-0P8978067F3103837-80650342HJ8089941", | |
| "create_time": "2016-05-09T17:29:18Z", | |
| "resource_type": "checkout-order", | |
| "event_type": "CHECKOUT.ORDER.PROCESSED", | |
| "summary": "A checkout order was processed", | |
| "resource": { | |
| "id": "19S86694A9334040A", | |
| "intent": "SALE", | |
| "payment_details": { |
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
| # Parses YouTube URLs directly or from iframe code. Handles: | |
| # * Address bar on YouTube url (ex: http://www.youtube.com/watch?v=ZFqlHhCNBOI) | |
| # * Direct http://youtu.be/ url (ex: http://youtu.be/ZFqlHhCNBOI) | |
| # * Full iframe embed code (ex: <iframe src="http://www.youtube.com/embed/ZFqlHhCNBOI">) | |
| # * Old <object> tag embed code (ex: <object><param name="movie" value="http://www.youtube.com/v/ZFqlHhCNBOI">...) | |
| /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/ | |
| $5 #=> the video ID | |
| # test it on Rubular: http://rubular.com/r/eaJeSMkJvo |
NewerOlder