Tag Archives: leet code

[Solved] RedisTemplate increment Error: io.lettuce.core.RedisCommandExecutionException: ERR value is not an intege

Redistemplate uses increment to report an error: io.lettuce.core.RedisCommandExecutionException: ERR value is not an intege

Problem analysis

We can learn from spring’s documents that spring has two rare serialization strategies for redis. One is the JDKSerializationRedisSerialzer serialization of RedisTemplate application. The serialized value contains object information, version number, class information, etc. after this serialization, a string cannot be self incremented.

The other is the StringRedisSerializer adopted by the StringRedisTemplate. This strategy converts the string value into a byte array, so the values saved in redis can be operated.

Solution:

Replace RedisTemplate with String RedisTemplate

How to Solve LeetCode Error: AddressSanitizer:DEADLYSIGNAL

LeetCode Error: AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL

AddressSanitizer:DEADLYSIGNAL
42ERROR: AddressSanitizer: SEGV on unknown address (pc 0x00000034e832 bp 0x7ffdffb45790 sp 0x7ffdffb45540 T0)
42The signal is caused by a READ memory access.
42Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.
#3 0x7f75a82060b2 (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
AddressSanitizer can not provide additional info.
42ABORTING

 

class Solution {
public:
    bool isValid(string s) {
          int n = s.size();
          if(n % 2 == 1){
              return false;
          }
          unordered_map<char, char> pairs = {
              {')','('},//key value
              {']','['},
              {'}','{'}
          };
          stack<char> stk;
          for(char ch:s){
              if(pairs.count(ch)){//Intrinsically check whether the pairs have elements with the given key ch
                  if(stk.top() != pairs[ch] || stk.empty()){
                      return false;
                  }
                  stk.pop();
              }else{
                  stk.push(ch);
              }
          }
          return stk.empty();
    }
};

Error reporting:

modification:

if(stk.empty() || stk.top() != pairs[ch])

Leetcode error: AddressSanitizer:DEADLYSIGNAL [How to Solve]

leetcode error:

AddressSanitizer:DEADLYSIGNAL ================================================================= ==43==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x00000034ca17 bp 0x7ffe82f08070 sp 0x7ffe82f07f40 T0) ==43==The signal is caused by a READ memory access. ==43==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used. #3 0x7f952a7800b2 (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) AddressSanitizer can not provide additional info. ==43==ABORTING

As you can see, the unknown address was accessed.
Reason:
The code accesses the top element of the stack for an empty stack

else if(s[i] == '}')
{
    if(st.top() == '{')
    {
       st.pop();
    }else
    {
       return false;
    }
}

Solution:

Just join the blank judgment

else if(s[i] == '}')
{
    if(!st.empty() && st.top() == '{')
    {
        st.pop();
    }else
    {
        return false;
    }
}

[Solved] Some index files failed to download.They have been ignored, or old ones used instead

sudo apt-get updateerror:

Err:1 http://ppa.launchpad.net/wireshark-dev/stable/ubuntu bionic InRelease
  Temporary failure resolving 'ppa.launchpad.net'
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://ppa.launchpad.net/wireshark-dev/stable/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'ppa.launchpad.net'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Use Ping www.google.comtest the network. If it appears: Ping: www.google.com: temporary failure in name resolution is a network problem,

Solution:

first

sudo vim /etc/systemd/resolved.conf

Modify DNS as follows:

[Resolve]
DNS=8.8.8.8
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

Modify the following configuration file

vim /etc/resolv.conf 

Add the following:

nameserver 8.8.8.8

Then restart:

reboot

Just update the source after restart:

sudo apt-get update