Skip to content

Instantly share code, notes, and snippets.

View jomarpueyo's full-sized avatar

Jomar Pueyo jomarpueyo

  • Texas
View GitHub Profile
@jomarpueyo
jomarpueyo / Section5.java
Created December 23, 2018 01:12
My Coding Exercise Solutions for Java Programming Masterclass for Software Developers on Udemy for Section 5
package com.jomarpueyo;
import java.util.Scanner;
public class Section5 {
public static void main(String[] args) {
//Exercise 11
System.out.println("Exercise 11");
printNumberInWord(0);
@jomarpueyo
jomarpueyo / Section4.java
Last active September 28, 2020 17:37
My Coding Exercise Solutions for Java Programming Masterclass for Software Developers on Udemy for Section 4
public class Section4 {
public static void main(String[] args) {
//Coding Exercise 1
System.out.println("Exercise 1");
printMegaBytesAndKiloBytes(-1020);
printMegaBytesAndKiloBytes(1020);
printMegaBytesAndKiloBytes(2050);
//Coding Exercise 2
class Solution {
public boolean isPalindrome(int x) {
if(x<0){
return false;
}
char [] xArray = (""+x).toCharArray();
for(int i=0; i<xArray.length/2;i++){
if(xArray[i]!=xArray[xArray.length-1-i]){
return false;
}
@jomarpueyo
jomarpueyo / RomanToInt.java
Created October 11, 2018 02:27
leetcode.com // Problem 13. Convert Roman numerials to Integer equivalent https://leetcode.com/problems/roman-to-integer/description/
class Solution {
public int romanToInt(String s) {
Map<Character, Integer> map = new HashMap<>();
map.put('I',1);
map.put('V',5);
map.put('X',10);
map.put('L',50);
map.put('C',100);
map.put('D',500);
map.put('M',1000);
class Solution {
public String reverseString(String s) {
char [] sArray = s.toCharArray(); //Convert String to char[] Array
int swaps = sArray.length/2; //Find how many swaps (Odds round down)
int i = 0; //Index of character we are on
for (swaps = swaps; swaps!=0 ; swaps--){
char copy = sArray[i]; //Make a copy before over written
sArray[i] = sArray[sArray.length - 1 - i]; //Overwrite copy
sArray[sArray.length - 1 - i] = copy; //Set copy to swap position
i++; //Increment index
@jomarpueyo
jomarpueyo / ConvertBST.java
Created October 7, 2018 23:18
leetcode.com // Problem 538. Convert BST to Greater Tree https://leetcode.com/problems/convert-bst-to-greater-tree/description/
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
@jomarpueyo
jomarpueyo / shuffle.py
Last active October 7, 2018 22:26
Deck Shuffling Odds. What are the number of shuffles to a deck of n items back in order?
from random import shuffle
import sys
def main():
#sys.setrecursionlimit(9000) #system recursion limit
array_size = 7 #Number of Items in the list
myList=[] #Initialize List
for i in range(array_size): #Create List of User Input
myList.append(i+1) #Add item to list
class Solution {
public int numJewelsInStones(String J, String S) {
char [] jArray = J.toCharArray(); //Prep both strings to be searched
char [] sArray = S.toCharArray();
int count = 0;
for(char x : jArray){ //For every element in jArray,
for (char y : sArray){ //search in the sArray.