# Algorithm

`Input: x = 4Output: 2`
`class Solution {    public int mySqrt(int x) {        if (x == 0 || x == 1) {            return x;        }        int left = 1;        int right = x;        int ans = -1;        int mid;        while (left < right) {            mid = left + (right - left) / 2;            if (mid+1 <= x / (mid+1)) {                left = mid;            } else if (mid > x / mid) {                right = mid;            } else {                ans = mid;                break;            }        }        return ans;    }}`

# Review

1. Change the default port
`#Port 22122#AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress ::`
`\$ sudo systemctl restart sshd`
`\$ ssh-keygen -t ed25519    Generating public/private ed25519 key pair. Enter file in which to save the key (~/.ssh/id_ed25519):`
`\$ ssh-copy-id jgarrido@example.com`
`AllowUsers jgarrido jane tux`

# Tip

`#include <stdio.h>#include <string.h>int main(){    const char s1[] = "abcd\0\0\0\0";    const char s2[] = "abcd\0xyz";    const char s3[] = "abcdabcd";    printf("----- strcmp() -----\n");    printf("strcmp(s1, s2) = %d\n", strcmp(s1, s2)); // 0    printf("strcmp(s1, s2) = %d\n", strcmp(s1, s2)); // 0    printf("strcmp(s1, s2) = %d\n", strcmp(s2, s3)); // -97    printf("----- strncmp() -----\n");    printf("strncmp(s1, s2, 4) = %d\n", strncmp(s1, s2, 5)); // 0    printf("strncmp(s1, s3, 4) = %d\n", strncmp(s1, s3, 5)); // -97    printf("strncmp(s2, s3, 4) = %d\n", strncmp(s2, s3, 5)); // -97    printf("strncmp(s1, s2, 8) = %d\n", strncmp(s1, s2, 8)); // 0    printf("strncmp(s1, s3, 8) = %d\n", strncmp(s1, s3, 8)); // -97    printf("strncmp(s2, s3, 8) = %d\n", strncmp(s2, s3, 8)); // -97    printf("----- memcmp() -----\n");    printf("memcmp(s1, s2, 4) = %d\n", memcmp(s1, s2, 5)); // 0    printf("memcmp(s1, s3, 4) = %d\n", memcmp(s1, s3, 5)); // -97    printf("memcmp(s2, s3, 4) = %d\n", memcmp(s2, s3, 5)); // -97    printf("memcmp(s1, s2, 8) = %d\n", memcmp(s1, s2, 8)); // -120    printf("memcmp(s1, s3, 8) = %d\n", memcmp(s1, s3, 8)); // -97    printf("memcmp(s2, s3, 8) = %d\n", memcmp(s2, s3, 8)); // -97    return 0;}`

# Share

--

-- A programmer. Share knowledge of programming, operating system, Linux kernel, and reading, thinking etc. Let us maintain a beginner mend and grow together!