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
| /*pota-too*/ | |
| class Solution { | |
| public int singleNumber(int[] nums) { | |
| int hasil = 0; | |
| for (int i : nums) { | |
| hasil ^= i; | |
| } | |
| return hasil; | |
| } | |
| } |
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
| /*pota-too*/ | |
| class Solution { | |
| public int singleNumber(int[] nums) { | |
| int hitung= 0; | |
| int hasil=0; | |
| for (int i=0; i<nums.length; i++){ | |
| hitung=0; // reset nilai hitung menjadi 0 setiap i yang baru. | |
| for (int j=0;j<nums.length; j++){ | |
| if(nums[i] == nums[j]){ | |
| hitung+=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 Solution { | |
| public boolean isPerfectSquare(int num) { | |
| int p = 1; | |
| int r = num; | |
| while (p <= r) { | |
| int x = p - (p - r) / 2; | |
| if (x * x == num) return true; | |
| else if (x * x < num) p = x + 1; | |
| else r = x - 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
| String regex = "\\b([a-zA-z]+)(?:\\s+\\1\\b)+"; | |
| Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); | |
| while (m.find()){ | |
| input = input.replaceAll(m.group(),m.group(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 Solution { | |
| public List<Integer> findAnagrams(String s, String p) { | |
| int ns = s.length(); | |
| int np = p.length(); | |
| int[] sRef = new int[26]; | |
| int[] pRef = new int[26]; | |
| List<Integer> results = new ArrayList<>(); | |
| if(ns < np) { | |
| return results; // No solution |
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
| #include <cmath> | |
| #include <cstdio> | |
| #include <vector> | |
| #include <iostream> | |
| #include <algorithm> | |
| using namespace std; | |
| int main() { | |
| int p,q; | |
| cin >> p >> q ; |
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
| #include <cmath> | |
| #include <cstdio> | |
| #include <vector> | |
| #include <iostream> | |
| #include <algorithm> | |
| #include <sstream> | |
| #include <map> | |
| using namespace std; | |
| int main() { |
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: | |
| int countPrimes(int n) { | |
| if (n<= 2) return 0; | |
| int count = n/2; | |
| bool notPrime [n]; | |
| // for (int i=0; i<n; i++){ | |
| // notPrime[i]= false; | |
| // } | |
| memset(notPrime,false,n); |
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
| sudo apt-get update && sudo apt-get upgrade && sudo rpi-update | |
| sudo nano /etc/dphys-swapfile | |
| CONF_SWAPSIZE=2048 | |
| sudo apt-get install build-essential cmake pkg-config | |
| sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev | |
| sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev | |
| sudo apt-get install libxvidcore-dev libx264-dev | |
| sudo apt-get install libgtk2.0-dev libgtk-3-dev | |
| sudo apt-get install libatlas-base-dev gfortran |
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 int[] plusOne(int[] digits) { | |
| int len = digits.length; | |
| if(digits[len-1]<9) { | |
| digits[len-1] +=1; | |
| return digits; | |
| } | |
| else{ | |
| int i = len-1; | |
| while (digits[i]== 9){ |
OlderNewer